6static const char *
const RC6_TAG =
"remote.rc6";
8static constexpr uint16_t RC6_FREQ = 36000;
9static constexpr uint16_t RC6_UNIT = 444;
10static constexpr uint16_t RC6_HEADER_MARK = (6 * RC6_UNIT);
11static constexpr uint16_t RC6_HEADER_SPACE = (2 * RC6_UNIT);
12static constexpr uint16_t RC6_MODE_MASK = 0x07;
19 dst->
item(RC6_HEADER_MARK, RC6_HEADER_SPACE);
24 uint8_t header{
static_cast<uint8_t
>((1 << 3) | data.mode)};
26 for (uint8_t mask = 0x8; mask; mask >>= 1) {
33 next = next + RC6_UNIT;
43 next = next - RC6_UNIT;
57 next = next + RC6_UNIT * 2;
67 next = next - RC6_UNIT * 2;
74 uint16_t
raw{
static_cast<uint16_t
>((data.address << 8) | data.command)};
76 for (uint16_t mask = 0x8000; mask; mask >>= 1) {
83 next = next + RC6_UNIT;
93 next = next - RC6_UNIT;
116 if (!src.
expect_item(RC6_HEADER_MARK, RC6_HEADER_SPACE)) {
127 bit = src.
peek() > 0;
128 header = header + (bit << (3 - offset++));
133 }
else if (offset == 4) {
140 data.mode = header & RC6_MODE_MASK;
142 if (data.mode != 0) {
147 data.toggle = src.
peek() > 0;
155 while (offset < 16) {
156 bit = src.
peek() > 0;
157 buffer = buffer + (bit << (15 - offset++));
169 data.address = (0xFF00 & buffer) >> 8;
170 data.command = (0x00FF & buffer);
175 ESP_LOGI(RC6_TAG,
"Received RC6: mode=0x%X, address=0x%02X, command=0x%02X, toggle=0x%X", data.mode, data.address,
176 data.command, data.toggle);
void encode(RemoteTransmitData *dst, const RC6Data &data) override
void dump(const RC6Data &data) override
optional< RC6Data > decode(RemoteReceiveData src) override
bool expect_item(uint32_t mark, uint32_t space)
bool peek_space(uint32_t length, uint32_t offset=0) const
int32_t peek(uint32_t offset=0) const
void advance(uint32_t amount=1)
bool peek_mark(uint32_t length, uint32_t offset=0) const
void space(uint32_t length)
void set_carrier_frequency(uint32_t carrier_frequency)
void mark(uint32_t length)
void item(uint32_t mark, uint32_t space)
void reserve(uint32_t len)