ESPHome  2024.4.1
nec_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 NECData {
9  uint16_t address;
10  uint16_t command;
11  uint16_t command_repeats;
12 
13  bool operator==(const NECData &rhs) const { return address == rhs.address && command == rhs.command; }
14 };
15 
16 class NECProtocol : public RemoteProtocol<NECData> {
17  public:
18  void encode(RemoteTransmitData *dst, const NECData &data) override;
19  optional<NECData> decode(RemoteReceiveData src) override;
20  void dump(const NECData &data) override;
21 };
22 
24 
25 template<typename... Ts> class NECAction : public RemoteTransmitterActionBase<Ts...> {
26  public:
27  TEMPLATABLE_VALUE(uint16_t, address)
28  TEMPLATABLE_VALUE(uint16_t, command)
29  TEMPLATABLE_VALUE(uint16_t, command_repeats)
30 
31  void encode(RemoteTransmitData *dst, Ts... x) override {
32  NECData data{};
33  data.address = this->address_.value(x...);
34  data.command = this->command_.value(x...);
35  data.command_repeats = this->command_repeats_.value(x...);
36  NECProtocol().encode(dst, data);
37  }
38 };
39 
40 } // namespace remote_base
41 } // namespace esphome
bool operator==(const NECData &rhs) const
Definition: nec_protocol.h:13
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:27
uint16_t x
Definition: tt21100.cpp:17
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
void encode(RemoteTransmitData *dst, const NECData &data) override