]> git.gag.com Git - fw/altos/commitdiff
altos: ignore the first few battery values in telebt-v4.0-seeed
authorKeith Packard <keithp@keithp.com>
Tue, 25 Feb 2025 03:47:11 +0000 (19:47 -0800)
committerKeith Packard <keithp@keithp.com>
Tue, 25 Feb 2025 03:47:11 +0000 (19:47 -0800)
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 <keithp@keithp.com>
src/telebt-v4.0-seeed/ao_telebt_seeed.c

index 75293993198c9506d893b95ddd8f366e5d6b2adb..8e27ded0b59e47088417f8ea61977942854c528c 100644 (file)
@@ -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);