diff --git a/esphome/components/bl0910/bl0910.cpp b/esphome/components/bl0910/bl0910.cpp index 67c9da4bff..d2fba1becd 100644 --- a/esphome/components/bl0910/bl0910.cpp +++ b/esphome/components/bl0910/bl0910.cpp @@ -10,7 +10,7 @@ namespace bl0910 { static const char *const TAG = "bl0910"; -static uint8_t checksum_calc(uint8_t *data) { +static uint8_t checksum_calc(const uint8_t *data) { uint8_t checksum = 0; for (int i = 0; i < 5; i++) { checksum += data[i]; @@ -74,12 +74,12 @@ float BL0910::get_energy(uint8_t channel) { return ((float) this->read_register(BL0910_REG_CF_CNT[channel])) / this->energy_reference_[channel]; } -float BL0910::get_frequency(void) { +float BL0910::get_frequency() { const float freq = (float) this->read_register(BL0910_REG_PERIOD); return 10000000.0 / freq; } -float BL0910::get_temperature(void) { +float BL0910::get_temperature() { const float temp = (float) this->read_register(BL0910_REG_TPS1); return (temp - 64.0) * 12.5 / 59.0 - 40.0; } diff --git a/esphome/components/bl0910/bl0910.h b/esphome/components/bl0910/bl0910.h index 26e5c3cd18..f183b95db6 100644 --- a/esphome/components/bl0910/bl0910.h +++ b/esphome/components/bl0910/bl0910.h @@ -72,11 +72,11 @@ class BL0910 : public PollingComponent, void write_register(uint8_t addr, uint8_t data_h, uint8_t data_m, uint8_t data_l); int32_t read_register(uint8_t addr); float get_voltage(uint8_t channel); - float get_frequency(void); + float get_frequency(); float get_current(uint8_t channel); float get_power(uint8_t channel); float get_energy(uint8_t channel); - float get_temperature(void); + float get_temperature(); float get_powerfactor(uint8_t channel, float freq); }; } // namespace bl0910