ESPHome 2025.5.0
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 {
12namespace remote_base {
13
15 uint16_t magnitude;
16 uint32_t wand_id;
17
18 bool operator==(const MagiQuestData &rhs) const {
19 // Treat 0xffff as a special, wildcard magnitude
20 // In testing, the wand never produces this value, and this allows us to match
21 // on just the wand_id if wanted.
22 if (rhs.wand_id != this->wand_id) {
23 return false;
24 }
25 return (this->wand_id == 0xffff || rhs.wand_id == 0xffff || this->wand_id == rhs.wand_id);
26 }
27};
28
29class MagiQuestProtocol : public RemoteProtocol<MagiQuestData> {
30 public:
31 void encode(RemoteTransmitData *dst, const MagiQuestData &data) override;
33 void dump(const MagiQuestData &data) override;
34};
35
36DECLARE_REMOTE_PROTOCOL(MagiQuest)
37
38template<typename... Ts> class MagiQuestAction : public RemoteTransmitterActionBase<Ts...> {
39 public:
40 TEMPLATABLE_VALUE(uint16_t, magnitude)
41 TEMPLATABLE_VALUE(uint32_t, wand_id)
42
43 void encode(RemoteTransmitData *dst, Ts... x) override {
44 MagiQuestData data{};
45 data.magnitude = this->magnitude_.value(x...);
46 data.wand_id = this->wand_id_.value(x...);
47 MagiQuestProtocol().encode(dst, data);
48 }
49};
50
51} // namespace remote_base
52} // namespace esphome
void dump(const MagiQuestData &data) override
void encode(RemoteTransmitData *dst, const MagiQuestData &data) override
optional< MagiQuestData > decode(RemoteReceiveData src) override
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
bool operator==(const MagiQuestData &rhs) const
uint16_t x
Definition tt21100.cpp:5