diff options
Diffstat (limited to 'app/src/battery.c')
-rw-r--r-- | app/src/battery.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/app/src/battery.c b/app/src/battery.c index a99660c..c63008e 100644 --- a/app/src/battery.c +++ b/app/src/battery.c @@ -15,13 +15,14 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include <zmk/event_manager.h> +#include <zmk/battery.h> #include <zmk/events/battery_state_changed.h> const struct device *battery; -static int32_t last_state_of_charge = 0; +static uint8_t last_state_of_charge = 0; -int32_t zmk_battery_state_of_charge() { return last_state_of_charge; } +uint8_t zmk_battery_state_of_charge() { return last_state_of_charge; } static int zmk_battery_update(const struct device *battery) { struct sensor_value state_of_charge; @@ -43,9 +44,9 @@ static int zmk_battery_update(const struct device *battery) { if (last_state_of_charge != state_of_charge.val1) { last_state_of_charge = state_of_charge.val1; - LOG_DBG("Setting BAS GATT battery level to %d.", state_of_charge.val1); + LOG_DBG("Setting BAS GATT battery level to %d.", last_state_of_charge); - rc = bt_bas_set_battery_level(state_of_charge.val1); + rc = bt_bas_set_battery_level(last_state_of_charge); if (rc != 0) { LOG_WRN("Failed to set BAS GATT battery level (err %d)", rc); @@ -53,7 +54,7 @@ static int zmk_battery_update(const struct device *battery) { } rc = ZMK_EVENT_RAISE(new_zmk_battery_state_changed( - (struct zmk_battery_state_changed){.state_of_charge = state_of_charge.val1})); + (struct zmk_battery_state_changed){.state_of_charge = last_state_of_charge})); } return rc; |