mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 20:47:08 +03:00
option for a battery handler
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user