mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-04 18:49:00 +00:00
do not use ifdef for HAS_XYZ capability flags
This commit is contained in:
parent
b2b5bc1a6d
commit
0fbf7f7e4f
@ -85,7 +85,7 @@ static void lsEnter()
|
|||||||
sleepStart = -1;
|
sleepStart = -1;
|
||||||
sleepTime = 0;
|
sleepTime = 0;
|
||||||
|
|
||||||
#ifdef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
if (!doPreflightSleep()) {
|
if (!doPreflightSleep()) {
|
||||||
LOG_DEBUG("Transition to LS state aborted because of tasks pending");
|
LOG_DEBUG("Transition to LS state aborted because of tasks pending");
|
||||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||||
@ -102,7 +102,7 @@ static void lsEnter()
|
|||||||
static void lsIdle()
|
static void lsIdle()
|
||||||
{
|
{
|
||||||
if (!doPreflightSleep()) {
|
if (!doPreflightSleep()) {
|
||||||
#ifdef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
@ -119,7 +119,7 @@ static void lsIdle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#ifndef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if !HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
doLightSleep(sleepLeft);
|
doLightSleep(sleepLeft);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ static void lsIdle()
|
|||||||
|
|
||||||
static void lsExit()
|
static void lsExit()
|
||||||
{
|
{
|
||||||
#ifdef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
doLightSleep(LIGHT_SLEEP_ABORT);
|
doLightSleep(LIGHT_SLEEP_ABORT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ void PowerFSM_setup()
|
|||||||
powerFSM.add_transition(&stateLS, &stateDARK, EVENT_WEB_REQUEST, NULL, "Web request");
|
powerFSM.add_transition(&stateLS, &stateDARK, EVENT_WEB_REQUEST, NULL, "Web request");
|
||||||
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_WEB_REQUEST, NULL, "Web request");
|
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_WEB_REQUEST, NULL, "Web request");
|
||||||
|
|
||||||
#ifdef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
// it's better to exit dynamic light sleep when packet is received to ensure routing is properly handled
|
// 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(&stateLS, &stateDARK, EVENT_RADIO_INTERRUPT, NULL, "Radio interrupt");
|
||||||
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_RADIO_INTERRUPT, NULL, "Radio interrupt");
|
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_RADIO_INTERRUPT, NULL, "Radio interrupt");
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define EVENT_RADIO_INTERRUPT 18
|
#define EVENT_RADIO_INTERRUPT 18
|
||||||
#define EVENT_WEB_REQUEST 19
|
#define EVENT_WEB_REQUEST 19
|
||||||
|
|
||||||
#ifdef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
#define WAKE_TIME_MS 500
|
#define WAKE_TIME_MS 500
|
||||||
#else
|
#else
|
||||||
#define WAKE_TIME_MS (Default::getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs))
|
#define WAKE_TIME_MS (Default::getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs))
|
||||||
|
@ -227,6 +227,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Setup flag, which indicates if our device supports dynamic light sleep
|
// Setup flag, which indicates if our device supports dynamic light sleep
|
||||||
#if defined(HAS_ESP32_PM_SUPPORT) && defined(CONFIG_FREERTOS_USE_TICKLESS_IDLE)
|
#if HAS_ESP32_PM_SUPPORT && defined(CONFIG_FREERTOS_USE_TICKLESS_IDLE)
|
||||||
#define HAS_ESP32_DYNAMIC_LIGHT_SLEEP 1
|
#define HAS_ESP32_DYNAMIC_LIGHT_SLEEP 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#ifdef HAS_ESP32_PM_SUPPORT
|
#if HAS_ESP32_PM_SUPPORT
|
||||||
#include "esp32/pm.h"
|
#include "esp32/pm.h"
|
||||||
#include "esp_pm.h"
|
#include "esp_pm.h"
|
||||||
#endif
|
#endif
|
||||||
@ -54,7 +54,7 @@ Observable<void *> notifyLightSleep;
|
|||||||
/// Called to tell observers that light sleep has just ended, and why it ended
|
/// Called to tell observers that light sleep has just ended, and why it ended
|
||||||
Observable<esp_sleep_wakeup_cause_t> notifyLightSleepEnd;
|
Observable<esp_sleep_wakeup_cause_t> notifyLightSleepEnd;
|
||||||
|
|
||||||
#ifdef HAS_ESP32_PM_SUPPORT
|
#if HAS_ESP32_PM_SUPPORT
|
||||||
esp_pm_lock_handle_t pmLightSleepLock;
|
esp_pm_lock_handle_t pmLightSleepLock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false, bool skipSaveN
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#ifdef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
static bool pmLightSleepLockAcquired;
|
static bool pmLightSleepLockAcquired;
|
||||||
#endif
|
#endif
|
||||||
static concurrency::Lock *lightSleepConcurrencyLock;
|
static concurrency::Lock *lightSleepConcurrencyLock;
|
||||||
@ -335,7 +335,7 @@ void doLightSleep(uint32_t sleepMsec)
|
|||||||
assert(lightSleepConcurrencyLock);
|
assert(lightSleepConcurrencyLock);
|
||||||
lightSleepConcurrencyLock->lock();
|
lightSleepConcurrencyLock->lock();
|
||||||
|
|
||||||
#ifndef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if !HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
assert(sleepMsec != LIGHT_SLEEP_ABORT);
|
assert(sleepMsec != LIGHT_SLEEP_ABORT);
|
||||||
assert(sleepMsec != LIGHT_SLEEP_DYNAMIC);
|
assert(sleepMsec != LIGHT_SLEEP_DYNAMIC);
|
||||||
#else
|
#else
|
||||||
@ -419,7 +419,7 @@ void doLightSleep(uint32_t sleepMsec)
|
|||||||
notifyLightSleepEnd.notifyObservers(wakeCause);
|
notifyLightSleepEnd.notifyObservers(wakeCause);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
res = esp_pm_lock_release(pmLightSleepLock);
|
res = esp_pm_lock_release(pmLightSleepLock);
|
||||||
assert(res == ESP_OK);
|
assert(res == ESP_OK);
|
||||||
pmLightSleepLockAcquired = false;
|
pmLightSleepLockAcquired = false;
|
||||||
@ -441,7 +441,7 @@ void initLightSleep()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_ESP32_PM_SUPPORT
|
#if HAS_ESP32_PM_SUPPORT
|
||||||
res = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "meshtastic", &pmLightSleepLock);
|
res = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "meshtastic", &pmLightSleepLock);
|
||||||
assert(res == ESP_OK);
|
assert(res == ESP_OK);
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ void initLightSleep()
|
|||||||
esp_pm_config_esp32_t pm_config;
|
esp_pm_config_esp32_t pm_config;
|
||||||
pm_config.max_freq_mhz = 80;
|
pm_config.max_freq_mhz = 80;
|
||||||
pm_config.min_freq_mhz = dfsSupported ? 20 : pm_config.max_freq_mhz;
|
pm_config.min_freq_mhz = dfsSupported ? 20 : pm_config.max_freq_mhz;
|
||||||
#ifdef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
pm_config.light_sleep_enable = true;
|
pm_config.light_sleep_enable = true;
|
||||||
#else
|
#else
|
||||||
pm_config.light_sleep_enable = false;
|
pm_config.light_sleep_enable = false;
|
||||||
@ -466,7 +466,7 @@ void initLightSleep()
|
|||||||
|
|
||||||
lightSleepConcurrencyLock = new concurrency::Lock();
|
lightSleepConcurrencyLock = new concurrency::Lock();
|
||||||
|
|
||||||
#ifdef HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
#if HAS_ESP32_DYNAMIC_LIGHT_SLEEP
|
||||||
pmLightSleepLockAcquired = true;
|
pmLightSleepLockAcquired = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#define LED_PIN LED
|
#define LED_PIN LED
|
||||||
|
|
||||||
#define HAS_32768HZ
|
|
||||||
|
|
||||||
#define USE_SSD1306 // Heltec_v3 has a SSD1306 display
|
#define USE_SSD1306 // Heltec_v3 has a SSD1306 display
|
||||||
|
|
||||||
#define RESET_OLED RST_OLED
|
#define RESET_OLED RST_OLED
|
||||||
@ -43,4 +41,4 @@
|
|||||||
#define SX126X_DIO2_AS_RF_SWITCH
|
#define SX126X_DIO2_AS_RF_SWITCH
|
||||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||||
|
|
||||||
#define HAS_32768HZ 1
|
#define HAS_32768HZ 1
|
||||||
|
Loading…
Reference in New Issue
Block a user