MCPcopy Create free account
hub / github.com/Arduino-IRremote/Arduino-IRremote / computeLGRawDataAndChecksum

Method computeLGRawDataAndChecksum

src/ir_LG.hpp:138–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138uint32_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
153void IRsend::sendLG(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
154 sendPulseDistanceWidth_P(&LGProtocolConstants, computeLGRawDataAndChecksum(aAddress, aCommand), LG_BITS, aNumberOfRepeats);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected