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