6 namespace remote_base {
8 static const char *
const TAG =
"remote.toshibaac";
10 static const uint32_t HEADER_HIGH_US = 4500;
11 static const uint32_t HEADER_LOW_US = 4500;
12 static const uint32_t BIT_HIGH_US = 560;
13 static const uint32_t BIT_ONE_LOW_US = 1690;
14 static const uint32_t BIT_ZERO_LOW_US = 560;
15 static const uint32_t FOOTER_HIGH_US = 560;
16 static const uint32_t FOOTER_LOW_US = 4500;
17 static const uint16_t PACKET_SPACE = 5500;
21 dst->
reserve((3 + (48 * 2)) * 3);
23 for (uint8_t repeat = 0; repeat < 2; repeat++) {
24 dst->
item(HEADER_HIGH_US, HEADER_LOW_US);
25 for (uint8_t bit = 48; bit > 0; bit--) {
26 dst->
mark(BIT_HIGH_US);
28 dst->
space(BIT_ONE_LOW_US);
30 dst->
space(BIT_ZERO_LOW_US);
33 dst->
item(FOOTER_HIGH_US, FOOTER_LOW_US);
37 dst->
item(HEADER_HIGH_US, HEADER_LOW_US);
38 for (uint8_t bit = 48; bit > 0; bit--) {
39 dst->
mark(BIT_HIGH_US);
41 dst->
space(BIT_ONE_LOW_US);
43 dst->
space(BIT_ZERO_LOW_US);
46 dst->
item(FOOTER_HIGH_US, FOOTER_LOW_US);
57 if (!src.
expect_item(HEADER_HIGH_US, HEADER_LOW_US))
59 for (uint8_t bit_counter = 0; bit_counter < 48; bit_counter++) {
61 packet = (packet << 1) | 1;
62 }
else if (src.
expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
63 packet = (packet << 1) | 0;
72 if (!src.
expect_item(HEADER_HIGH_US, HEADER_LOW_US))
74 for (uint8_t bit_counter = 0; bit_counter < 48; bit_counter++) {
76 out.rc_code_1 = (out.rc_code_1 << 1) | 1;
77 }
else if (src.
expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
78 out.rc_code_1 = (out.rc_code_1 << 1) | 0;
84 if (packet != out.rc_code_1)
91 if (!src.
expect_item(HEADER_HIGH_US, HEADER_LOW_US))
93 for (uint8_t bit_counter = 0; bit_counter < 48; bit_counter++) {
95 out.rc_code_2 = (out.rc_code_2 << 1) | 1;
96 }
else if (src.
expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) {
97 out.rc_code_2 = (out.rc_code_2 << 1) | 0;
108 ESP_LOGI(TAG,
"Received Toshiba AC: rc_code_1=0x%" PRIX64
", rc_code_2=0x%" PRIX64, data.
rc_code_1, data.
rc_code_2);
110 ESP_LOGI(TAG,
"Received Toshiba AC: rc_code_1=0x%" PRIX64, data.
rc_code_1);
void dump(const ToshibaAcData &data) override
void set_carrier_frequency(uint32_t carrier_frequency)
void item(uint32_t mark, uint32_t space)
optional< ToshibaAcData > decode(RemoteReceiveData src) override
void encode(RemoteTransmitData *dst, const ToshibaAcData &data) override
void mark(uint32_t length)
void space(uint32_t length)
Implementation of SPI Controller mode.
void reserve(uint32_t len)
bool expect_item(uint32_t mark, uint32_t space)