Go to the documentation of this file.
35 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
94 #define LG_ADDRESS_BITS 8
95 #define LG_COMMAND_BITS 16
96 #define LG_CHECKSUM_BITS 4
97 #define LG_BITS (LG_ADDRESS_BITS + LG_COMMAND_BITS + LG_CHECKSUM_BITS) // 28
99 #define LG_UNIT 500 // 19 periods of 38 kHz
101 #define LG_HEADER_MARK (18 * LG_UNIT) // 9000
102 #define LG_HEADER_SPACE 4200 // 4200 | 84
104 #define LG2_HEADER_MARK (19 * LG_UNIT) // 9500
105 #define LG2_HEADER_SPACE (6 * LG_UNIT) // 3000
107 #define LG_BIT_MARK LG_UNIT
108 #define LG_ONE_SPACE 1580 // 60 periods of 38 kHz
109 #define LG_ZERO_SPACE 550
111 #define LG_REPEAT_HEADER_SPACE (4 * LG_UNIT) // 2250
112 #define LG_REPEAT_PERIOD 110000 // Commands are repeated every 110 ms (measured from start to start) for as long as the key on the remote control is held down.
153 uint8_t tChecksum = 0;
154 uint16_t tTempForChecksum =
aCommand;
155 for (
int i = 0; i < 4; ++i) {
156 tChecksum += tTempForChecksum & 0xF;
157 tTempForChecksum >>= 4;
159 return (tRawData | (tChecksum & 0xF));
165 void IRsend::sendLG(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
172 void IRsend::sendLG2(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
201 #if defined(LOCAL_DEBUG)
202 Serial.print(F(
"LG: "));
203 Serial.println(F(
"Header mark is wrong"));
219 #if defined(LOCAL_DEBUG)
220 Serial.print(F(
"LG: "));
221 Serial.print(F(
"Repeat header space is wrong"));
228 #if defined(LOCAL_DEBUG)
229 Serial.print(F(
"LG: "));
230 Serial.println(F(
"Header space length is wrong"));
236 #if defined(LOCAL_DEBUG)
237 Serial.print(F(
"LG: "));
238 Serial.println(F(
"Decode failed"));
251 uint8_t tChecksum = 0;
253 for (
int i = 0; i < 4; ++i) {
254 tChecksum += tTempForChecksum & 0xF;
255 tTempForChecksum >>= 4;
259 #if defined(LOCAL_DEBUG)
260 Serial.print(F(
"LG: "));
261 Serial.print(F(
"4 bit checksum is not correct. expected=0x"));
262 Serial.print(tChecksum, HEX);
263 Serial.print(F(
" received=0x"));
265 Serial.print(F(
" data=0x"));
291 unsigned int offset = 1;
314 #if defined(LOCAL_DEBUG)
315 Serial.println(F(
"Stop bit mark length is wrong"));
332 #if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__))
346 #if defined(LOCAL_DEBUG)
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
#define LG_REPEAT_HEADER_SPACE
void sendLGRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats=NO_REPEATS)
Here you can put your raw data, even one with "wrong" checksum.
Results returned from old decoders !!!deprecated!!!
#define PROTOCOL_IS_MSB_FIRST
decode_type_t lastDecodedProtocol
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
void int_fast8_t aNumberOfRepeats
#define MICROS_IN_ONE_MILLI
void mark(uint16_t aMarkMicros)
Sends an IR mark for the specified number of microseconds.
#define IRDATA_FLAGS_IS_REPEAT
The gap between the preceding frame is as smaller than the maximum gap expected for a repeat....
decode_type_t
An enum consisting of all supported formats.
void sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats)
Sends PulseDistance frames and repeats.
irparams_struct * rawDataPtr
Pointer of the raw timing data to be decoded. Mainly the OverflowFlag and the data buffer filled by r...
decode_type_t decode_type
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
#define IR_DEBUG_PRINT(...)
If DEBUG, print the arguments, otherwise do nothing.
bool matchSpace(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
Compensate for spaces shortened by demodulator hardware.
void sendLG2SpecialRepeat()
Static function for sending special repeat frame.
bool decodeLGMSB(decode_results *aResults)
#define IRDATA_FLAGS_PARITY_FAILED
The current (autorepeat) frame violated parity check.
uint8_t flags
IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above.
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
uint32_t computeLGRawDataAndChecksum(uint8_t aAddress, uint16_t aCommand)
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
bool matchMark(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
Compensate for marks exceeded by demodulator hardware.
IRRawbufType rawbuf[RAW_BUFFER_LENGTH]
raw data / tick counts per mark/space. With 8 bit we can only store up to 12.7 ms....
#define IRDATA_FLAGS_IS_MSB_FIRST
Value is mainly determined by the (known) protocol.
uint32_t lastDecodedCommand
struct PulseDistanceWidthProtocolConstants LGProtocolConstants
static void space(uint16_t aSpaceMicros)
Sends an IR space for the specified number of microseconds.
struct PulseDistanceWidthProtocolConstants LG2ProtocolConstants
IRRawlenType rawlen
counter of entries in rawbuf of last received frame.
void sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits)
Sends PulseDistance from data contained in parameter using ProtocolConstants structure for timing etc...
uint32_t lastDecodedAddress
#define IR_DEBUG_PRINTLN(...)
If DEBUG, print the arguments as a line, otherwise do nothing.
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
void sendLG(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
LG uses the NEC repeat.
void enableIROut(uint_fast8_t aFrequencyKHz)
Enables IR output.
void sendLG2(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
LG2 uses a special repeat.
void sendNECSpecialRepeat()
Static function variant of IRsend::sendNECRepeat For use in ProtocolConstants.