ESPHome 2026.5.1
Loading...
Searching...
No Matches
magiquest_protocol.h
Go to the documentation of this file.
1#pragma once
2
3#include "remote_base.h"
4
5#include <cinttypes>
6
7/* Based on protocol analysis from
8 * https://arduino-irremote.github.io/Arduino-IRremote/ir__MagiQuest_8cpp_source.html
9 */
10
11namespace esphome::remote_base {
12
14 uint16_t magnitude;
16
17 bool operator==(const MagiQuestData &rhs) const {
18 // Treat 0xffff as a special, wildcard magnitude
19 // In testing, the wand never produces this value, and this allows us to match
20 // on just the wand_id if wanted.
21 if (rhs.wand_id != this->wand_id) {
22 return false;
23 }
24 return (this->wand_id == 0xffff || rhs.wand_id == 0xffff || this->wand_id == rhs.wand_id);
25 }
26};
27
28class MagiQuestProtocol : public RemoteProtocol<MagiQuestData> {
29 public:
30 void encode(RemoteTransmitData *dst, const MagiQuestData &data) override;
31 optional<MagiQuestData> decode(RemoteReceiveData src) override;
32 void dump(const MagiQuestData &data) override;
33};
34
35DECLARE_REMOTE_PROTOCOL(MagiQuest)
36
37template<typename... Ts> class MagiQuestAction : public RemoteTransmitterActionBase<Ts...> {
38 public:
39 TEMPLATABLE_VALUE(uint16_t, magnitude)
40 TEMPLATABLE_VALUE(uint32_t, wand_id)
41
42 void encode(RemoteTransmitData *dst, Ts... x) override {
43 MagiQuestData data{};
44 data.magnitude = this->magnitude_.value(x...);
45 data.wand_id = this->wand_id_.value(x...);
46 MagiQuestProtocol().encode(dst, data);
47 }
48};
49
50} // namespace esphome::remote_base
void dump(const MagiQuestData &data) override
void encode(RemoteTransmitData *dst, const MagiQuestData &data) override
optional< MagiQuestData > decode(RemoteReceiveData src) override
static void uint32_t
bool operator==(const MagiQuestData &rhs) const
uint16_t x
Definition tt21100.cpp:5