From 8561b0a62f1995c57af65488f96918b34ecd195a Mon Sep 17 00:00:00 2001 From: Djordje <6750655+DjordjeMandic@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:57:44 +0100 Subject: [PATCH] [midea] [midea_ir] Use esphome clamp helper instead of std clamp --- esphome/components/midea/air_conditioner.cpp | 3 ++- esphome/components/midea/ir_transmitter.h | 6 +++--- esphome/components/midea_ir/midea_data.h | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/esphome/components/midea/air_conditioner.cpp b/esphome/components/midea/air_conditioner.cpp index 0513160711..787299683a 100644 --- a/esphome/components/midea/air_conditioner.cpp +++ b/esphome/components/midea/air_conditioner.cpp @@ -1,6 +1,7 @@ #ifdef USE_ARDUINO #include "esphome/core/log.h" +#include "esphome/core/helpers.h" #include "air_conditioner.h" #include "ac_adapter.h" #include @@ -131,7 +132,7 @@ void AirConditioner::do_follow_me(float temperature, bool fahrenheit, bool beepe // Round and convert temperature to long, then clamp and convert it to uint8_t uint8_t temp_uint8 = - static_cast(std::clamp(std::lroundf(temperature), 0L, static_cast(UINT8_MAX))); + static_cast(esphome::clamp(std::lroundf(temperature), 0L, static_cast(UINT8_MAX))); char temp_symbol = fahrenheit ? 'F' : 'C'; ESP_LOGD(Constants::TAG, "Follow me action called with temperature: %f °%c, rounded to: %u °%c", temperature, diff --git a/esphome/components/midea/ir_transmitter.h b/esphome/components/midea/ir_transmitter.h index 30d817a132..4da37cf043 100644 --- a/esphome/components/midea/ir_transmitter.h +++ b/esphome/components/midea/ir_transmitter.h @@ -3,7 +3,7 @@ #ifdef USE_ARDUINO #ifdef USE_REMOTE_TRANSMITTER #include "esphome/components/remote_base/midea_protocol.h" -#include +#include "esphome/core/helpers.h" namespace esphome { namespace midea { @@ -39,9 +39,9 @@ class IrFollowMeData : public IrData { this->set_fahrenheit(fahrenheit); if (this->fahrenheit()) { // see https://github.com/esphome/feature-requests/issues/1627#issuecomment-1365639966 - val = std::clamp(val, MIN_TEMP_F, MAX_TEMP_F) - 31; + val = esphome::clamp(val, MIN_TEMP_F, MAX_TEMP_F) - 31; } else { - val = std::clamp(val, MIN_TEMP_C, MAX_TEMP_C) + 1; + val = esphome::clamp(val, MIN_TEMP_C, MAX_TEMP_C) + 1; } this->set_value_(4, val); } diff --git a/esphome/components/midea_ir/midea_data.h b/esphome/components/midea_ir/midea_data.h index b73898c356..9a35d5f260 100644 --- a/esphome/components/midea_ir/midea_data.h +++ b/esphome/components/midea_ir/midea_data.h @@ -2,7 +2,7 @@ #include "esphome/components/remote_base/midea_protocol.h" #include "esphome/components/climate/climate_mode.h" -#include +#include "esphome/core/helpers.h" namespace esphome { namespace midea_ir { @@ -85,9 +85,9 @@ class FollowMeData : public MideaData { this->set_fahrenheit(fahrenheit); if (this->fahrenheit()) { // see https://github.com/esphome/feature-requests/issues/1627#issuecomment-1365639966 - val = std::clamp(val, MIN_TEMP_F, MAX_TEMP_F) - 31; + val = esphome::clamp(val, MIN_TEMP_F, MAX_TEMP_F) - 31; } else { - val = std::clamp(val, MIN_TEMP_C, MAX_TEMP_C) + 1; + val = esphome::clamp(val, MIN_TEMP_C, MAX_TEMP_C) + 1; } this->set_value_(4, val); }