4#if defined(USE_ARDUINO) || defined(USE_ESP32)
6#include <HeatpumpIRFactory.h>
10static constexpr uint8_t FRAME_PREFIX[5] = {0x52, 0xAE, 0xC3, 0x26, 0xD9};
11static constexpr uint8_t XOR_CHECKSUM_EXPECTED = 0xFF;
12static constexpr uint8_t PREFIX_LENGTH = 5;
13static constexpr uint8_t MODE_TEMP_BYTE = 9;
14static constexpr uint8_t MODE_MASK = 0x07;
16static constexpr uint8_t TEMPERATURE_BASE = 17;
17static constexpr uint8_t TEMPERATURE_SHIFT = 4;
18static constexpr remote_base::BitTimings MITSUBISHI_HEAVY_BIT_TIMINGS{.bit_mark = MITSUBISHI_HEAVY_BIT_MARK,
19 .one_space = MITSUBISHI_HEAVY_ONE_SPACE,
20 .zero_space = MITSUBISHI_HEAVY_ZERO_SPACE};
23 if (!
data.expect_item(MITSUBISHI_HEAVY_HDR_MARK, MITSUBISHI_HEAVY_HDR_SPACE))
30 for (uint8_t i = 0; i < PREFIX_LENGTH; i++) {
31 if (frame[i] != FRAME_PREFIX[i])
39 if ((uint8_t) (frame[i] ^ frame[i + 1]) != XOR_CHECKSUM_EXPECTED)
46 if (frame[MODE_TEMP_BYTE] & MITSUBISHI_HEAVY_MODE_OFF) {
50 switch (frame[MODE_TEMP_BYTE] & MODE_MASK) {
51 case MITSUBISHI_HEAVY_MODE_AUTO:
54 case MITSUBISHI_HEAVY_MODE_HEAT:
57 case MITSUBISHI_HEAVY_MODE_COOL:
60 case MITSUBISHI_HEAVY_MODE_DRY:
63 case MITSUBISHI_HEAVY_MODE_FAN:
72 uint8_t temp_nibble = frame[MODE_TEMP_BYTE] >> TEMPERATURE_SHIFT;
73 uint8_t inverted_nibble = ~temp_nibble;
74 uint8_t temp_offset = inverted_nibble &
TEMP_MASK;
75 return TEMPERATURE_BASE + temp_offset;
80 if (!decode_mode_field(frame,
mode))
83 climate.target_temperature = decode_temperature_field(frame);
89 if (!read_raw_bytes(data, frame))
91 if (!validate_prefix(frame))
93 if (!validate_checksums(frame))
95 return apply_climate_state(frame, climate);
BedjetMode mode
BedJet operating mode.
ClimateMode
Enum for all modes a climate device can be in.
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
bool decode_mitsubishi_heavy_frame(remote_base::RemoteReceiveData &data, uint8_t frame[MITSUBISHI_HEAVY_FRAME_LENGTH], HeatpumpIRClimate &climate)
Read a Mitsubishi Heavy frame into frame, check its prefix and inverted byte pairs,...
constexpr uint8_t MITSUBISHI_HEAVY_FRAME_LENGTH
Bytes in a Mitsubishi Heavy IR frame, prefix included.
std::span< const uint8_t > data