Go to the documentation of this file.
38 #ifndef _IR_MAGIQUEST_HPP
39 #define _IR_MAGIQUEST_HPP
85 #define MAGIQUEST_CHECKSUM_BITS 8 // magiquest_t.cmd.checksum
86 #define MAGIQUEST_MAGNITUDE_BITS 9 // magiquest_t.cmd.magnitude
87 #define MAGIQUEST_WAND_ID_BITS 31 // magiquest_t.cmd.wand_id -> wand-id is handled as 32 bit and always even
88 #define MAGIQUEST_START_BITS 8 // magiquest_t.cmd.StartBits
90 #define MAGIQUEST_PERIOD 1150 // Time for a full MagiQuest "bit" (1100 - 1200 usec)
92 #define MAGIQUEST_DATA_BITS (MAGIQUEST_CHECKSUM_BITS + MAGIQUEST_MAGNITUDE_BITS + MAGIQUEST_WAND_ID_BITS) // 48 Size of the command without the start bits
93 #define MAGIQUEST_BITS (MAGIQUEST_CHECKSUM_BITS + MAGIQUEST_MAGNITUDE_BITS + MAGIQUEST_WAND_ID_BITS + MAGIQUEST_START_BITS) // 56 Size of the command with the start bits
105 #define MAGIQUEST_UNIT (MAGIQUEST_PERIOD / 4) // 287.5
107 #define MAGIQUEST_ONE_MARK (2 * MAGIQUEST_UNIT) // 576
108 #define MAGIQUEST_ONE_SPACE (2 * MAGIQUEST_UNIT) // 576
109 #define MAGIQUEST_ZERO_MARK MAGIQUEST_UNIT // 287.5
110 #define MAGIQUEST_ZERO_SPACE (3 * MAGIQUEST_UNIT) // 864
129 tWandId.
ULong = aWandId << 1;
130 uint8_t tChecksum = (tWandId.
Bytes[0]) + tWandId.
Bytes[1] + tWandId.
Bytes[2] + tWandId.
Bytes[3];
131 tChecksum += aMagnitude + (aMagnitude >> 8);
132 tChecksum = ~tChecksum + 1;
140 #if defined(LOCAL_DEBUG)
142 Serial.print(F(
"MagiQuest checksum=0x"));
143 Serial.println(tChecksum, HEX);
170 #if defined(USE_THRESHOLD_DECODER)
176 #if defined(LOCAL_DEBUG)
177 Serial.print(F(
"MagiQuest: "));
178 Serial.print(F(
"Not 8 leading zero start bits received, RawData=0x"));
188 #if defined(USE_THRESHOLD_DECODER)
195 uint8_t tChecksum = tDecodedRawData.
Bytes[0] + tDecodedRawData.
Bytes[1] + tDecodedRawData.
Bytes[2] + tDecodedRawData.
Bytes[3];
196 #if defined(LOCAL_DEBUG)
197 Serial.print(F(
"31 bit WandId=0x"));
199 Serial.print(F(
" shifted=0x"));
200 Serial.println(tDecodedRawData.
ULong, HEX);
208 #if defined(USE_THRESHOLD_DECODER)
213 #if defined(LOCAL_DEBUG)
214 Serial.print(F(
"Magnitude + checksum=0x"));
220 tChecksum += tDecodedRawData.
UBytes[2] + tDecodedRawData.
UBytes[1] + tDecodedRawData.
UBytes[0];
221 if (tChecksum != 0) {
223 #if defined(LOCAL_DEBUG)
224 Serial.print(F(
"Checksum 0x"));
225 Serial.print(tChecksum, HEX);
226 Serial.println(F(
" is not 0"));
241 #if defined(LOCAL_DEBUG)
244 #endif // _IR_MAGIQUEST_HPP
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
#define SUPPRESS_STOP_BIT
Union to specify parts / manifestations of a 32 bit Long without casts and shifts.
void sendMagiQuest(uint32_t aWandId, uint16_t aMagnitude)
#define PROTOCOL_IS_MSB_FIRST
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
void decodePulseDistanceWidthData_P(PulseDistanceWidthProtocolConstants const *aProtocolConstantsPGM, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
#define MAGIQUEST_ONE_SPACE
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.
#define MAGIQUEST_ZERO_MARK
#define IRDATA_FLAGS_PARITY_FAILED
The current (autorepeat) frame violated parity check.
void sendPulseDistanceWidthData_P(PulseDistanceWidthProtocolConstants const *aProtocolConstantsPGM, IRRawDataType aData, uint_fast8_t aNumberOfBits)
uint8_t flags
IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above.
#define MAGIQUEST_ZERO_SPACE
struct PulseDistanceWidthProtocolConstants const MagiQuestProtocolConstants PROGMEM
#define MAGIQUEST_CHECKSUM_BITS
#define MAGIQUEST_ONE_MARK
#define MAGIQUEST_MAGNITUDE_BITS
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
#define MAGIQUEST_WAND_ID_BITS
#define IRDATA_FLAGS_IS_MSB_FIRST
Value is mainly determined by the (known) protocol.
uint16_t extra
Contains upper 16 bit of Magiquest WandID, Kaseikyo unknown vendor ID and Distance protocol (HeaderMa...
#define PROTOCOL_IS_PULSE_DISTANCE_WIDTH
IRRawlenType rawlen
Counter of entries in rawbuf of last received frame.
#define MAGIQUEST_START_BITS
#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 enableIROut(uint_fast8_t aFrequencyKHz)
Enables IR output.