Go to the documentation of this file.
   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) {
 
  202 #if defined(LOCAL_DEBUG) 
  203             Serial.print(F(
"LG: "));
 
  204             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"));
 
  245     uint8_t tChecksum = 0;
 
  247     for (
int i = 0; i < 4; ++i) {
 
  248         tChecksum += tTempForChecksum & 0xF; 
 
  249         tTempForChecksum >>= 4; 
 
  253 #if defined(LOCAL_DEBUG) 
  254         Serial.print(F(
"LG: "));
 
  255         Serial.print(F(
"4 bit checksum is not correct. expected=0x"));
 
  256         Serial.print(tChecksum, HEX);
 
  257         Serial.print(F(
" received=0x"));
 
  259         Serial.print(F(
" data=0x"));
 
  285     unsigned int offset = 1; 
 
  307 #if defined(LOCAL_DEBUG) 
  308         Serial.println(F(
"Stop bit mark length is wrong"));
 
  325 #if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)) 
  339 #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!!!
void decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
#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
void decodePulseDistanceWidthData_P(PulseDistanceWidthProtocolConstants const *aProtocolConstantsPGM, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
#define MICROS_IN_ONE_MILLI
#define PROTOCOL_IS_PULSE_DISTANCE
void sendPulseDistanceWidth_P(PulseDistanceWidthProtocolConstants const *aProtocolConstantsPGM, IRRawDataType aData, uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats)
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.
decode_type_t decode_type
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send<protocol>Raw 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.
uint32_t computeLGRawDataAndChecksum(uint8_t aAddress, uint16_t aCommand)
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
struct PulseDistanceWidthProtocolConstants const LGProtocolConstants PROGMEM
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....
uint16_t lastDecodedCommand
#define IRDATA_FLAGS_IS_MSB_FIRST
Value is mainly determined by the (known) protocol.
static void space(uint16_t aSpaceMicros)
Sends an IR space for the specified number of microseconds.
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...
#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.
uint16_t lastDecodedAddress
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.