Replace method map_float with helper method remap

This commit is contained in:
thetestspecimen 2024-10-07 23:05:08 +03:00
parent a6695e65e1
commit e35968d003
No known key found for this signature in database
GPG Key ID: C88001C355A25170
2 changed files with 1 additions and 6 deletions

View File

@ -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);
}

View File

@ -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_();