Improve Power State Update Task timing

This commit is contained in:
Phillip Kühne 2025-02-16 19:17:36 +01:00
parent a48dd7c9dd
commit fd1be4ffeb
Signed by: phillip
GPG Key ID: E4C1C4D2F90902AA
2 changed files with 8 additions and 1 deletions

View File

@ -14,8 +14,11 @@ SemaphoreHandle_t PowerManager::powerMutex = NULL;
void vTaskUpdatePowerState(void *pvParameters) { void vTaskUpdatePowerState(void *pvParameters) {
for (;;) { for (;;) {
ESP_LOGV(TAG, "Updating Power State..."); ESP_LOGV(TAG, "Updating Power State...");
TickType_t executionStart = xTaskGetTickCount();
PowerManager::updatePowerStateHandler(); PowerManager::updatePowerStateHandler();
vTaskDelay(pdMS_TO_TICKS(10)); vTaskDelayUntil(
&executionStart,
pdMS_TO_TICKS(PowerParameters::POWER_STATE_UPDATE_INTERVAL_MS));
} }
} }

View File

@ -12,6 +12,7 @@
#ifndef PowerParameters_h #ifndef PowerParameters_h
#define PowerParameters_h #define PowerParameters_h
#include <cstdint>
namespace PowerParameters { namespace PowerParameters {
struct Battery { struct Battery {
@ -114,6 +115,9 @@ enum PowerConsumers {
MOTOR_RIGHT, MOTOR_RIGHT,
IMU IMU
}; };
static constexpr uint32_t POWER_STATE_UPDATE_INTERVAL_MS = 10;
}; // namespace PowerParameters }; // namespace PowerParameters
#endif // Consumptions_h #endif // Consumptions_h