ESPHome  2024.11.0
canalsat_protocol.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "remote_base.h"
4 
5 namespace esphome {
6 namespace remote_base {
7 
8 struct CanalSatData {
9  uint8_t device : 7;
10  uint8_t address : 6;
11  uint8_t repeat : 1;
12  uint8_t command : 7;
13 
14  bool operator==(const CanalSatData &rhs) const {
15  return device == rhs.device && address == rhs.address && command == rhs.command;
16  }
17 };
18 
19 struct CanalSatLDData : public CanalSatData {};
20 
21 class CanalSatBaseProtocol : public RemoteProtocol<CanalSatData> {
22  public:
23  void encode(RemoteTransmitData *dst, const CanalSatData &data) override;
24  optional<CanalSatData> decode(RemoteReceiveData src) override;
25  void dump(const CanalSatData &data) override;
26 
27  protected:
28  uint16_t frequency_;
29  uint16_t unit_;
30  const char *tag_;
31 };
32 
34  public:
36 };
37 
39  public:
41 };
42 
44 
45 template<typename... Ts> class CanalSatAction : public RemoteTransmitterActionBase<Ts...> {
46  public:
47  TEMPLATABLE_VALUE(uint8_t, device)
48  TEMPLATABLE_VALUE(uint8_t, address)
49  TEMPLATABLE_VALUE(uint8_t, command)
50 
51  void encode(RemoteTransmitData *dst, Ts... x) {
52  CanalSatData data{};
53  data.device = this->device_.value(x...);
54  data.address = this->address_.value(x...);
55  data.command = this->command_.value(x...);
56  CanalSatProtocol().encode(dst, data);
57  }
58 };
59 
61 
62 template<typename... Ts> class CanalSatLDAction : public RemoteTransmitterActionBase<Ts...> {
63  public:
64  TEMPLATABLE_VALUE(uint8_t, device)
65  TEMPLATABLE_VALUE(uint8_t, address)
66  TEMPLATABLE_VALUE(uint8_t, command)
67 
68  void encode(RemoteTransmitData *dst, Ts... x) {
69  CanalSatData data{};
70  data.device = this->device_.value(x...);
71  data.address = this->address_.value(x...);
72  data.command = this->command_.value(x...);
73  CanalSatLDProtocol().encode(dst, data);
74  }
75 };
76 
77 } // namespace remote_base
78 } // namespace esphome
bool operator==(const CanalSatData &rhs) const
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:27
uint16_t x
Definition: tt21100.cpp:17
void encode(RemoteTransmitData *dst, const CanalSatData &data) override
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7