Go to the documentation of this file.
77 #define LEGO_CHANNEL_BITS 4
78 #define LEGO_MODE_BITS 4
79 #define LEGO_COMMAND_BITS 4
80 #define LEGO_PARITY_BITS 4
82 #define LEGO_BITS (LEGO_CHANNEL_BITS + LEGO_MODE_BITS + LEGO_COMMAND_BITS + LEGO_PARITY_BITS)
84 #define LEGO_HEADER_MARK 158 // 6 cycles
85 #define LEGO_HEADER_SPACE 1026 // 39 cycles
87 #define LEGO_BIT_MARK 158 // 6 cycles
88 #define LEGO_ONE_SPACE 553 // 21 cycles
89 #define LEGO_ZERO_SPACE 263 // 10 cycles
90 #define LEGO_ONE_THRESHOLD 408 // 15.5 cycles - not used, just for info
92 #define LEGO_AVERAGE_DURATION 11000 // LEGO_HEADER_MARK + LEGO_HEADER_SPACE + 16 * 600 + 158
94 #define LEGO_AUTO_REPEAT_PERIOD_MIN 110000 // Every frame is auto repeated 5 times.
95 #define LEGO_AUTO_REPEAT_PERIOD_MAX 230000 // space for channel 3
97 #define LEGO_MODE_EXTENDED 0
98 #define LEGO_MODE_COMBO 1
99 #define LEGO_MODE_SINGLE 0x4 // here the 2 LSB have meanings like Output A / Output B
117 uint8_t tParity = 0xF ^ aChannel ^ aMode ^
aCommand;
131 uint_fast8_t tNumberOfRepeats = 0;
133 tNumberOfRepeats = 4;
177 uint8_t tParityReceived = tDecodedValue & 0xF;
181 uint8_t tParityComputed = 0xF ^ tToggleEscapeChannel ^ tMode ^ tData;
184 if (tParityReceived != tParityComputed) {
185 DEBUG_PRINT(F(
"LEGO: Parity is not correct. expected=0x"));
226 #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, IRDecodedRawDataType 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...
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.
IRDecodedRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send<protocol>Raw functions.
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 DEBUG_PRINTLN(...)
#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
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.