Skip to content

Added support for RC5 extended #522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions IRremote.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class IRsend
//......................................................................
# if SEND_RC5
void sendRC5 (unsigned long data, int nbits) ;
void sendRC5ext (unsigned long addr, unsigned long cmd, boolean toggle);
# endif
# if SEND_RC6
void sendRC6 (unsigned long data, int nbits) ;
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## ?
- Added Philips Extended RC-5 protocol support [PR #522] (https://github.com/z3t0/Arduino-IRremote/pull/522)

## 2.3.3 - 2017/03/31
- Added ESP32 IR receive support [PR #427](https://github.com/z3t0/Arduino-IRremote/pull/425)

Expand Down
67 changes: 67 additions & 0 deletions ir_RC5_RC6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,73 @@ void IRsend::sendRC5 (unsigned long data, int nbits)

space(0); // Always end with the LED off
}

void IRsend::sendRC5ext (unsigned long addr, unsigned long cmd, boolean toggle)
{
// Set IR carrier frequency
enableIROut(36);

unsigned long addressBits = 5;
unsigned long commandBits = 7;
unsigned long nbits = addressBits + commandBits;

// Start
mark(RC5_T1);

// Bit #6 of the command part, but inverted!
unsigned long cmdBit6 = (1UL << (commandBits-1)) & cmd;
if (cmdBit6) {
// Inverted (1 -> 0 = mark-to-space)
mark(RC5_T1);
space(RC5_T1);
} else {
space(RC5_T1);
mark(RC5_T1);
}
commandBits--;

// Toggle bit
static int toggleBit = 1;
if (toggle) {
if (toggleBit == 0) {
toggleBit = 1;
} else {
toggleBit = 0;
}
}
if (toggleBit) {
space(RC5_T1);
mark(RC5_T1);
} else {
mark(RC5_T1);
space(RC5_T1);
}

// Address
for (unsigned long mask = 1UL << (addressBits - 1); mask; mask >>= 1) {
if (addr & mask) {
space(RC5_T1); // 1 is space, then mark
mark(RC5_T1);
} else {
mark(RC5_T1);
space(RC5_T1);
}
}

// Command
for (unsigned long mask = 1UL << (commandBits - 1); mask; mask >>= 1) {
if (cmd & mask) {
space(RC5_T1); // 1 is space, then mark
mark(RC5_T1);
} else {
mark(RC5_T1);
space(RC5_T1);
}
}

space(0); // Always end with the LED off
}

#endif

//+=============================================================================
Expand Down