ESPHome  2023.9.3
drayton_protocol.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "remote_base.h"
5 
6 namespace esphome {
7 namespace remote_base {
8 
9 struct DraytonData {
10  uint16_t address;
11  uint8_t channel;
12  uint8_t command;
13 
14  bool operator==(const DraytonData &rhs) const {
15  return address == rhs.address && channel == rhs.channel && command == rhs.command;
16  }
17 };
18 
19 class DraytonProtocol : public RemoteProtocol<DraytonData> {
20  public:
21  void encode(RemoteTransmitData *dst, const DraytonData &data) override;
22  optional<DraytonData> decode(RemoteReceiveData src) override;
23  void dump(const DraytonData &data) override;
24 };
25 
27 
28 template<typename... Ts> class DraytonAction : public RemoteTransmitterActionBase<Ts...> {
29  public:
30  TEMPLATABLE_VALUE(uint16_t, address)
31  TEMPLATABLE_VALUE(uint8_t, channel)
32  TEMPLATABLE_VALUE(uint8_t, command)
33 
34  void encode(RemoteTransmitData *dst, Ts... x) override {
35  DraytonData data{};
36  data.address = this->address_.value(x...);
37  data.channel = this->channel_.value(x...);
38  data.command = this->command_.value(x...);
39  DraytonProtocol().encode(dst, data);
40  }
41 };
42 
43 } // namespace remote_base
44 } // namespace esphome
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:27
void encode(RemoteTransmitData *dst, const DraytonData &data) override
uint16_t x
Definition: tt21100.cpp:17
bool operator==(const DraytonData &rhs) const
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7