Skip to content

Commit 7c25c29

Browse files
committed
fw/apps/prf/mfg_charge: fail test if starting with too charged battery
Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 93ee320 commit 7c25c29

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/fw/apps/prf_apps/mfg_charge_app.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,21 @@ static const char* status_text[] = {
3434
#ifdef PLATFORM_TINTIN
3535
static const int SLOW_THRESHOLD_PERCENTAGE = 42; // ~3850mv
3636
static const int PASS_BATTERY_PERCENTAGE = 84; // ~4050mv
37+
static const int MAX_START_BATTERY_PERCENTAGE = 75; // Fail if starting >75%
3738

3839
static const int TEMP_MIN_MC = 0;
3940
static const int TEMP_MAX_MC = 0;
4041
#elif defined(PLATFORM_ASTERIX) || defined(PLATFORM_OBELIX) || defined(PLATFORM_GETAFIX)
4142
static const int SLOW_THRESHOLD_PERCENTAGE = 0;
4243
static const int PASS_BATTERY_PERCENTAGE = 70;
44+
static const int MAX_START_BATTERY_PERCENTAGE = 75; // Fail if starting >75%
4345

4446
static const int TEMP_MIN_MC = 15000; // 15.0C
4547
static const int TEMP_MAX_MC = 35000; // 35.0C
4648
#else
4749
static const int SLOW_THRESHOLD_PERCENTAGE = 0; // Always go "slow" on snowy
4850
static const int PASS_BATTERY_PERCENTAGE = 60; // ~4190mv
51+
static const int MAX_START_BATTERY_PERCENTAGE = 75; // Fail if starting >75%
4952

5053
static const int TEMP_MIN_MC = 0;
5154
static const int TEMP_MAX_MC = 0;
@@ -81,6 +84,12 @@ static void prv_handle_second_tick(struct tm *tick_time, TimeUnits units_changed
8184

8285
switch (data->test_state) {
8386
case ChargeStateStart:
87+
if (charge_state.charge_percent > MAX_START_BATTERY_PERCENTAGE) {
88+
next_state = ChargeStateFail;
89+
data->countdown_running = false;
90+
battery_set_charge_enable(false);
91+
break;
92+
}
8493
if (charge_state.is_plugged && charge_state.is_charging) {
8594
next_state = ChargeStateRunning;
8695
} else {

0 commit comments

Comments
 (0)