ESPHome  2024.10.2
nexa_protocol.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "remote_base.h"
4 
5 #include <cinttypes>
6 
7 namespace esphome {
8 namespace remote_base {
9 
10 struct NexaData {
11  uint32_t device;
12  uint8_t group;
13  uint8_t state;
14  uint8_t channel;
15  uint8_t level;
16  bool operator==(const NexaData &rhs) const {
17  return device == rhs.device && group == rhs.group && state == rhs.state && channel == rhs.channel &&
18  level == rhs.level;
19  }
20 };
21 
22 class NexaProtocol : public RemoteProtocol<NexaData> {
23  public:
24  void one(RemoteTransmitData *dst) const;
25  void zero(RemoteTransmitData *dst) const;
26  void sync(RemoteTransmitData *dst) const;
27 
28  void encode(RemoteTransmitData *dst, const NexaData &data) override;
29  optional<NexaData> decode(RemoteReceiveData src) override;
30  void dump(const NexaData &data) override;
31 };
32 
34 
35 template<typename... Ts> class NexaAction : public RemoteTransmitterActionBase<Ts...> {
36  public:
37  TEMPLATABLE_VALUE(uint32_t, device)
38  TEMPLATABLE_VALUE(uint8_t, group)
39  TEMPLATABLE_VALUE(uint8_t, state)
40  TEMPLATABLE_VALUE(uint8_t, channel)
41  TEMPLATABLE_VALUE(uint8_t, level)
42  void encode(RemoteTransmitData *dst, Ts... x) override {
43  NexaData data{};
44  data.device = this->device_.value(x...);
45  data.group = this->group_.value(x...);
46  data.state = this->state_.value(x...);
47  data.channel = this->channel_.value(x...);
48  data.level = this->level_.value(x...);
49  NexaProtocol().encode(dst, data);
50  }
51 };
52 
53 } // namespace remote_base
54 } // namespace esphome
bool operator==(const NexaData &rhs) const
Definition: nexa_protocol.h:16
uint16_t sync
Definition: sun_gtil2.cpp:14
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 NexaData &data) override
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7