ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
rc6_protocol.h
Go to the documentation of this file.
1#pragma once
2
3#include "remote_base.h"
4
5namespace esphome::remote_base {
6
7struct RC6Data {
8 uint8_t mode : 3;
9 uint8_t toggle : 1;
10 uint8_t address;
11 uint8_t command;
12
13 bool operator==(const RC6Data &rhs) const { return address == rhs.address && command == rhs.command; }
14};
15
16class RC6Protocol : public RemoteProtocol<RC6Data> {
17 public:
18 void encode(RemoteTransmitData *dst, const RC6Data &data) override;
19 optional<RC6Data> decode(RemoteReceiveData src) override;
20 void dump(const RC6Data &data) override;
21};
22
23DECLARE_REMOTE_PROTOCOL(RC6)
24
25template<typename... Ts> class RC6Action : public RemoteTransmitterActionBase<Ts...> {
26 public:
27 TEMPLATABLE_VALUE(uint8_t, address)
28 TEMPLATABLE_VALUE(uint8_t, command)
29
30 void encode(RemoteTransmitData *dst, Ts... x) {
31 RC6Data data{};
32 data.mode = 0;
33 data.toggle = this->toggle_;
34 data.address = this->address_.value(x...);
35 data.command = this->command_.value(x...);
36 RC6Protocol().encode(dst, data);
37 this->toggle_ = !this->toggle_;
38 }
39
40 protected:
41 uint8_t toggle_{0};
42};
43
44} // namespace esphome::remote_base
uint8_t address
Definition bl0906.h:4
void encode(RemoteTransmitData *dst, const RC6Data &data) override
void dump(const RC6Data &data) override
optional< RC6Data > decode(RemoteReceiveData src) override
bool operator==(const RC6Data &rhs) const
uint16_t x
Definition tt21100.cpp:5