ESPHome  2024.6.1
rc6_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 RC6Data {
9  uint8_t mode : 3;
10  uint8_t toggle : 1;
11  uint8_t address;
12  uint8_t command;
13 
14  bool operator==(const RC6Data &rhs) const { return address == rhs.address && command == rhs.command; }
15 };
16 
17 class RC6Protocol : public RemoteProtocol<RC6Data> {
18  public:
19  void encode(RemoteTransmitData *dst, const RC6Data &data) override;
20  optional<RC6Data> decode(RemoteReceiveData src) override;
21  void dump(const RC6Data &data) override;
22 };
23 
25 
26 template<typename... Ts> class RC6Action : public RemoteTransmitterActionBase<Ts...> {
27  public:
28  TEMPLATABLE_VALUE(uint8_t, address)
29  TEMPLATABLE_VALUE(uint8_t, command)
30 
31  void encode(RemoteTransmitData *dst, Ts... x) {
32  RC6Data data{};
33  data.mode = 0;
34  data.toggle = this->toggle_;
35  data.address = this->address_.value(x...);
36  data.command = this->command_.value(x...);
37  RC6Protocol().encode(dst, data);
38  this->toggle_ = !this->toggle_;
39  }
40 
41  protected:
42  uint8_t toggle_{0};
43 };
44 
45 } // namespace remote_base
46 } // 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 RC6Data &data) override
bool operator==(const RC6Data &rhs) const
Definition: rc6_protocol.h:14
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7