mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-30 02:15:41 +00:00
move feature flags
This commit is contained in:
parent
8cb9344ed7
commit
07804e1efa
@ -102,7 +102,7 @@ static void lsEnter()
|
||||
static void lsIdle()
|
||||
{
|
||||
if (!doPreflightSleep()) {
|
||||
#ifdef DYNAMIC_LIGHT_SLEEP
|
||||
#ifdef HAS_DYNAMIC_LIGHT_SLEEP
|
||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||
#endif
|
||||
return;
|
||||
@ -329,7 +329,7 @@ void PowerFSM_setup()
|
||||
powerFSM.add_transition(&stateLS, &stateDARK, EVENT_WEB_REQUEST, NULL, "Web request");
|
||||
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_WEB_REQUEST, NULL, "Web request");
|
||||
|
||||
#ifdef DYNAMIC_LIGHT_SLEEP
|
||||
#ifdef HAS_DYNAMIC_LIGHT_SLEEP
|
||||
// it's better to exit dynamic light sleep when packet is received to ensure routing is properly handled
|
||||
powerFSM.add_transition(&stateLS, &stateDARK, EVENT_RADIO_INTERRUPT, NULL, "Radio interrupt");
|
||||
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_RADIO_INTERRUPT, NULL, "Radio interrupt");
|
||||
|
@ -24,14 +24,11 @@
|
||||
#define EVENT_RADIO_INTERRUPT 18
|
||||
#define EVENT_WEB_REQUEST 19
|
||||
|
||||
#ifdef ARCH_ESP32
|
||||
#ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#define DYNAMIC_LIGHT_SLEEP
|
||||
#ifdef HAS_DYNAMIC_LIGHT_SLEEP
|
||||
#define WAKE_TIME_MS 500
|
||||
#else
|
||||
#define WAKE_TIME_MS (Default::getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if MESHTASTIC_EXCLUDE_POWER_FSM
|
||||
class FakeFsm
|
||||
|
@ -211,3 +211,13 @@
|
||||
#endif
|
||||
|
||||
#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32 // FIXME: may be different on ESP32-S3, etc.
|
||||
|
||||
// Setup flag, which indicates if our device supports power management
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#define HAS_ESP32_PM_SUPPORT
|
||||
#endif
|
||||
|
||||
// Setup flag, which indicates if our device supports dynamic light sleep
|
||||
#if defined(HAS_ESP32_PM_SUPPORT) && defined(CONFIG_FREERTOS_USE_TICKLESS_IDLE)
|
||||
#define HAS_DYNAMIC_LIGHT_SLEEP
|
||||
#endif
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "target_specific.h"
|
||||
|
||||
#ifdef ARCH_ESP32
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef HAS_ESP32_PM_SUPPORT
|
||||
#include "esp32/pm.h"
|
||||
#include "esp_pm.h"
|
||||
#endif
|
||||
@ -54,7 +54,7 @@ Observable<void *> notifyLightSleep;
|
||||
/// Called to tell observers that light sleep has just ended, and why it ended
|
||||
Observable<esp_sleep_wakeup_cause_t> notifyLightSleepEnd;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef HAS_ESP32_PM_SUPPORT
|
||||
esp_pm_lock_handle_t pmHandle;
|
||||
#endif
|
||||
|
||||
@ -84,7 +84,7 @@ void setCPUFast(bool on)
|
||||
#if defined(ARCH_ESP32) && !HAS_TFT
|
||||
#ifdef HAS_WIFI
|
||||
if (isWifiAvailable()) {
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && defined(WIFI_MAX_PERFORMANCE)
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(WIFI_MAX_PERFORMANCE)
|
||||
LOG_DEBUG("Set CPU to 240MHz because WiFi is in use");
|
||||
setCpuFrequencyMhz(240);
|
||||
return;
|
||||
@ -342,7 +342,7 @@ void doLightSleep(uint32_t sleepMsec)
|
||||
return; // nothing to do
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef HAS_ESP32_PM_SUPPORT
|
||||
res = esp_pm_lock_acquire(pmHandle);
|
||||
assert(res == ESP_OK);
|
||||
#endif
|
||||
@ -360,7 +360,7 @@ void doLightSleep(uint32_t sleepMsec)
|
||||
if (!pmLockAcquired) {
|
||||
console->flush();
|
||||
|
||||
#ifndef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#ifndef HAS_DYNAMIC_LIGHT_SLEEP
|
||||
esp_light_sleep_start();
|
||||
#endif
|
||||
|
||||
@ -371,7 +371,7 @@ void doLightSleep(uint32_t sleepMsec)
|
||||
enableLoraInterrupt();
|
||||
enableButtonInterrupt();
|
||||
|
||||
#ifndef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#ifndef HAS_DYNAMIC_LIGHT_SLEEP
|
||||
res = esp_sleep_enable_timer_wakeup(sleepMsec * 1000LL);
|
||||
assert(res == ESP_OK);
|
||||
#endif
|
||||
@ -414,13 +414,13 @@ void doLightSleep(uint32_t sleepMsec)
|
||||
|
||||
console->flush();
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef HAS_ESP32_PM_SUPPORT
|
||||
res = esp_pm_lock_release(pmHandle);
|
||||
assert(res == ESP_OK);
|
||||
#endif
|
||||
pmLockAcquired = false;
|
||||
|
||||
#ifndef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#ifndef HAS_DYNAMIC_LIGHT_SLEEP
|
||||
esp_light_sleep_start();
|
||||
#endif
|
||||
|
||||
@ -432,7 +432,7 @@ void initLightSleep()
|
||||
{
|
||||
esp_err_t res;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef HAS_ESP32_PM_SUPPORT
|
||||
res = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "meshtastic", &pmHandle);
|
||||
assert(res == ESP_OK);
|
||||
|
||||
@ -442,7 +442,7 @@ void initLightSleep()
|
||||
esp_pm_config_esp32_t pm_config;
|
||||
pm_config.max_freq_mhz = 80;
|
||||
pm_config.min_freq_mhz = 20;
|
||||
#ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#ifdef HAS_DYNAMIC_LIGHT_SLEEP
|
||||
pm_config.light_sleep_enable = true;
|
||||
#else
|
||||
pm_config.light_sleep_enable = false;
|
||||
|
Loading…
Reference in New Issue
Block a user