while not perfect, good enough to move power statemachine to master

This commit is contained in:
geeksville 2020-02-22 14:56:19 -08:00
parent ca37e50362
commit a1a1ceb94d
4 changed files with 16 additions and 15 deletions

View File

@ -41,7 +41,7 @@ off during light sleep, but there is a TODO item to fix this.
* While in LS: Every send_owner_interval (defaults to 4, i.e. one hour), when we wake to send our position we _also_ broadcast our owner. This lets new nodes on the network find out about us or correct duplicate node number assignments.
* While in LS/NB/DARK: If the user presses a button (EVENT_PRESS) we go to full ON mode for screen_on_secs (default 30 seconds). Multiple presses keeps resetting this timeout
* While in LS/NB/DARK: If we receive new text messages (EVENT_RECEIVED_TEXT_MSG), we go to full ON mode for screen_on_secs (same as if user pressed a button)
* While in LS: if we receive packets on the radio (EVENT_RECEIVED_PACKET) we will wake and handle them and stay awake in NB mode for min_wake_secs (default 10 seconds)
* While in LS: while we receive packets on the radio (EVENT_RECEIVED_PACKET) we will wake and handle them and stay awake in NB mode for min_wake_secs (default 10 seconds)
* While in NB: If we do have packets the phone (EVENT_PACKETS_FOR_PHONE) would want we transition to DARK mode for wait_bluetooth secs.
### events that decrease cpu activity
@ -53,6 +53,7 @@ off during light sleep, but there is a TODO item to fix this.
into either LS or SDS levels. If either phone_sds_timeout_secs (default 1 hr) or mesh_sds_timeout_secs (default 1 hr) are exceeded we will lower into SDS mode for sds_secs (default 1 hr) (or a button press). Otherwise we will lower into LS mode for ls_secs (default 1 hr) (or until an interrupt, button press)
TODO: Eventually these scheduled intervals should be synchronized to the GPS clock, so that we can consider leaving the lora receiver off to save even more power.
TODO: In NB mode we should put cpu into light sleep any time we really aren't that busy (without declaring LS state) - i.e. we should leave GPS on etc...
# Low power consumption tasks

View File

@ -12,7 +12,7 @@ RTC_DATA_ATTR bool timeSetFromGPS; // We only reset our time once per _boot_ aft
GPS gps;
bool hasValidLocation; // default to false, until we complete our first read
bool wantNewLocation;
bool wantNewLocation = true;
GPS::GPS() : PeriodicTask()
{
@ -139,6 +139,7 @@ void GPS::doTask()
void GPS::startLock()
{
DEBUG_MSG("Looking for GPS lock\n");
wantNewLocation = true;
setPeriod(1);
}

View File

@ -49,6 +49,16 @@ void NodeDB::init()
devicestate.node_db_count = 0;
devicestate.receive_queue_count = 0;
radioConfig.preferences.send_owner_interval = 4; // per sw-design.md
radioConfig.preferences.position_broadcast_secs = 15 * 60;
radioConfig.preferences.wait_bluetooth_secs = 30;
radioConfig.preferences.screen_on_secs = 30;
radioConfig.preferences.mesh_sds_timeout_secs = 60 * 60;
radioConfig.preferences.phone_sds_timeout_sec = 60 * 60;
radioConfig.preferences.sds_secs = 60 * 60;
radioConfig.preferences.ls_secs = 60 * 60;
radioConfig.preferences.phone_timeout_secs = 15 * 60;
#ifdef GPS_RX_PIN
// some hardware defaults to have a built in GPS
myNodeInfo.has_gps = true;
@ -84,17 +94,6 @@ void NodeDB::init()
loadFromDisk();
DEBUG_MSG("NODENUM=0x%x, dbsize=%d\n", myNodeInfo.my_node_num, *numNodes);
// FIXME - move above
radioConfig.preferences.send_owner_interval = 4; // per sw-design.md
radioConfig.preferences.position_broadcast_secs = 20; // 15 * 60;
radioConfig.preferences.wait_bluetooth_secs = 10; // 30;
radioConfig.preferences.screen_on_secs = 30;
radioConfig.preferences.mesh_sds_timeout_secs = 60 * 60;
radioConfig.preferences.phone_sds_timeout_sec = 60 * 60;
radioConfig.preferences.sds_secs = 60 * 60;
radioConfig.preferences.ls_secs = 60 * 60;
radioConfig.preferences.phone_timeout_secs = 15 * 60;
}
// We reserve a few nodenums for future use

View File

@ -43,8 +43,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Select which board is being used. If the outside build environment has sent a choice, just use that
#if !defined(T_BEAM_V10) && !defined(HELTEC_LORA32)
//#define T_BEAM_V10 // AKA Rev1 (second board released)
#define HELTEC_LORA32
#define T_BEAM_V10 // AKA Rev1 (second board released)
// #define HELTEC_LORA32
#define HW_VERSION_US // We encode the hardware freq range in the hw version string, so sw update can eventually install the correct build
#endif