muse long_press & battery read at boot

This commit is contained in:
Philippe G
2022-01-24 16:08:00 -08:00
parent 3d8055a948
commit cf4ed64eb0
3 changed files with 15 additions and 7 deletions

View File

@@ -46,30 +46,38 @@ static const char TAG[] = "muse";
static void (*battery_handler_chain)(float value);
static void battery_svc(float value);
static bool init(void);
static void set_battery_led(float value);
const struct target_s target_muse = { "muse", init };
static bool init(void) {
battery_handler_chain = battery_handler_svc;
battery_handler_svc = battery_svc;
ws2812_control_init();
ESP_LOGI(TAG, "Initializing for Muse");
float value = battery_value_svc();
ESP_LOGI(TAG, "Initializing for Muse %f", value);
return true;
}
#define VGREEN 4.0
#define VRED 3.6
static void battery_svc(float value) {
static void set_battery_led(float value) {
struct led_state new_state;
ESP_LOGI(TAG, "Called for battery service with %f", value);
if (value > VGREEN) new_state.leds[0] = GREEN;
else if (value < VRED) new_state.leds[0] = RED;
else new_state.leds[0] = YELLOW;
ws2812_write_leds(new_state);
}
static void battery_svc(float value) {
set_battery_led(value);
ESP_LOGI(TAG, "Called for battery service with %f", value);
if (battery_handler_chain) battery_handler_chain(value);
}