* @param aAddress 5 address bits to be sent first (MSB first). * @param aCommand 6 or 7 (RC5X) bits. If aCommand is >=0x40 then we switch automatically to RC5X. * @param aEnableAutomaticToggle Send toggle bit according to the state of the static sLastSendToggleValue variable. */
| 227 | * @param aEnableAutomaticToggle Send toggle bit according to the state of the static sLastSendToggleValue variable. |
| 228 | */ |
| 229 | void IRsend::sendRC5(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle) { |
| 230 | |
| 231 | // Set IR carrier frequency |
| 232 | enableIROut (RC5_RC6_KHZ); |
| 233 | |
| 234 | uint16_t tIRData = ((aAddress & 0x1F) << (RC5_COMMAND_BITS)); // << 6 |
| 235 | |
| 236 | /* |
| 237 | * Process field bit (the bit after start bit) |
| 238 | * Field bit is 1 for RC5 and 0 (inverted 7. command bit) for RC5X |
| 239 | */ |
| 240 | if (aCommand >= 0x40) { // Auto discovery of RC5X |
| 241 | // Mask bit 7 of command to set field bit to 0 (inverted 1) for RC5X |
| 242 | aCommand &= 0x3F; |
| 243 | } else { |
| 244 | // Set field bit to 1 for RC5 |
| 245 | tIRData |= 1 << (RC5_TOGGLE_BIT + RC5_ADDRESS_BITS + RC5_COMMAND_BITS); // 1 << 12 = 0x1000 |
| 246 | } |
| 247 | tIRData |= aCommand; |
| 248 | |
| 249 | if (aEnableAutomaticToggle) { |
| 250 | // invert toggle bit if enabled |
| 251 | sLastSendToggleValue ^= 1; |
| 252 | } |
| 253 | // set toggled bit independent of current state of aEnableAutomaticToggle |
| 254 | if (sLastSendToggleValue) { |
| 255 | tIRData |= 1 << (RC5_ADDRESS_BITS + RC5_COMMAND_BITS); |
| 256 | } |
| 257 | |
| 258 | uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1; |
| 259 | while (tNumberOfCommands > 0) { |
| 260 | |
| 261 | // start bit is sent by sendBiphaseData |
| 262 | sendBiphaseData(RC5_UNIT, tIRData, RC5_BITS); |
| 263 | |
| 264 | tNumberOfCommands--; |
| 265 | // skip last delay! |
| 266 | if (tNumberOfCommands > 0) { |
| 267 | // send repeated command in a fixed raster |
| 268 | delay(RC5_REPEAT_DISTANCE / MICROS_IN_ONE_MILLI); |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | #if defined(DECODE_RC5) || defined(DECODE_MARANTZ) || defined(DECODE_RC6) |
| 274 | void IRrecv::initBiphaselevel(uint_fast8_t aRCDecodeRawbuffOffset, uint16_t aBiphaseTimeUnit) { |
nothing calls this directly
no outgoing calls
no test coverage detected