ESPHome  2025.2.0
toto_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 TotoData {
9  uint8_t rc_code_1 : 4;
10  uint8_t rc_code_2 : 4;
11  uint8_t command;
12 
13  bool operator==(const TotoData &rhs) const {
14  return (rc_code_1 == rhs.rc_code_1) && (rc_code_2 == rhs.rc_code_2) && (command == rhs.command);
15  }
16 };
17 
18 class TotoProtocol : public RemoteProtocol<TotoData> {
19  public:
20  void encode(RemoteTransmitData *dst, const TotoData &data) override;
21  optional<TotoData> decode(RemoteReceiveData src) override;
22  void dump(const TotoData &data) override;
23 };
24 
26 
27 template<typename... Ts> class TotoAction : public RemoteTransmitterActionBase<Ts...> {
28  public:
29  TEMPLATABLE_VALUE(uint8_t, rc_code_1)
30  TEMPLATABLE_VALUE(uint8_t, rc_code_2)
31  TEMPLATABLE_VALUE(uint8_t, command)
32 
33  void encode(RemoteTransmitData *dst, Ts... x) override {
34  TotoData data{};
35  data.rc_code_1 = this->rc_code_1_.value(x...);
36  data.rc_code_2 = this->rc_code_2_.value(x...);
37  data.command = this->command_.value(x...);
38  this->set_send_times(this->send_times_.value_or(x..., 3));
39  this->set_send_wait(this->send_wait_.value_or(x..., 36000));
40  TotoProtocol().encode(dst, data);
41  }
42 };
43 
44 } // namespace remote_base
45 } // namespace esphome
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 TotoData &data) override
bool operator==(const TotoData &rhs) const
Definition: toto_protocol.h:13
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7