9 namespace remote_base {
11 static const char *
const TAG =
"remote.magiquest";
13 static const uint32_t MAGIQUEST_UNIT = 288;
14 static const uint32_t MAGIQUEST_ONE_MARK = 2 * MAGIQUEST_UNIT;
15 static const uint32_t MAGIQUEST_ONE_SPACE = 2 * MAGIQUEST_UNIT;
16 static const uint32_t MAGIQUEST_ZERO_MARK = MAGIQUEST_UNIT;
17 static const uint32_t MAGIQUEST_ZERO_SPACE = 3 * MAGIQUEST_UNIT;
24 dst->
item(MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE);
25 dst->
item(MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE);
26 for (uint32_t mask = 1 << 31; mask; mask >>= 1) {
28 dst->
item(MAGIQUEST_ONE_MARK, MAGIQUEST_ONE_SPACE);
30 dst->
item(MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE);
34 for (uint16_t mask = 1 << 15; mask; mask >>= 1) {
36 dst->
item(MAGIQUEST_ONE_MARK, MAGIQUEST_ONE_SPACE);
38 dst->
item(MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE);
42 dst->
mark(MAGIQUEST_UNIT);
50 if (!src.
expect_item(MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE) ||
51 !src.
expect_item(MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE)) {
55 for (uint32_t mask = 1 << 31; mask; mask >>= 1) {
56 if (src.
expect_item(MAGIQUEST_ONE_MARK, MAGIQUEST_ONE_SPACE)) {
58 }
else if (src.
expect_item(MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE)) {
59 data.wand_id &= ~mask;
65 for (uint16_t mask = 1 << 15; mask; mask >>= 1) {
66 if (src.
expect_item(MAGIQUEST_ONE_MARK, MAGIQUEST_ONE_SPACE)) {
67 data.magnitude |= mask;
68 }
else if (src.
expect_item(MAGIQUEST_ZERO_MARK, MAGIQUEST_ZERO_SPACE)) {
69 data.magnitude &= ~mask;
79 ESP_LOGI(TAG,
"Received MagiQuest: wand_id=0x%08" PRIX32
", magnitude=0x%04X", data.
wand_id, data.
magnitude);
void set_carrier_frequency(uint32_t carrier_frequency)
void item(uint32_t mark, uint32_t space)
optional< MagiQuestData > decode(RemoteReceiveData src) override
bool expect_mark(uint32_t length)
void dump(const MagiQuestData &data) override
void mark(uint32_t length)
Implementation of SPI Controller mode.
void reserve(uint32_t len)
bool expect_item(uint32_t mark, uint32_t space)
void encode(RemoteTransmitData *dst, const MagiQuestData &data) override