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.
136 #if !defined(DISABLE_CODE_FOR_RECEIVER)
150 #if !defined(DISABLE_CODE_FOR_RECEIVER)
161 uint8_t tChecksum = 0;
162 uint16_t tTempForChecksum =
aCommand;
163 for (
int i = 0; i < 4; ++i) {
164 tChecksum += tTempForChecksum & 0xF;
165 tTempForChecksum >>= 4;
167 return (tRawData | (tChecksum & 0xF));
173 void IRsend::sendLG(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
180 void IRsend::sendLG2(uint8_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
206 #if defined(LOCAL_DEBUG)
207 Serial.print(F(
"LG: "));
208 Serial.println(F(
"Header mark is wrong"));
227 #if defined(LOCAL_DEBUG)
228 Serial.print(F(
"LG: "));
229 Serial.print(F(
"Repeat header space is wrong"));
236 #if defined(LOCAL_DEBUG)
237 Serial.print(F(
"LG: "));
238 Serial.println(F(
"Header space length is wrong"));
244 #if defined(LOCAL_DEBUG)
245 Serial.print(F(
"LG: "));
246 Serial.println(F(
"Decode failed"));
259 uint8_t tChecksum = 0;
261 for (
int i = 0; i < 4; ++i) {
262 tChecksum += tTempForChecksum & 0xF;
263 tTempForChecksum >>= 4;
267 #if defined(LOCAL_DEBUG)
268 Serial.print(F(
"LG: "));
269 Serial.print(F(
"4 bit checksum is not correct. expected=0x"));
270 Serial.print(tChecksum, HEX);
271 Serial.print(F(
" received=0x"));
273 Serial.print(F(
" data=0x"));
299 unsigned int offset = 1;
322 #if defined(LOCAL_DEBUG)
323 Serial.println(F(
"Stop bit mark length is wrong"));
340 #if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__))
342 "The function sendLG(data, nbits) is deprecated and may not work as expected! Use sendLGRaw(data, NumberOfRepeats) or better sendLG(Address, Command, NumberOfRepeats)."));
352 #if !defined(DISABLE_CODE_FOR_RECEIVER)
358 #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 uint8_t int_fast8_t aNumberOfRepeats
#define MICROS_IN_ONE_MILLI
void mark(unsigned int aMarkMicros)
Sends an IR mark for the specified number of microseconds.
#define IRDATA_FLAGS_IS_REPEAT
decode_type_t
An enum consisting of all supported formats.
void restartAfterSend()
Restarts receiver after send.
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.
void sendLG2SpecialRepeat()
Static function for sending special repeat frame.
uint_fast8_t rawlen
counter of entries in rawbuf
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
bool decodeLGMSB(decode_results *aResults)
#define IRDATA_FLAGS_PARITY_FAILED
the current (autorepeat) frame violated parity check
bool matchSpace(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
Compensate for spaces shortened by demodulator hardware.
uint8_t flags
See IRDATA_FLAGS_* definitions above.
unsigned int rawbuf[RAW_BUFFER_LENGTH]
raw data / tick counts per mark/space, first entry is the length of the gap between previous and curr...
uint32_t computeLGRawDataAndChecksum(uint8_t aAddress, uint16_t aCommand)
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
#define IRDATA_FLAGS_IS_MSB_FIRST
Value is mainly determined by the (known) protocol.
uint32_t lastDecodedCommand
static void space(unsigned int aSpaceMicros)
Sends an IR space for the specified number of microseconds.
struct PulseDistanceWidthProtocolConstants LGProtocolConstants
struct PulseDistanceWidthProtocolConstants LG2ProtocolConstants
void sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits)
Sends PulseDistance data The output always ends with a space Each additional call costs 16 bytes prog...
uint32_t lastDecodedAddress
#define IR_DEBUG_PRINTLN(...)
If DEBUG, print the arguments as a line, otherwise do nothing.
bool matchMark(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
Compensate for marks exceeded by demodulator hardware.
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.
IRrecv IrReceiver
The receiver instance.
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 for sending special repeat frame.