Implement Battery Update Task in HardwareRevX
This commit is contained in:
parent
7967300508
commit
b3aa617a59
2 changed files with 15 additions and 4 deletions
|
@ -428,10 +428,19 @@ void HardwareRevX::setupWifi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareRevX::startTasks() {
|
void HardwareRevX::startTasks() {
|
||||||
// if (xTaskCreate(&HardwareRevX::updateBatteryTask, "Battery Percent Update",
|
if (xTaskCreate(&HardwareRevX::updateBatteryTask, "Battery Percent Update",
|
||||||
// 1024, nullptr, 5, &batteryUpdateTskHndl) != pdPASS) {
|
1024, nullptr, 5, &batteryUpdateTskHndl) != pdPASS) {
|
||||||
// debugPrint("ERROR Could not Create Battery Update Task!");
|
debugPrint("ERROR Could not Create Battery Update Task!");
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HardwareRevX::updateBatteryTask(void*){
|
||||||
|
while(true){
|
||||||
|
if(auto status = mInstance->getBatteryStatus(); status.has_value()){
|
||||||
|
mInstance->mBatteryNotification.notify(status.value());
|
||||||
|
}
|
||||||
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HardwareRevX::loopHandler() {
|
void HardwareRevX::loopHandler() {
|
||||||
|
|
|
@ -60,6 +60,8 @@ protected:
|
||||||
|
|
||||||
// Tasks
|
// Tasks
|
||||||
void startTasks();
|
void startTasks();
|
||||||
|
/// @brief Send Battery Notification every 5 Seconds
|
||||||
|
static void updateBatteryTask(void *);
|
||||||
|
|
||||||
TaskHandle_t batteryUpdateTskHndl = nullptr;
|
TaskHandle_t batteryUpdateTskHndl = nullptr;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue