diff --git a/src/ir_Bosch.cpp b/src/ir_Bosch.cpp index 56e9d2b99..31753520f 100644 --- a/src/ir_Bosch.cpp +++ b/src/ir_Bosch.cpp @@ -98,15 +98,20 @@ void IRBosch144AC::setTempRaw(const uint8_t code) { _.TempS3 = code & 1; // save 1 bit in Section3 } -/// Set the temperature. +/// Set the temperature. Allow 0.5 degree steps. /// @param[in] degrees The temperature in degrees celsius. -void IRBosch144AC::setTemp(const uint8_t degrees) { - uint8_t temp = max(kBosch144TempMin, degrees); +void IRBosch144AC::setTemp(const float degrees) { + uint8_t temp = static_cast(degrees); + temp = max(kBosch144TempMin, temp); temp = min(kBosch144TempMax, temp); setTempRaw(kBosch144TempMap[temp - kBosch144TempMin]); + + _.TempHalfDegree = (degrees - temp) >= 0.5; } -uint8_t IRBosch144AC::getTemp(void) const { +/// Get the temperature with 0.5 degree steps. +/// @return The temperature in degrees celsius. +float IRBosch144AC::getTemp(void) const { uint8_t temp = (_.TempS1 << 1) + _.TempS3; uint8_t retemp = 25; for (uint8_t i = 0; i < kBosch144TempRange; i++) { @@ -114,7 +119,7 @@ uint8_t IRBosch144AC::getTemp(void) const { retemp = kBosch144TempMin + i; } } - return retemp; + return static_cast(retemp) + (_.TempHalfDegree ? 0.5f : 0.0f); } /// Set the speed of the fan. @@ -260,7 +265,7 @@ String IRBosch144AC::toString(void) const { static_cast(stdAc::fanspeed_t::kAuto), static_cast(stdAc::fanspeed_t::kAuto), static_cast(stdAc::fanspeed_t::kMedium)); - result += addTempToString(getTemp()); + result += addTempFloatToString(getTemp()); result += addBoolToString(_.Quiet, kQuietStr); return result; } diff --git a/src/ir_Bosch.h b/src/ir_Bosch.h index 9ebee9854..0864433d4 100644 --- a/src/ir_Bosch.h +++ b/src/ir_Bosch.h @@ -41,7 +41,7 @@ const uint16_t kBosch144BytesPerSection = 6; using irutils::addBoolToString; using irutils::addModeToString; using irutils::addFanToString; -using irutils::addTempToString; +using irutils::addTempFloatToString; using std::min; using std::max; using std::memcpy; @@ -100,37 +100,39 @@ const uint8_t kBosch144DefaultState[kBosch144StateLength] = { union Bosch144Protocol { uint8_t raw[kBosch144StateLength]; ///< The state in IR code form. struct { - uint8_t :8; // Fixed value 0b10110010 / 0xB2. ############ - uint8_t InnvertS1_1:8; // Invert byte 0b01001101 / 0x4D # - uint8_t :5; // not used (without timer use) # - uint8_t FanS1 :3; // Fan speed bits in Section 1 # - uint8_t InnvertS1_2:8; // Invert byte # Section 1 = - uint8_t :2; // not used (without timer use) # Sektion 2 - uint8_t ModeS1 :2; // Operation mode bits S1 # - uint8_t TempS1 :4; // Desired temperature (Celsius) S2 # - uint8_t InnvertS1_3:8; // Invert byte (without timer use) ############ - - uint8_t :8; // Fixed value 0b10110010 / 0xB2. ############ - uint8_t InnvertS2_1:8; // Invert byte 0b01001101 / 0x4D # - uint8_t :5; // not used (without timer use) # - uint8_t FanS2 :3; // Fan speed bits in Section 2 # - uint8_t InnvertS2_2:8; // Invert byte # Section 2 = - uint8_t :2; // not used (without timer use) # Sektion 1 - uint8_t ModeS2 :2; // Operation mode bits S2 # - uint8_t TempS2 :4; // Desired temperature (Celsius) S2 # - uint8_t InnvertS2_3:8; // Invert byte (without timer use) ########### - - uint8_t :8; // Fixed value 0b11010101 / 0xD5 ########### - uint8_t ModeS3 :1; // ModeBit in Section 3 # - uint8_t FanS3 :6; // Fan speed bits in Section 3 # - uint8_t :1; // Unknown # - uint8_t :7; // Unknown # - uint8_t Quiet :1; // Silent-Mode # Section 3 - uint8_t :4; // Unknown # - uint8_t TempS3 :1; // Desired temp. Bit in Section3 # - uint8_t :3; // Unknown # - uint8_t :8; // Unknown # - uint8_t ChecksumS3 :8; // Checksum from byte 13-17 ########### + uint8_t :8; // Fixed value 0b10110010 / 0xB2. ########## + uint8_t InnvertS1_1 :8; // Invert byte 0b01001101 / 0x4D # + uint8_t :5; // not used (without timer use) # + uint8_t FanS1 :3; // Fan speed bits in Section 1 # + uint8_t InnvertS1_2 :8; // Invert byte # Section 1 = + uint8_t :2; // not used (without timer use) # Sektion 2 + uint8_t ModeS1 :2; // Operation mode bits S1 # + uint8_t TempS1 :4; // Desired temperature (Celsius) S2 # + uint8_t InnvertS1_3 :8; // Invert byte (without timer use) ########## + + uint8_t :8; // Fixed value 0b10110010 / 0xB2. ########## + uint8_t InnvertS2_1 :8; // Invert byte 0b01001101 / 0x4D # + uint8_t :5; // not used (without timer use) # + uint8_t FanS2 :3; // Fan speed bits in Section 2 # + uint8_t InnvertS2_2 :8; // Invert byte # Section 2 = + uint8_t :2; // not used (without timer use) # Sektion 1 + uint8_t ModeS2 :2; // Operation mode bits S2 # + uint8_t TempS2 :4; // Desired temperature (Celsius) S2 # + uint8_t InnvertS2_3 :8; // Invert byte (without timer use) ########## + + uint8_t :8; // Fixed value 0b11010101 / 0xD5 ########## + uint8_t ModeS3 :1; // ModeBit in Section 3 # + uint8_t FanS3 :6; // Fan speed bits in Section 3 # + uint8_t :1; // Unknown # + uint8_t :5; // Unknown # + uint8_t TempHalfDegree:1; // Desired temp. Half degree bit # + uint8_t :1; // Unknown # Section 3 + uint8_t Quiet :1; // Silent-Mode # + uint8_t :4; // Unknown # + uint8_t TempS3 :1; // Desired temp. Bit in Section3 # + uint8_t :3; // Unknown # + uint8_t :8; // Unknown # + uint8_t ChecksumS3 :8; // Checksum from byte 13-17 ########## }; }; @@ -153,8 +155,8 @@ class IRBosch144AC { void begin(); void setPower(const bool state); bool getPower(void) const; - void setTemp(const uint8_t temp); - uint8_t getTemp(void) const; + void setTemp(const float temp); + float getTemp(void) const; void setFan(const uint16_t speed); uint16_t getFan(void) const; void setMode(const uint8_t mode);