Skip to content

Commit 5b197cf

Browse files
gmarullclaude
andcommitted
mfg: retry vibration calibration up to 3 times
A single transient F0 detection glitch on the line should not fail the whole vibration test. Retry vibe_calibrate() on the next tick when it returns an error, up to MAX_CALIBRATION_ATTEMPTS, before reporting a failure. Unsupported drivers (E_INVALID_OPERATION) still skip without retrying. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
1 parent ac86abc commit 5b197cf

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/fw/apps/prf/mfg_vibration.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#define VIBE_COUNT 5
1919
#define FAIL_DISPLAY_S 3
20+
#define MAX_CALIBRATION_ATTEMPTS 3
2021

2122
typedef enum {
2223
STATE_CALIBRATE,
@@ -33,6 +34,7 @@ typedef struct {
3334

3435
int wait;
3536
int vibe_count;
37+
int cali_attempts;
3638
VibeTestState state;
3739
} AppData;
3840

@@ -79,6 +81,9 @@ static void prv_handle_second_tick(struct tm *tick_time, TimeUnits units_changed
7981
} else if (status == E_INVALID_OPERATION) {
8082
text_layer_set_text(&data->status, "CALIBRATION SKIPPED");
8183
data->state = STATE_WAITING;
84+
} else if (++data->cali_attempts < MAX_CALIBRATION_ATTEMPTS) {
85+
text_layer_set_text(&data->status, "CALIBRATION RETRY");
86+
// Stay in STATE_CALIBRATE to retry on the next tick.
8287
} else {
8388
text_layer_set_text(&data->status, "CALIBRATION FAILED");
8489
mfg_test_result_report(MfgTestId_Vibration, false, 0);

0 commit comments

Comments
 (0)