Go to the documentation of this file.
38 #ifndef _IR_MAGIQUEST_HPP
39 #define _IR_MAGIQUEST_HPP
41 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
86 #define MAGIQUEST_CHECKSUM_BITS 8 // magiquest_t.cmd.checksum
87 #define MAGIQUEST_MAGNITUDE_BITS 9 // magiquest_t.cmd.magnitude
88 #define MAGIQUEST_WAND_ID_BITS 31 // magiquest_t.cmd.wand_id -> wand-id is handled as 32 bit and always even
89 #define MAGIQUEST_START_BITS 8 // magiquest_t.cmd.StartBits
91 #define MAGIQUEST_PERIOD 1150 // Time for a full MagiQuest "bit" (1100 - 1200 usec)
93 #define MAGIQUEST_DATA_BITS (MAGIQUEST_CHECKSUM_BITS + MAGIQUEST_MAGNITUDE_BITS + MAGIQUEST_WAND_ID_BITS) // 48 Size of the command without the start bits
94 #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
104 #define MAGIQUEST_UNIT (MAGIQUEST_PERIOD / 4) // 287.5
106 #define MAGIQUEST_ONE_MARK (2 * MAGIQUEST_UNIT) // 576
107 #define MAGIQUEST_ONE_SPACE (2 * MAGIQUEST_UNIT) // 576
108 #define MAGIQUEST_ZERO_MARK MAGIQUEST_UNIT // 287.5
109 #define MAGIQUEST_ZERO_SPACE (3 * MAGIQUEST_UNIT) // 864
128 tWandId.
ULong = aWandId << 1;
129 uint8_t tChecksum = (tWandId.
Bytes[0]) + tWandId.
Bytes[1] + tWandId.
Bytes[2] + tWandId.
Bytes[3];
130 tChecksum += aMagnitude + (aMagnitude >> 8);
131 tChecksum = ~tChecksum + 1;
139 #if defined(LOCAL_DEBUG)
141 Serial.print(F(
"MagiQuest checksum=0x"));
142 Serial.println(tChecksum, HEX);
169 #if defined(LOCAL_DEBUG)
170 Serial.print(F(
"MagiQuest: "));
171 Serial.println(F(
"Start bit decode failed"));
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(LOCAL_DEBUG)
189 Serial.print(F(
"MagiQuest: "));
190 Serial.println(F(
"ID decode failed"));
195 #if defined(LOCAL_DEBUG)
196 Serial.print(F(
"31 bit WandId=0x"));
201 uint8_t tChecksum = tDecodedRawData.
Bytes[0] + tDecodedRawData.
Bytes[1] + tDecodedRawData.
Bytes[2] + tDecodedRawData.
Bytes[3];
202 #if defined(LOCAL_DEBUG)
203 Serial.print(F(
"31 bit WandId=0x"));
205 Serial.print(F(
" shifted=0x"));
206 Serial.println(tDecodedRawData.
ULong, HEX);
213 #if defined(LOCAL_DEBUG)
214 Serial.print(F(
"MagiQuest: "));
215 Serial.println(F(
"Magnitude + checksum decode failed"));
220 #if defined(LOCAL_DEBUG)
221 Serial.print(F(
"Magnitude + checksum=0x"));
227 tChecksum += tDecodedRawData.
UBytes[2] + tDecodedRawData.
UBytes[1] + tDecodedRawData.
UBytes[0];
228 if (tChecksum != 0) {
230 #if defined(LOCAL_DEBUG)
231 Serial.print(F(
"Checksum 0x"));
232 Serial.print(tChecksum, HEX);
233 Serial.println(F(
" is not 0"));
248 #if defined(LOCAL_DEBUG)
251 #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...
#define MAGIQUEST_ONE_SPACE
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.
struct PulseDistanceWidthProtocolConstants MagiQuestProtocolConstants
#define MAGIQUEST_ZERO_MARK
#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.
#define MAGIQUEST_ZERO_SPACE
#define MAGIQUEST_CHECKSUM_BITS
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
#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...
IRRawlenType rawlen
counter of entries in rawbuf of last received frame.
#define MAGIQUEST_START_BITS
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 enableIROut(uint_fast8_t aFrequencyKHz)
Enables IR output.