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

Method computeNECRawDataAndChecksum

src/ir_NEC.hpp:157–173  ·  view source on GitHub ↗

* Convert 16 bit address and 16 bit command to 32 bit NECRaw data * If we get a command < 0x100, we send command and then ~command * If we get an address < 0x100, we send 8 bit address and then ~address * !!! Be aware, that this is flexible, but makes it impossible to send e.g. 0x0042 as 16 bit value!!! * To force send 16 bit address, use: sendOnkyo(). */

Source from the content-addressed store, hash-verified

155 * To force send 16 bit address, use: sendOnkyo().
156 */
157uint32_t IRsend::computeNECRawDataAndChecksum(uint16_t aAddress, uint16_t aCommand) {
158 LongUnion tRawData;
159
160 // Address 16 bit LSB first
161 if ((aAddress & 0xFF00) == 0) {
162 // assume 8 bit address -> send 8 address bits and then 8 inverted address bits LSB first
163 tRawData.UByte.LowByte = aAddress;
164 tRawData.UByte.MidLowByte = ~tRawData.UByte.LowByte;
165 } else {
166 tRawData.UWord.LowWord = aAddress;
167 }
168
169 // send 8 command bits and then 8 inverted command bits LSB first
170 tRawData.UByte.MidHighByte = aCommand;
171 tRawData.UByte.HighByte = ~aCommand;
172 return tRawData.ULong;
173}
174
175/**
176 * NEC Send frame and special repeats

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected