| 136 | } |
| 137 | |
| 138 | uint32_t IRsend::computeLGRawDataAndChecksum(uint8_t aAddress, uint16_t aCommand) { |
| 139 | uint32_t tRawData = ((uint32_t) aAddress << (LG_COMMAND_BITS + LG_CHECKSUM_BITS)) | ((uint32_t) aCommand << LG_CHECKSUM_BITS); |
| 140 | /* |
| 141 | * My guess of the 4 bit checksum |
| 142 | * Addition of all 4 nibbles of the 16 bit command |
| 143 | */ |
| 144 | uint8_t tChecksum = 0; |
| 145 | uint16_t tTempForChecksum = aCommand; |
| 146 | for (int i = 0; i < 4; ++i) { |
| 147 | tChecksum += tTempForChecksum & 0xF; // add low nibble |
| 148 | tTempForChecksum >>= 4; // shift by a nibble |
| 149 | } |
| 150 | return (tRawData | (tChecksum & 0xF)); |
| 151 | } |
| 152 | |
| 153 | void IRsend::sendLG(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) { |
| 154 | sendPulseDistanceWidth_P(&LGProtocolConstants, computeLGRawDataAndChecksum(aAddress, aCommand), LG_BITS, aNumberOfRepeats); |
nothing calls this directly
no outgoing calls
no test coverage detected