]> www.fi.muni.cz Git - bike-lights.git/blobdiff - adc.c
adc: battery adc
[bike-lights.git] / adc.c
diff --git a/adc.c b/adc.c
index 9a5e31438834a7408acfd7e086935a14781da37f..bef7375e8b54f40167e4c591a10021a0b653360e 100644 (file)
--- a/adc.c
+++ b/adc.c
@@ -3,6 +3,7 @@
 
 #include "lights.h"
 
+/* ADC numbering: PWM LEDs first, then ambient light sensor, battery sensor */
 static unsigned char adc_mux[] = { // pwmleds should be first
        // 0: pwmled 0: 1.1V, ADC3 (PA4), single-ended
        _BV(REFS1) | _BV(MUX1) | _BV(MUX0),
@@ -17,6 +18,7 @@ static unsigned char adc_mux[] = { // pwmleds should be first
 };
 
 #define AMBIENT_ADC N_PWMLEDS
+#define BATTERY_ADC (N_PWMLEDS + 1)
 
 #define LAST_ADC (sizeof(adc_mux)/sizeof(adc_mux[0]))
 volatile static unsigned char current_adc;
@@ -28,7 +30,7 @@ static void start_next_adc()
                --current_adc;
 
                // test if current_adc should be measured
-               if (current_adc < N_PWMLEDS && pwmled_is_on(current_adc))
+               if (current_adc < N_PWMLEDS && pwmled_needs_adc(current_adc))
                        goto found;
                if (current_adc == AMBIENT_ADC)
                        goto found;