Discharging: use averaged values for thresholds

This commit is contained in:
Thomas Kolb 2021-07-10 16:38:47 +02:00
parent 0339b521dd
commit 716c158716

View file

@ -270,7 +270,7 @@ static void load_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
discharge_state = DISCHARGE_OVERCURRENT; discharge_state = DISCHARGE_OVERCURRENT;
} }
if(meas->u_bat < u_bat_load_off) { if(meas->avg_u_bat < u_bat_load_off) {
discharge_state = DISCHARGE_VOLTAGE_LOW; discharge_state = DISCHARGE_VOLTAGE_LOW;
} }
break; break;
@ -282,7 +282,7 @@ static void load_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
} }
// Can only switch on again after a specific amount of time has passed // Can only switch on again after a specific amount of time has passed
if((meas->u_bat > u_bat_load_on) if((meas->avg_u_bat > u_bat_load_on)
&& (discharge_time_in_state > LOAD_ON_DELAY)) { && (discharge_time_in_state > LOAD_ON_DELAY)) {
discharge_state = DISCHARGE_OK; discharge_state = DISCHARGE_OK;
} }