Update the gfx task to make use of the battery indicator feature
This commit is contained in:
parent
3cee4efa91
commit
36aaafac13
@ -13,6 +13,7 @@
|
||||
#include "QMC5883L.h"
|
||||
#include "BMP280.h"
|
||||
#include "bma456w.h"
|
||||
#include "CST816D.h"
|
||||
#include "watch_peripherals.h"
|
||||
#include "watch_settings.h"
|
||||
|
||||
@ -23,6 +24,12 @@ static void date_time_cb(struct tm * const dateTime)
|
||||
//APP_LOG_DEBUG("RTC time : %d:%d:%d", dateTime->tm_hour, dateTime->tm_min, dateTime->tm_sec);
|
||||
}
|
||||
|
||||
static uint8_t battery_percentage = 100;
|
||||
static uint8_t battery_indicator_cb(void)
|
||||
{
|
||||
return battery_percentage;
|
||||
}
|
||||
|
||||
WatchFace_t watchFace;
|
||||
MenuScreen_t menuScreen;
|
||||
CompassScreen_t compassScreen;
|
||||
@ -143,13 +150,17 @@ void gfx_task(void *param)
|
||||
settings_screen_init(&settingsScreen);
|
||||
settings_screen_register_API_interface(&settingsScreen, &settingsScreenAPIInterface);
|
||||
|
||||
watch_face_register_cb(&watchFace, &(date_time_cb));
|
||||
watch_face_register_date_time_cb(&watchFace, &(date_time_cb));
|
||||
watch_face_register_battery_indicator_cb(&watchFace, &(battery_indicator_cb));
|
||||
watch_face_create(&watchFace);
|
||||
|
||||
lv_scr_load(watchFace.display);
|
||||
|
||||
/* Let's init the watch peripherals driver (vibration motor + battery voltage sense) */
|
||||
watch_peripherals_init(27);
|
||||
/* Make the first battery voltage reading here */
|
||||
uint16_t battery_voltage = watch_peripherals_get_battery_voltage(Battery_Unit_mV);
|
||||
battery_percentage = battery_voltage_to_percentage(battery_voltage);
|
||||
|
||||
/* Let's init the I2C interface */
|
||||
i2c_init(I2C_SDA, I2C_SCL, 100000);
|
||||
@ -261,7 +272,6 @@ void gfx_task(void *param)
|
||||
extern LCDConfig_t LCDConfig;
|
||||
float temperature = 0;
|
||||
float pressure = 0;
|
||||
uint16_t battery_voltage = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
@ -298,11 +308,14 @@ void gfx_task(void *param)
|
||||
{
|
||||
pressure = BMP280_get_pressure(&temperature);
|
||||
BMP280_trigger_measurement();
|
||||
battery_voltage = watch_peripherals_get_battery_voltage(Battery_Unit_mV);
|
||||
battery_percentage = battery_voltage_to_percentage(battery_voltage);
|
||||
APP_LOG_DEBUG("GFX thread, temp : %0.2f °C, press : %0.2f hPa, bat : %u mV <-> %u %%",
|
||||
temperature,
|
||||
pressure/100,
|
||||
battery_voltage = watch_peripherals_get_battery_voltage(Battery_Unit_mV),
|
||||
battery_voltage_to_percentage(battery_voltage));
|
||||
temperature,
|
||||
pressure/100,
|
||||
battery_voltage,
|
||||
battery_percentage);
|
||||
|
||||
aliveCounter = 0;
|
||||
}
|
||||
|
||||
@ -315,7 +328,7 @@ void gfx_task(void *param)
|
||||
//lcd_on(&LCDConfig, false);
|
||||
lcd_sleep(&LCDConfig, true);
|
||||
QMC5883L_set_power_mode(Standby);
|
||||
if(CST816D_set_power_mode())
|
||||
if(CST816D_sleep())
|
||||
APP_LOG_DEBUG("CST816D Sleep cmd ok");
|
||||
else
|
||||
APP_LOG_DEBUG("CST816D Sleep cmd fail");
|
||||
|
Loading…
Reference in New Issue
Block a user