option for a battery handler

This commit is contained in:
Philippe G
2022-01-17 23:41:03 -08:00
parent 4b704faaf3
commit 86953fff14
2 changed files with 4 additions and 0 deletions

View File

@@ -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);
}
}