ESPHome  2024.11.0
lg_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 LGData {
12  uint32_t data;
13  uint8_t nbits;
14 
15  bool operator==(const LGData &rhs) const { return data == rhs.data && nbits == rhs.nbits; }
16 };
17 
18 class LGProtocol : public RemoteProtocol<LGData> {
19  public:
20  void encode(RemoteTransmitData *dst, const LGData &data) override;
21  optional<LGData> decode(RemoteReceiveData src) override;
22  void dump(const LGData &data) override;
23 };
24 
26 
27 template<typename... Ts> class LGAction : public RemoteTransmitterActionBase<Ts...> {
28  public:
29  TEMPLATABLE_VALUE(uint32_t, data)
30  TEMPLATABLE_VALUE(uint8_t, nbits)
31 
32  void encode(RemoteTransmitData *dst, Ts... x) override {
33  LGData data{};
34  data.data = this->data_.value(x...);
35  data.nbits = this->nbits_.value(x...);
36  LGProtocol().encode(dst, data);
37  }
38 };
39 
40 } // namespace remote_base
41 } // 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 LGData &data) override
Definition: lg_protocol.cpp:15
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool operator==(const LGData &rhs) const
Definition: lg_protocol.h:15