mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 12:06:26 +01:00
Replace method map_float with helper method remap
This commit is contained in:
parent
a6695e65e1
commit
e35968d003
@ -93,10 +93,6 @@ float Sen0501Component::get_setup_priority() const { return setup_priority::DATA
|
||||
|
||||
// PROTECTED
|
||||
|
||||
float Sen0501Component::map_float_(float x, float in_min, float in_max, float out_min, float out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
void Sen0501Component::read_temperature_() {
|
||||
uint8_t buffer[2];
|
||||
uint16_t data;
|
||||
@ -137,7 +133,7 @@ void Sen0501Component::read_uv_intensity_() {
|
||||
} else if (output_voltage >= 2.99) {
|
||||
output_voltage = 2.99;
|
||||
}
|
||||
ultra_violet = map_float_(output_voltage, 0.99, 2.9, 0.0, 15.0);
|
||||
ultra_violet = remap(output_voltage, 0.99f, 2.9f, 0.0f, 15.0f);
|
||||
}
|
||||
this->uv_intensity_->publish_state(ultra_violet);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ class Sen0501Component : public PollingComponent, public i2c::I2CDevice {
|
||||
void update() override;
|
||||
|
||||
protected:
|
||||
float map_float_(float x, float in_min, float in_max, float out_min, float out_max);
|
||||
|
||||
void read_temperature_();
|
||||
void read_humidity_();
|
||||
|
Loading…
Reference in New Issue
Block a user