mirror of
https://github.com/esphome/esphome.git
synced 2024-12-29 00:41:44 +01:00
[midea] [midea_ir] Use esphome clamp helper instead of std clamp
This commit is contained in:
parent
b760a74c5f
commit
8561b0a62f
3 changed files with 8 additions and 7 deletions
|
@ -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 <cmath>
|
||||
|
@ -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<uint8_t>(std::clamp<long>(std::lroundf(temperature), 0L, static_cast<long>(UINT8_MAX)));
|
||||
static_cast<uint8_t>(esphome::clamp<long>(std::lroundf(temperature), 0L, static_cast<long>(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,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#ifdef USE_ARDUINO
|
||||
#ifdef USE_REMOTE_TRANSMITTER
|
||||
#include "esphome/components/remote_base/midea_protocol.h"
|
||||
#include <algorithm>
|
||||
#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<uint8_t>(val, MIN_TEMP_F, MAX_TEMP_F) - 31;
|
||||
val = esphome::clamp<uint8_t>(val, MIN_TEMP_F, MAX_TEMP_F) - 31;
|
||||
} else {
|
||||
val = std::clamp<uint8_t>(val, MIN_TEMP_C, MAX_TEMP_C) + 1;
|
||||
val = esphome::clamp<uint8_t>(val, MIN_TEMP_C, MAX_TEMP_C) + 1;
|
||||
}
|
||||
this->set_value_(4, val);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "esphome/components/remote_base/midea_protocol.h"
|
||||
#include "esphome/components/climate/climate_mode.h"
|
||||
#include <algorithm>
|
||||
#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<uint8_t>(val, MIN_TEMP_F, MAX_TEMP_F) - 31;
|
||||
val = esphome::clamp<uint8_t>(val, MIN_TEMP_F, MAX_TEMP_F) - 31;
|
||||
} else {
|
||||
val = std::clamp<uint8_t>(val, MIN_TEMP_C, MAX_TEMP_C) + 1;
|
||||
val = esphome::clamp<uint8_t>(val, MIN_TEMP_C, MAX_TEMP_C) + 1;
|
||||
}
|
||||
this->set_value_(4, val);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue