32static constexpr size_t STATE_LENGTH = 27;
33static constexpr size_t SECTION1_LENGTH = 8;
34static constexpr size_t SECTION2_LENGTH = STATE_LENGTH - SECTION1_LENGTH;
35static constexpr uint8_t CHECKSUM_INIT = 0xF4;
43static constexpr uint8_t FAN_SPEED_MIN = 0;
44static constexpr uint8_t FAN_SPEED_LOW = 1;
45static constexpr uint8_t FAN_SPEED_MEDIUM = 2;
46static constexpr uint8_t FAN_SPEED_HIGH = 3;
47static constexpr uint8_t FAN_SPEED_MAX = 4;
48static constexpr uint8_t FAN_SPEED_AUTO = 7;
49static constexpr uint8_t FAN_SPEED_OFFSET = 3;
51static constexpr uint8_t VANE_V_HIGHEST = 0x1;
52static constexpr uint8_t VANE_V_MIDDLE = 0x3;
53static constexpr uint8_t VANE_V_LOWEST = 0x5;
54static constexpr uint8_t VANE_V_AUTO = 0xF;
58static constexpr uint8_t TEMP_MAINTENANCE = 10;
59static constexpr uint8_t TEMP_MIN_RECEIVE = 8;
60static constexpr uint8_t TEMP_MIN = 16;
61static constexpr uint8_t TEMP_MAX = 30;
62static constexpr uint8_t TEMP_FAN_MODE = 27;
74static constexpr ModelBytes MODEL_BYTES[] PROGMEM = {
75 {0x00, 0x06, 0x00, 0x01, 0x06},
76 {0x00, 0x00, 0x00, 0x81, 0x00},
77 {0x02, 0x06, 0x00, 0x81, 0x00},
78 {0x00, 0x06, 0x00, 0x81, 0x00},
79 {0x00, 0x00, 0x10, 0x01, 0x00},
80 {0x08, 0x06, 0x00, 0x89, 0x00},
81 {0x08, 0x00, 0x00, 0x81, 0x00},
95 memset(
state, 0, STATE_LENGTH);
117 state[13] = model.
b13_or | (p.
power ? 0x01 : 0x00) | ((
static_cast<uint8_t
>(p.
mode) & 0x07) << 4);
119 state[14] = (temp & 0x1F) << 1;
131 uint8_t expected[STATE_LENGTH];
133 if (memcmp(
state, expected, 13) != 0)
138 const uint8_t
mode = (
state[13] >> 4) & 0x07;
150 const uint8_t temp = (
state[14] >> 1) & 0x1F;
151 if (temp < TEMP_MIN_RECEIVE || temp > TEMP_MAX)
154 const uint8_t fan =
static_cast<uint8_t
>((
state[16] >> 4) - FAN_SPEED_OFFSET);
155 if (fan > FAN_SPEED_MAX && fan != FAN_SPEED_AUTO)
167static constexpr uint32_t CARRIER_FREQUENCY = 36700;
168static constexpr uint32_t HEADER_MARK = 3456;
169static constexpr uint32_t HEADER_SPACE = 1728;
170static constexpr uint32_t BIT_MARK = 432;
171static constexpr uint32_t BIT_ONE_SPACE = 1296;
172static constexpr uint32_t BIT_ZERO_SPACE = 432;
173static constexpr uint32_t SECTION_GAP = 10000;
175 .bit_mark = BIT_MARK, .one_space = BIT_ONE_SPACE, .zero_space = BIT_ZERO_SPACE};
179 return data.peek_mark(BIT_MARK) && (!data.is_valid(1) || data.peek_space_at_least(3 * BIT_ONE_SPACE, 1));
184 if (!data.expect_item(HEADER_MARK, HEADER_SPACE) || !data.expect_bytes<BIT_TIMINGS>(bytes, SECTION1_LENGTH))
186 size_t len = SECTION1_LENGTH;
188 if (!data.expect_bytes<BIT_TIMINGS>(bytes + SECTION1_LENGTH, SECTION2_LENGTH - SECTION1_LENGTH) ||
191 len = SECTION2_LENGTH;
203 uint8_t section[SECTION2_LENGTH];
206 uint8_t expected[STATE_LENGTH];
209 if (
len == SECTION1_LENGTH) {
210 if (memcmp(section, expected, SECTION1_LENGTH) != 0)
213 if (!data.is_valid(1) || !data.expect_space(SECTION_GAP))
217 if (
len != SECTION2_LENGTH)
220 memcpy(
state, expected, SECTION1_LENGTH);
221 memcpy(
state + SECTION1_LENGTH, section, SECTION2_LENGTH);
constexpr uint8_t sum_bytes(const uint8_t *data, size_t len, uint8_t sum=0)
Add up the bytes of data with size len, truncated to 8 bits: the checksum many serial and IR protocol...