Fixed incorrect state transition due to 0-current glitch

This commit is contained in:
Thomas Kolb 2021-09-19 14:06:24 +02:00
parent 716c158716
commit 6ff8918e62

View file

@ -159,8 +159,8 @@ static void solar_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
break; break;
case CHARGE_TRANSITION: case CHARGE_TRANSITION:
// FIXME: dynamically adjust thresholds
if(charge_time_in_state < INITIAL_TO_FLOAT_TRANSITION_TIME) { if(charge_time_in_state < INITIAL_TO_FLOAT_TRANSITION_TIME) {
// dynamically adjust thresholds
fxp_t u_bat_full = fxp_t u_bat_full =
fxp_add(u_bat_initial_full, fxp_add(u_bat_initial_full,
fxp_mult( fxp_mult(
@ -198,12 +198,6 @@ static void solar_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
charge_state = CHARGE_HIGH_TEMPERATURE; charge_state = CHARGE_HIGH_TEMPERATURE;
break; break;
} }
// low-current limit (go to sleep at night)
if(meas->i_solar < sleep_solar_current) {
charge_state = CHARGE_SLEEP;
break;
}
break; break;
case CHARGE_SLEEP: case CHARGE_SLEEP: