diff --git a/components/services/battery.c b/components/services/battery.c index a0134c8c..2b356106 100644 --- a/components/services/battery.c +++ b/components/services/battery.c @@ -41,6 +41,8 @@ static struct { .attenuation = ADC_ATTEN_DB_0, }; +void (*battery_handler_svc)(float value); + /**************************************************************************************** * */ @@ -65,6 +67,7 @@ static void battery_callback(TimerHandle_t xTimer) { if (++battery.count == 30) { battery.avg = battery.sum / battery.count; battery.sum = battery.count = 0; + if (battery_handler_svc) (battery_handler_svc)(battery.avg); ESP_LOGI(TAG, "Voltage %.2fV", battery.avg); } } diff --git a/components/services/monitor.h b/components/services/monitor.h index 3f441ff9..b0710153 100644 --- a/components/services/monitor.h +++ b/components/services/monitor.h @@ -20,6 +20,7 @@ extern bool jack_inserted_svc(void); extern void (*spkfault_handler_svc)(bool inserted); extern bool spkfault_svc(void); +extern void (*battery_handler_svc)(float value); extern float battery_value_svc(void); extern uint16_t battery_level_svc(void);