Skip to content

Commit

Permalink
Add CPU deep and light sleep powermon states
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksville committed Jun 21, 2024
1 parent b2a388b commit febe747
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion protobufs
4 changes: 4 additions & 0 deletions src/PowerFSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Default.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "PowerMon.h"
#include "configuration.h"
#include "graphics/Screen.h"
#include "main.h"
Expand Down Expand Up @@ -49,6 +50,7 @@ static bool isPowered()
static void sdsEnter()
{
LOG_DEBUG("Enter state: SDS\n");
powerMon->setState(meshtastic_PowerMon_State_CPU_DeepSleep);
// FIXME - make sure GPS and LORA radio are off first - because we want close to zero current draw
doDeepSleep(Default::getConfiguredOrDefaultMs(config.power.sds_secs), false);
}
Expand Down Expand Up @@ -87,8 +89,10 @@ static void lsIdle()
// Briefly come out of sleep long enough to blink the led once every few seconds
uint32_t sleepTime = SLEEP_TIME;

powerMon->setState(meshtastic_PowerMon_State_CPU_LightSleep);
setLed(false); // Never leave led on while in light sleep
esp_sleep_source_t wakeCause2 = doLightSleep(sleepTime * 1000LL);
powerMon->clearState(meshtastic_PowerMon_State_CPU_LightSleep);

switch (wakeCause2) {
case ESP_SLEEP_WAKEUP_TIMER:
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/generated/meshtastic/powermon.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you are making new meshtastic features feel free to add new entries at the en
typedef enum _meshtastic_PowerMon_State {
meshtastic_PowerMon_State_None = 0,
meshtastic_PowerMon_State_CPU_DeepSleep = 1,
meshtastic_PowerMon_State_CPU_Sleep = 2,
meshtastic_PowerMon_State_CPU_LightSleep = 2,
meshtastic_PowerMon_State_CPU_Awake = 4,
meshtastic_PowerMon_State_Lora_RXOn = 8,
meshtastic_PowerMon_State_Lora_TXOn = 16,
Expand Down

0 comments on commit febe747

Please sign in to comment.