[bl0942] Remove broken 24-bit overflow tracking (#15650)

Co-authored-by: DidierA <1620015+didiera@users.noreply.github.com>
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
Didier A
2026-05-06 18:34:55 +02:00
committed by GitHub
parent 2864922ac0
commit cfd2c9182c
2 changed files with 2 additions and 7 deletions

View File

@@ -161,13 +161,9 @@ void BL0942::received_package_(DataPacket *data) {
return;
}
// cf_cnt is only 24 bits, so track overflows
// cf_cnt wraps at 24 bits; total_increasing on the energy sensor handles the
// wrap (and any spurious chip resets) downstream.
uint32_t cf_cnt = (uint24_t) data->cf_cnt;
cf_cnt |= this->prev_cf_cnt_ & 0xff000000;
if (cf_cnt < this->prev_cf_cnt_) {
cf_cnt += 0x1000000;
}
this->prev_cf_cnt_ = cf_cnt;
float v_rms = (uint24_t) data->v_rms / voltage_reference_;
float i_rms = (uint24_t) data->i_rms / current_reference_;

View File

@@ -141,7 +141,6 @@ class BL0942 : public PollingComponent, public uart::UARTDevice {
bool reset_ = false;
LineFrequency line_freq_ = LINE_FREQUENCY_50HZ;
optional<uint32_t> rx_start_{};
uint32_t prev_cf_cnt_ = 0;
bool validate_checksum_(DataPacket *data);
int read_reg_(uint8_t reg);