Go to the documentation of this file.
   81 #define LEGO_CHANNEL_BITS       4 
   82 #define LEGO_MODE_BITS          4 
   83 #define LEGO_COMMAND_BITS       4 
   84 #define LEGO_PARITY_BITS        4 
   86 #define LEGO_BITS               (LEGO_CHANNEL_BITS + LEGO_MODE_BITS + LEGO_COMMAND_BITS + LEGO_PARITY_BITS) 
   88 #define LEGO_HEADER_MARK        158    //  6 cycles 
   89 #define LEGO_HEADER_SPACE       1026   // 39 cycles 
   91 #define LEGO_BIT_MARK           158    //  6 cycles 
   92 #define LEGO_ONE_SPACE          553    // 21 cycles 
   93 #define LEGO_ZERO_SPACE         263    // 10 cycles 
   94 #define LEGO_ONE_THRESHOLD      408    // 15.5 cycles - not used, just for info 
   96 #define LEGO_AVERAGE_DURATION   11000 // LEGO_HEADER_MARK + LEGO_HEADER_SPACE  + 16 * 600 + 158 
   98 #define LEGO_AUTO_REPEAT_PERIOD_MIN 110000 // Every frame is auto repeated 5 times. 
   99 #define LEGO_AUTO_REPEAT_PERIOD_MAX 230000 // space for channel 3 
  101 #define LEGO_MODE_EXTENDED  0 
  102 #define LEGO_MODE_COMBO     1 
  103 #define LEGO_MODE_SINGLE    0x4 // here the 2 LSB have meanings like Output A / Output B 
  121     uint8_t tParity = 0xF ^ aChannel ^ aMode ^ 
aCommand;
 
  130 #if defined(LOCAL_DEBUG) 
  131     Serial.print(F(
"sendLego aRawData=0x"));
 
  132     Serial.println(aRawData, HEX);
 
  137     uint_fast8_t tNumberOfRepeats = 0;
 
  139         tNumberOfRepeats = 4;
 
  186     uint8_t tParityReceived = tDecodedValue & 0xF;
 
  190     uint8_t tParityComputed = 0xF ^ tToggleEscapeChannel ^ tMode ^ tData;
 
  193     if (tParityReceived != tParityComputed) {
 
  194 #if defined(LOCAL_DEBUG) 
  195         Serial.print(F(
"LEGO: "));
 
  196         Serial.print(F(
"Parity is not correct. expected=0x"));
 
  197         Serial.print(tParityComputed, HEX);
 
  198         Serial.print(F(
" received=0x"));
 
  199         Serial.print(tParityReceived, HEX);
 
  200         Serial.print(F(
", raw=0x"));
 
  201         Serial.print(tDecodedValue, HEX);
 
  202         Serial.print(F(
", 3 nibbles are 0x"));
 
  203         Serial.print(tToggleEscapeChannel, HEX);
 
  204         Serial.print(F(
", 0x"));
 
  205         Serial.print(tMode, HEX);
 
  206         Serial.print(F(
", 0x"));
 
  207         Serial.println(tData, HEX);
 
  236 #if defined(LOCAL_DEBUG) 
  239 #endif // _IR_LEGO_HPP 
  
 
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
#define MICROS_PER_TICK
microseconds per clock interrupt tick
void decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
#define LEGO_COMMAND_BITS
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
#define MICROS_IN_ONE_MILLI
#define PROTOCOL_IS_PULSE_DISTANCE
void sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats)
Sends PulseDistance frames and repeats.
#define IRDATA_FLAGS_IS_AUTO_REPEAT
The current repeat frame is a repeat, that is always sent after a regular frame and cannot be avoided...
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.
#define IRDATA_FLAGS_PARITY_FAILED
The current (autorepeat) frame violated parity check.
bool decodeLegoPowerFunctions()
IRRawlenType rawlen
counter of entries in rawbuf
uint8_t flags
IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above.
#define PROTOCOL_IS_LSB_FIRST
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
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.
#define LEGO_HEADER_SPACE
IRRawlenType rawlen
Counter of entries in rawbuf of last received frame.
struct PulseDistanceWidthProtocolConstants LegoProtocolConstants
#define LEGO_AUTO_REPEAT_PERIOD_MIN
#define LEGO_AUTO_REPEAT_PERIOD_MAX
#define IR_DEBUG_PRINTLN(...)
If DEBUG, print the arguments as a line, otherwise do nothing.
unsigned int RepeatPeriodMillis
void sendLegoPowerFunctions(uint8_t aChannel, uint8_t tCommand, uint8_t aMode, bool aDoSend5Times=true)
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
uint16_t initialGapTicks
Contains the initial gap (pre 4.4: the value in rawbuf[0]) of the last received frame.