5 namespace remote_base {
7 static const char *
const TAG =
"remote.coolix";
9 static const int32_t TICK_US = 560;
10 static const int32_t HEADER_MARK_US = 8 * TICK_US;
11 static const int32_t HEADER_SPACE_US = 8 * TICK_US;
12 static const int32_t BIT_MARK_US = 1 * TICK_US;
13 static const int32_t BIT_ONE_SPACE_US = 3 * TICK_US;
14 static const int32_t BIT_ZERO_SPACE_US = 1 * TICK_US;
15 static const int32_t FOOTER_MARK_US = 1 * TICK_US;
16 static const int32_t FOOTER_SPACE_US = 10 * TICK_US;
28 dst->
item(HEADER_MARK_US, HEADER_SPACE_US);
31 for (
unsigned shift = 16;; shift -= 8) {
33 const uint8_t byte = src >> shift;
35 for (uint8_t mask = 1 << 7; mask; mask >>= 1)
36 dst->
item(BIT_MARK_US, (byte & mask) ? BIT_ONE_SPACE_US : BIT_ZERO_SPACE_US);
38 for (uint8_t mask = 1 << 7; mask; mask >>= 1)
39 dst->
item(BIT_MARK_US, (byte & mask) ? BIT_ZERO_SPACE_US : BIT_ONE_SPACE_US);
43 dst->
mark(FOOTER_MARK_US);
52 encode_frame(dst, data.
first);
54 dst->
space(FOOTER_SPACE_US);
55 encode_frame(dst, data.
second);
61 if (!src.
expect_item(HEADER_MARK_US, HEADER_SPACE_US))
65 for (
unsigned n = 3;; data <<= 8) {
67 for (uint32_t mask = 1 << 7; mask; mask >>= 1) {
77 for (uint32_t mask = 1 << 7; mask; mask >>= 1) {
78 if (!src.
expect_item(BIT_MARK_US, (data & mask) ? BIT_ZERO_SPACE_US : BIT_ONE_SPACE_US))
94 const auto size = data.
size();
95 if ((size != 200 && size != 100) || !decode_frame(data, result.
first))
97 if (size == 100 || !data.
expect_space(FOOTER_SPACE_US) || !decode_frame(data, result.
second))
104 ESP_LOGI(TAG,
"Received Coolix: 0x%06" PRIX32, data.
first);
106 ESP_LOGI(TAG,
"Received unstrict Coolix: [0x%06" PRIX32
", 0x%06" PRIX32
"]", data.
first, data.
second);
108 ESP_LOGI(TAG,
"Received unstrict Coolix: [0x%06" PRIX32
"]", data.
first);
optional< CoolixData > decode(RemoteReceiveData data) override
void set_carrier_frequency(uint32_t carrier_frequency)
void item(uint32_t mark, uint32_t space)
bool operator==(const CoolixData &other) const
bool expect_space(uint32_t length)
bool expect_mark(uint32_t length)
void encode(RemoteTransmitData *dst, const CoolixData &data) override
void mark(uint32_t length)
void dump(const CoolixData &data) override
void space(uint32_t length)
Implementation of SPI Controller mode.
void reserve(uint32_t len)
bool expect_item(uint32_t mark, uint32_t space)