ESPHome  2022.9.2
samsung_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 SamsungData {
10  uint64_t data;
11  uint8_t nbits;
12 
13  bool operator==(const SamsungData &rhs) const { return data == rhs.data && nbits == rhs.nbits; }
14 };
15 
16 class SamsungProtocol : public RemoteProtocol<SamsungData> {
17  public:
18  void encode(RemoteTransmitData *dst, const SamsungData &data) override;
19  optional<SamsungData> decode(RemoteReceiveData src) override;
20  void dump(const SamsungData &data) override;
21 };
22 
24 
25 template<typename... Ts> class SamsungAction : public RemoteTransmitterActionBase<Ts...> {
26  public:
27  TEMPLATABLE_VALUE(uint64_t, data)
28  TEMPLATABLE_VALUE(uint8_t, nbits)
29 
30  void encode(RemoteTransmitData *dst, Ts... x) override {
31  SamsungData data{};
32  data.data = this->data_.value(x...);
33  data.nbits = this->nbits_.value(x...);
34  SamsungProtocol().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
bool operator==(const SamsungData &rhs) const
Definition: a4988.cpp:4
void encode(RemoteTransmitData *dst, const SamsungData &data) override