diff --git a/docs/software/nrf52-TODO.md b/docs/software/nrf52-TODO.md index 46d320346..257862c3b 100644 --- a/docs/software/nrf52-TODO.md +++ b/docs/software/nrf52-TODO.md @@ -7,6 +7,10 @@ TODO: +- enter SDS state at correct time (to protect battery or loss of phone contact) +- show screen on eink when we enter SDS state (with app info and say sleeping) +- require button press to pair + - shrink soft device RAM usage - get nrf52832 working again (currently OOM) - i2c gps comms not quite right diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 454a8bdfd..0b1f2cbf9 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -244,10 +244,16 @@ void PowerFSM_setup() powerFSM.add_timed_transition(&stateON, &stateDARK, getPref_screen_on_secs() * 1000, NULL, "Screen-on timeout"); - powerFSM.add_timed_transition(&stateDARK, &stateNB, getPref_phone_timeout_secs() * 1000, NULL, "Phone timeout"); + // On most boards we use light-sleep to be our main state, but on NRF52 we just stay in DARK + State *lowPowerState = &stateLS; #ifndef NRF52_SERIES - // We never enter light-sleep state on NRF52 (because the CPU uses so little power normally) + // We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally) + + lowPowerState = &stateDARK; + + powerFSM.add_timed_transition(&stateDARK, &stateNB, getPref_phone_timeout_secs() * 1000, NULL, "Phone timeout"); + powerFSM.add_timed_transition(&stateNB, &stateLS, getPref_min_wake_secs() * 1000, NULL, "Min wake timeout"); powerFSM.add_timed_transition(&stateDARK, &stateLS, getPref_wait_bluetooth_secs() * 1000, NULL, "Bluetooth timeout"); @@ -255,9 +261,9 @@ void PowerFSM_setup() auto meshSds = getPref_mesh_sds_timeout_secs(); if (meshSds != UINT32_MAX) - powerFSM.add_timed_transition(&stateLS, &stateSDS, meshSds * 1000, NULL, "mesh timeout"); + powerFSM.add_timed_transition(lowPowerState, &stateSDS, meshSds * 1000, NULL, "mesh timeout"); // removing for now, because some users don't even have phones - // powerFSM.add_timed_transition(&stateLS, &stateSDS, getPref_phone_sds_timeout_sec() * 1000, NULL, "phone + // powerFSM.add_timed_transition(lowPowerState, &stateSDS, getPref_phone_sds_timeout_sec() * 1000, NULL, "phone // timeout"); powerFSM.run_machine(); // run one interation of the state machine, so we run our on enter tasks for the initial DARK state