mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 16:04:55 +00:00
[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:
@@ -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_;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user