Skip to content

Commit 33dd0e1

Browse files
committed
fw/apps/rprf/mfg_charge: immediately fail if going out of temp range
Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 2cff6cb commit 33dd0e1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/fw/apps/prf_apps/mfg_charge_app.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,18 @@ static void prv_handle_second_tick(struct tm *tick_time, TimeUnits units_changed
110110
data->seconds_remaining);
111111
}
112112

113+
if (temp_mc < TEMP_MIN_MC || temp_mc > TEMP_MAX_MC) {
114+
next_state = ChargeStateFail;
115+
data->countdown_running = false;
116+
battery_set_charge_enable(false);
117+
break;
118+
}
119+
113120
if (charge_state.charge_percent > SLOW_THRESHOLD_PERCENTAGE && data->fastcharge_enabled) {
114121
// go slow for a bit
115122
battery_set_fast_charge(false);
116123
data->fastcharge_enabled = false;
117-
} else if (charge_state.charge_percent > PASS_BATTERY_PERCENTAGE &&
118-
temp_mc >= TEMP_MIN_MC && temp_mc <= TEMP_MAX_MC) {
124+
} else if (charge_state.charge_percent > PASS_BATTERY_PERCENTAGE) {
119125
// The reading can be a bit shaky in the short term (i.e. a flaky USB connection), or we
120126
// just started charging. Make sure we have settled before transitioning into the
121127
// ChargeStatePass state

0 commit comments

Comments
 (0)