ESPHome  2022.9.2
dish_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 DishData {
9  uint8_t address;
10  uint8_t command;
11 
12  bool operator==(const DishData &rhs) const { return address == rhs.address && command == rhs.command; }
13 };
14 
15 class DishProtocol : public RemoteProtocol<DishData> {
16  public:
17  void encode(RemoteTransmitData *dst, const DishData &data) override;
18  optional<DishData> decode(RemoteReceiveData src) override;
19  void dump(const DishData &data) override;
20 };
21 
23 
24 template<typename... Ts> class DishAction : public RemoteTransmitterActionBase<Ts...> {
25  public:
26  TEMPLATABLE_VALUE(uint8_t, address)
27  TEMPLATABLE_VALUE(uint8_t, command)
28 
29  void encode(RemoteTransmitData *dst, Ts... x) override {
30  DishData data{};
31  data.address = this->address_.value(x...);
32  data.command = this->command_.value(x...);
33  DishProtocol().encode(dst, data);
34  }
35 };
36 
37 } // namespace remote_base
38 } // namespace esphome
bool operator==(const DishData &rhs) const
Definition: dish_protocol.h:12
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:25
Definition: a4988.cpp:4
void encode(RemoteTransmitData *dst, const DishData &data) override