ESPHome  2024.2.1
sony_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 SonyData {
12  uint32_t data;
13  uint8_t nbits;
14 
15  bool operator==(const SonyData &rhs) const { return data == rhs.data && nbits == rhs.nbits; }
16 };
17 
18 class SonyProtocol : public RemoteProtocol<SonyData> {
19  public:
20  void encode(RemoteTransmitData *dst, const SonyData &data) override;
21  optional<SonyData> decode(RemoteReceiveData src) override;
22  void dump(const SonyData &data) override;
23 };
24 
26 
27 template<typename... Ts> class SonyAction : 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  SonyData data{};
34  data.data = this->data_.value(x...);
35  data.nbits = this->nbits_.value(x...);
36  SonyProtocol().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 SonyData &data) override
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
bool operator==(const SonyData &rhs) const
Definition: sony_protocol.h:15