File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -270,6 +270,7 @@ class IRsend
270270 // ......................................................................
271271# if SEND_RC5
272272 void sendRC5 (unsigned long data, int nbits) ;
273+ void sendRC5ext (unsigned long addr, unsigned long cmd, boolean toggle);
273274# endif
274275# if SEND_RC6
275276 void sendRC6 (unsigned long data, int nbits) ;
Original file line number Diff line number Diff line change @@ -78,6 +78,73 @@ void IRsend::sendRC5 (unsigned long data, int nbits)
7878
7979 space (0 ); // Always end with the LED off
8080}
81+
82+ void IRsend::sendRC5ext (unsigned long addr, unsigned long cmd, boolean toggle)
83+ {
84+ // Set IR carrier frequency
85+ enableIROut (36 );
86+
87+ unsigned long addressBits = 5 ;
88+ unsigned long commandBits = 7 ;
89+ unsigned long nbits = addressBits + commandBits;
90+
91+ // Start
92+ mark (RC5_T1);
93+
94+ // Bit #6 of the command part, but inverted!
95+ unsigned long cmdBit6 = (1UL << (commandBits-1 )) & cmd;
96+ if (cmdBit6) {
97+ // Inverted (1 -> 0 = mark-to-space)
98+ mark (RC5_T1);
99+ space (RC5_T1);
100+ } else {
101+ space (RC5_T1);
102+ mark (RC5_T1);
103+ }
104+ commandBits--;
105+
106+ // Toggle bit
107+ static int toggleBit = 1 ;
108+ if (toggle) {
109+ if (toggleBit == 0 ) {
110+ toggleBit = 1 ;
111+ } else {
112+ toggleBit = 0 ;
113+ }
114+ }
115+ if (toggleBit) {
116+ space (RC5_T1);
117+ mark (RC5_T1);
118+ } else {
119+ mark (RC5_T1);
120+ space (RC5_T1);
121+ }
122+
123+ // Address
124+ for (unsigned long mask = 1UL << (addressBits - 1 ); mask; mask >>= 1 ) {
125+ if (addr & mask) {
126+ space (RC5_T1); // 1 is space, then mark
127+ mark (RC5_T1);
128+ } else {
129+ mark (RC5_T1);
130+ space (RC5_T1);
131+ }
132+ }
133+
134+ // Command
135+ for (unsigned long mask = 1UL << (commandBits - 1 ); mask; mask >>= 1 ) {
136+ if (cmd & mask) {
137+ space (RC5_T1); // 1 is space, then mark
138+ mark (RC5_T1);
139+ } else {
140+ mark (RC5_T1);
141+ space (RC5_T1);
142+ }
143+ }
144+
145+ space (0 ); // Always end with the LED off
146+ }
147+
81148#endif
82149
83150// +=============================================================================
You can’t perform that action at this time.
0 commit comments