Notify battery level every 10 minutes when connected to a BLE host.

Refactor battery percent : only use uint8_t to store the battery % remaining.
This commit is contained in:
Jean-François Milants
2021-07-11 16:55:06 +02:00
parent 6a91b83b12
commit e21f6a7f41
17 changed files with 71 additions and 68 deletions

View File

@@ -330,6 +330,11 @@ void SystemTask::Work() {
}
}
if (xTaskGetTickCount() - batteryNotificationTick > batteryNotificationPeriod) {
nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());
batteryNotificationTick = xTaskGetTickCount();
}
monitor.Process();
uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG);
dateTimeController.UpdateTime(systick_counter);

View File

@@ -135,6 +135,8 @@ namespace Pinetime {
void GoToRunning();
void UpdateMotion();
bool stepCounterMustBeReset = false;
static constexpr TickType_t batteryNotificationPeriod = 1000 * 60 * 10; // 1 tick ~= 1ms. 1ms * 60 * 10 = 10 minutes
TickType_t batteryNotificationTick = 0;
#if configUSE_TRACE_FACILITY == 1
SystemMonitor<FreeRtosMonitor> monitor;