5 namespace remote_base {
7 static const char *
const RC6_TAG =
"remote.rc6";
9 static const uint16_t RC6_FREQ = 36000;
10 static const uint16_t RC6_UNIT = 444;
11 static const uint16_t RC6_HEADER_MARK = (6 * RC6_UNIT);
12 static const uint16_t RC6_HEADER_SPACE = (2 * RC6_UNIT);
13 static const uint16_t RC6_MODE_MASK = 0x07;
20 dst->
item(RC6_HEADER_MARK, RC6_HEADER_SPACE);
25 uint8_t header{
static_cast<uint8_t
>((1 << 3) | data.
mode)};
27 for (uint8_t mask = 0x8; mask; mask >>= 1) {
34 next = next + RC6_UNIT;
44 next = next - RC6_UNIT;
58 next = next + RC6_UNIT * 2;
68 next = next - RC6_UNIT * 2;
77 for (uint16_t mask = 0x8000; mask; mask >>= 1) {
84 next = next + RC6_UNIT;
94 next = next - RC6_UNIT;
117 if (!src.
expect_item(RC6_HEADER_MARK, RC6_HEADER_SPACE)) {
128 bit = src.
peek() > 0;
129 header = header + (bit << (3 - offset++));
134 }
else if (offset == 4) {
141 data.mode = header & RC6_MODE_MASK;
143 if (data.mode != 0) {
148 data.toggle = src.
peek() > 0;
156 while (offset < 16) {
157 bit = src.
peek() > 0;
158 buffer = buffer + (bit << (15 - offset++));
170 data.address = (0xFF00 & buffer) >> 8;
171 data.command = (0x00FF & buffer);
176 ESP_LOGI(RC6_TAG,
"Received RC6: mode=0x%X, address=0x%02X, command=0x%02X, toggle=0x%X", data.
mode, data.
address,
void dump(const RC6Data &data) override
void set_carrier_frequency(uint32_t carrier_frequency)
bool peek_space(uint32_t length, uint32_t offset=0) const
void item(uint32_t mark, uint32_t space)
optional< RC6Data > decode(RemoteReceiveData src) override
bool peek_mark(uint32_t length, uint32_t offset=0) const
void encode(RemoteTransmitData *dst, const RC6Data &data) override
void mark(uint32_t length)
int32_t peek(uint32_t offset=0) const
void space(uint32_t length)
Implementation of SPI Controller mode.
void reserve(uint32_t len)
bool expect_item(uint32_t mark, uint32_t space)
void advance(uint32_t amount=1)