Skip to content

Commit 9d80f8b

Browse files
committed
Probable fix for power sensor bound check
1 parent 6eb27d3 commit 9d80f8b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

include/INA260.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ namespace INA260 {
9090
dCurrent_mAPS = dCurrent_mA * u_TO_BASE / dTime_us;
9191

9292
auto pTemp = static_cast<int_fast32_t>(powerSensor.readPower());
93-
if ((pTemp > (MAX_VOLTAGE_mV * MAX_CURRENT_A)) ||
94-
(pTemp < (PSENSOR::MIN_VOLTAGE_mV * MIN_CURRENT_A))) {
93+
if ((pTemp >
94+
(MAX_VOLTAGE_mV * static_cast<int_fast16_t>(MAX_CURRENT_A))) ||
95+
(pTemp < (PSENSOR::MIN_VOLTAGE_mV *
96+
static_cast<int_fast16_t>(MIN_CURRENT_A) * -1))) {
97+
// FIXED? 1540 mW out of bounds
9598
ESP_LOGE("TAG", "P out of bounds: %d mW", pTemp);
9699
result &= false;
97100
} // Else: Valid reading

0 commit comments

Comments
 (0)