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;
20 if (!
data.expect_item(MITSUBISHI_HEAVY_HDR_MARK, MITSUBISHI_HEAVY_HDR_SPACE))
25 for (uint8_t bit = 0; bit < 8; bit++) {
26 if (
data.expect_item(MITSUBISHI_HEAVY_BIT_MARK, MITSUBISHI_HEAVY_ONE_SPACE)) {
28 }
else if (!
data.expect_item(MITSUBISHI_HEAVY_BIT_MARK, MITSUBISHI_HEAVY_ZERO_SPACE)) {
39 for (uint8_t i = 0; i < PREFIX_LENGTH; i++) {
40 if (frame[i] != FRAME_PREFIX[i])
48 if ((uint8_t) (frame[i] ^ frame[i + 1]) != XOR_CHECKSUM_EXPECTED)
55 if (frame[MODE_TEMP_BYTE] & MITSUBISHI_HEAVY_MODE_OFF) {
59 switch (frame[MODE_TEMP_BYTE] & MODE_MASK) {
60 case MITSUBISHI_HEAVY_MODE_AUTO:
63 case MITSUBISHI_HEAVY_MODE_HEAT:
66 case MITSUBISHI_HEAVY_MODE_COOL:
69 case MITSUBISHI_HEAVY_MODE_DRY:
72 case MITSUBISHI_HEAVY_MODE_FAN:
81 uint8_t temp_nibble = frame[MODE_TEMP_BYTE] >> TEMPERATURE_SHIFT;
82 uint8_t inverted_nibble = ~temp_nibble;
83 uint8_t temp_offset = inverted_nibble &
TEMP_MASK;
84 return TEMPERATURE_BASE + temp_offset;
89 if (!decode_mode_field(frame,
mode))
92 climate.target_temperature = decode_temperature_field(frame);
98 if (!read_raw_bytes(data, frame))
100 if (!validate_prefix(frame))
102 if (!validate_checksums(frame))
104 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