move IDLE_POWER_SAVING_MS
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
#include "HalPowerManager.h"
|
||||||
|
|
||||||
#include <esp_sleep.h>
|
#include <esp_sleep.h>
|
||||||
|
|
||||||
#include "HalPowerManager.h"
|
|
||||||
#include "HalGPIO.h"
|
#include "HalGPIO.h"
|
||||||
|
|
||||||
void HalPowerManager::begin() {
|
void HalPowerManager::begin() {
|
||||||
|
|||||||
@@ -7,12 +7,13 @@
|
|||||||
#include "HalGPIO.h"
|
#include "HalGPIO.h"
|
||||||
|
|
||||||
class HalPowerManager {
|
class HalPowerManager {
|
||||||
static constexpr int LOW_POWER_FREQ = 10; // MHz
|
|
||||||
|
|
||||||
int normalFreq = 0; // MHz
|
int normalFreq = 0; // MHz
|
||||||
bool isLowPower = false;
|
bool isLowPower = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static constexpr int LOW_POWER_FREQ = 10; // MHz
|
||||||
|
static constexpr unsigned long IDLE_POWER_SAVING_MS = 3000; // ms
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
|
|
||||||
// Control CPU frequency for power saving
|
// Control CPU frequency for power saving
|
||||||
|
|||||||
@@ -414,8 +414,7 @@ void loop() {
|
|||||||
if (currentActivity && currentActivity->skipLoopDelay()) {
|
if (currentActivity && currentActivity->skipLoopDelay()) {
|
||||||
yield(); // Give FreeRTOS a chance to run tasks, but return immediately
|
yield(); // Give FreeRTOS a chance to run tasks, but return immediately
|
||||||
} else {
|
} else {
|
||||||
static constexpr unsigned long IDLE_POWER_SAVING_MS = 3000; // 3 seconds
|
if (millis() - lastActivityTime >= HalPowerManager::IDLE_POWER_SAVING_MS) {
|
||||||
if (millis() - lastActivityTime >= IDLE_POWER_SAVING_MS) {
|
|
||||||
// If we've been inactive for a while, increase the delay to save power
|
// If we've been inactive for a while, increase the delay to save power
|
||||||
powerManager.setPowerSaving(true); // Lower CPU frequency after extended inactivity
|
powerManager.setPowerSaving(true); // Lower CPU frequency after extended inactivity
|
||||||
delay(50);
|
delay(50);
|
||||||
|
|||||||
Reference in New Issue
Block a user