From: Keith Packard Date: Tue, 25 Feb 2025 03:47:11 +0000 (-0800) Subject: altos: ignore the first few battery values in telebt-v4.0-seeed X-Git-Tag: 1.9.20~1^2~14 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=01930120dfb37a6aeaf1b3800aad62f56a4e67b9;p=fw%2Faltos altos: ignore the first few battery values in telebt-v4.0-seeed The ADC appears to get at least the first value wrong, so discard some before we check the battery voltage. Signed-off-by: Keith Packard --- diff --git a/src/telebt-v4.0-seeed/ao_telebt_seeed.c b/src/telebt-v4.0-seeed/ao_telebt_seeed.c index 75293993..8e27ded0 100644 --- a/src/telebt-v4.0-seeed/ao_telebt_seeed.c +++ b/src/telebt-v4.0-seeed/ao_telebt_seeed.c @@ -28,14 +28,17 @@ ao_validate(void) { uint8_t data; int16_t decivolt; + int i; ao_config_get(); /* Check the battery voltage */ - data = ao_data_head; - do { - ao_sleep((void *) &ao_data_head); - } while (ao_data_head == data); + for (i = 0; i < 10; i++) { + data = ao_data_head; + do { + ao_sleep((void *) &ao_data_head); + } while (ao_data_head == data); + } decivolt = ao_battery_decivolt(ao_data_ring[data].adc.v_batt); if (decivolt < 35 || 55 < decivolt) ao_panic(AO_FAIL_ADC);