From 26fe9bba1445e7f4324ea00073249fc44525f509 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Mon, 18 Sep 2023 11:25:03 +0900 Subject: [PATCH] Daikin: Support setting temperature in 0.5 C unit Daikin 280-bit A/C protocol can set the temperature in 0.5 C unit. However, IRDaikinESP didn't support it. This PR allows to set and get the temperature in 0.5 C unit. It looks like some other Daikin protocols also support setting the temperature in 0.5 C unit: * Daikin2 * Daikin216 * Daikin160 * Daikin176 * Daikin152 However, they are not implemented in this PR, because I cannot test them. --- src/ir_Daikin.cpp | 15 ++++++++------- src/ir_Daikin.h | 7 +++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ir_Daikin.cpp b/src/ir_Daikin.cpp index f44cd8f13..45a0e6068 100644 --- a/src/ir_Daikin.cpp +++ b/src/ir_Daikin.cpp @@ -46,6 +46,7 @@ using irutils::addModeToString; using irutils::addSwingHToString; using irutils::addSwingVToString; using irutils::addTempToString; +using irutils::addTempFloatToString; using irutils::addFanToString; using irutils::bcdToUint8; using irutils::minsToString; @@ -221,15 +222,15 @@ bool IRDaikinESP::getPower(void) const { /// Set the temperature. /// @param[in] temp The temperature in degrees celsius. -void IRDaikinESP::setTemp(const uint8_t temp) { - uint8_t degrees = std::max(temp, kDaikinMinTemp); - degrees = std::min(degrees, kDaikinMaxTemp); - _.Temp = degrees; +void IRDaikinESP::setTemp(const float temp) { + float degrees = std::max(temp, static_cast(kDaikinMinTemp)); + degrees = std::min(degrees, static_cast(kDaikinMaxTemp)); + _.Temp2 = degrees * 2.0f; } /// Get the current temperature setting. /// @return The current setting for temp. in degrees celsius. -uint8_t IRDaikinESP::getTemp(void) const { return _.Temp; } +float IRDaikinESP::getTemp(void) const { return _.Temp2 / 2.0f; } /// Set the speed of the fan. /// @param[in] fan The desired setting. @@ -536,7 +537,7 @@ stdAc::state_t IRDaikinESP::toCommon(void) const { result.power = _.Power; result.mode = toCommonMode(_.Mode); result.celsius = true; - result.degrees = _.Temp; + result.degrees = _.Temp2 / 2.0f; result.fanspeed = toCommonFanSpeed(getFan()); result.swingv = _.SwingV ? stdAc::swingv_t::kAuto : stdAc::swingv_t::kOff; @@ -563,7 +564,7 @@ String IRDaikinESP::toString(void) const { result += addBoolToString(_.Power, kPowerStr, false); result += addModeToString(_.Mode, kDaikinAuto, kDaikinCool, kDaikinHeat, kDaikinDry, kDaikinFan); - result += addTempToString(_.Temp); + result += addTempFloatToString(_.Temp2 / 2.0f); result += addFanToString(getFan(), kDaikinFanMax, kDaikinFanMin, kDaikinFanAuto, kDaikinFanQuiet, kDaikinFanMed); result += addBoolToString(_.Powerful, kPowerfulStr); diff --git a/src/ir_Daikin.h b/src/ir_Daikin.h index 3a98f07e7..5becccf76 100644 --- a/src/ir_Daikin.h +++ b/src/ir_Daikin.h @@ -99,8 +99,7 @@ union DaikinESPProtocol{ uint64_t Mode :3; uint64_t :1; // Byte 22 - uint64_t :1; - uint64_t Temp :7; // Temp should be between 10 - 32 + uint64_t Temp2 :8; // Temp2 should be between 20 - 64 (10 C - 32 C) // Byte 23 uint64_t :8; @@ -738,8 +737,8 @@ class IRDaikinESP { void off(void); void setPower(const bool on); 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 uint8_t fan); uint8_t getFan(void) const; void setMode(const uint8_t mode);