Go to the documentation of this file.
63 #define LEGO_CHANNEL_BITS 4
64 #define LEGO_MODE_BITS 4
65 #define LEGO_COMMAND_BITS 4
66 #define LEGO_PARITY_BITS 4
68 #define LEGO_BITS (LEGO_CHANNEL_BITS + LEGO_MODE_BITS + LEGO_COMMAND_BITS + LEGO_PARITY_BITS)
70 #define LEGO_HEADER_MARK 158 // 6 cycles
71 #define LEGO_HEADER_SPACE 1026 // 39 cycles
73 #define LEGO_BIT_MARK 158 // 6 cycles
74 #define LEGO_ONE_SPACE 553 // 21 cycles
75 #define LEGO_ZERO_SPACE 263 // 10 cycles
77 #define LEGO_AVERAGE_DURATION 11000 // LEGO_HEADER_MARK + LEGO_HEADER_SPACE + 16 * 600 + 158
79 #define LEGO_AUTO_REPEAT_PERIOD_MIN 110000 // Every frame is auto repeated 5 times.
80 #define LEGO_AUTO_REPEAT_PERIOD_MAX 230000 // space for channel 3
82 #define LEGO_MODE_EXTENDED 0
83 #define LEGO_MODE_COMBO 1
84 #define LEGO_MODE_SINGLE 0x4 // here the 2 LSB have meanings like Output A / Output B
101 uint8_t tParity = 0xF ^ aChannel ^ aMode ^
aCommand;
115 uint_fast8_t tNumberOfRepeats = 0;
117 tNumberOfRepeats = 4;
162 uint8_t tParityReceived = tDecodedValue & 0xF;
166 uint8_t tParityComputed = 0xF ^ tToggleEscapeChannel ^ tMode ^ tData;
169 if (tParityReceived != tParityComputed) {
210 #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
#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
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...
#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 functions.
#define IR_DEBUG_PRINT(...)
If DEBUG, print the arguments, otherwise do nothing.
#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
bool checkHeader(PulseDistanceWidthProtocolConstants *aProtocolConstants)
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
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.
#define LEGO_HEADER_SPACE
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.