ESPHome  2022.9.2
sony_protocol.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "remote_base.h"
5 
6 namespace esphome {
7 namespace remote_base {
8 
9 struct SonyData {
10  uint32_t data;
11  uint8_t nbits;
12 
13  bool operator==(const SonyData &rhs) const { return data == rhs.data && nbits == rhs.nbits; }
14 };
15 
16 class SonyProtocol : public RemoteProtocol<SonyData> {
17  public:
18  void encode(RemoteTransmitData *dst, const SonyData &data) override;
19  optional<SonyData> decode(RemoteReceiveData src) override;
20  void dump(const SonyData &data) override;
21 };
22 
24 
25 template<typename... Ts> class SonyAction : public RemoteTransmitterActionBase<Ts...> {
26  public:
27  TEMPLATABLE_VALUE(uint32_t, data)
28  TEMPLATABLE_VALUE(uint8_t, nbits)
29 
30  void encode(RemoteTransmitData *dst, Ts... x) override {
31  SonyData data{};
32  data.data = this->data_.value(x...);
33  data.nbits = this->nbits_.value(x...);
34  SonyProtocol().encode(dst, data);
35  }
36 };
37 
38 } // namespace remote_base
39 } // namespace esphome
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:25
void encode(RemoteTransmitData *dst, const SonyData &data) override
Definition: a4988.cpp:4
bool operator==(const SonyData &rhs) const
Definition: sony_protocol.h:13