report battery level to BLE device

This commit is contained in:
KlausMu 2024-01-24 16:23:01 +01:00
parent 66c8195a31
commit fb4dbd71be
2 changed files with 5 additions and 0 deletions

View file

@ -4,6 +4,8 @@
//#define CRG_STAT 21 // battery charger feedback, GPIO21, VSPIHD, EMAC_TX_EN
#define ADC_BAT 36 // Battery voltage sense input (1/2 divider), GPIO36, ADC1_CH0, RTC_GPIO0
extern int battery_percentage;
void init_battery(void);
void update_battery_stats(void);

View file

@ -2,6 +2,7 @@
#include "commandHandler.h"
#include "device_keyboard_ble.h"
#include "gui.h"
#include "battery.h"
#ifdef ENABLE_KEYBOARD_BLE
@ -38,6 +39,8 @@ bool blinkBluetoothLabelIsOn = false;
void update_keyboard_ble_status() {
if (bleKeyboard.isConnected()) {
lv_label_set_text(BluetoothLabel, LV_SYMBOL_BLUETOOTH);
bleKeyboard.setBatteryLevel(battery_percentage);
} else {
if(millis() - blinkBluetoothLabelLastChange >= 1000){
blinkBluetoothLabelIsOn = !blinkBluetoothLabelIsOn;