blink the led very briefly every 5 secs while in light sleep
This commit is contained in:
+6
-2
@@ -2,6 +2,7 @@
|
||||
#include "GPS.h"
|
||||
#include "time.h"
|
||||
#include <sys/time.h>
|
||||
#include "configuration.h"
|
||||
|
||||
// stuff that really should be in in the instance instead...
|
||||
HardwareSerial _serial_gps(GPS_SERIAL_NUM);
|
||||
@@ -12,7 +13,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 = true;
|
||||
bool wantNewLocation = true;
|
||||
|
||||
GPS::GPS() : PeriodicTask()
|
||||
{
|
||||
@@ -98,12 +99,15 @@ void GPS::doTask()
|
||||
while (_serial_gps.available())
|
||||
{
|
||||
encode(_serial_gps.read());
|
||||
// DEBUG_MSG("Got GPS response\n");
|
||||
}
|
||||
|
||||
if (!timeSetFromGPS && time.isValid() && date.isValid())
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
DEBUG_MSG("Got time from GPS\n");
|
||||
|
||||
/* Convert to unix time
|
||||
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
|
||||
*/
|
||||
@@ -137,7 +141,7 @@ void GPS::doTask()
|
||||
setPeriod(hasValidLocation && !wantNewLocation ? 30 * 1000 : 100);
|
||||
}
|
||||
|
||||
void GPS::startLock()
|
||||
void GPS::startLock()
|
||||
{
|
||||
DEBUG_MSG("Looking for GPS lock\n");
|
||||
wantNewLocation = true;
|
||||
|
||||
+20
-4
@@ -43,11 +43,27 @@ static void lsEnter()
|
||||
|
||||
static void lsIdle()
|
||||
{
|
||||
doLightSleep(radioConfig.preferences.ls_secs * 1000LL);
|
||||
|
||||
// FIXME - blink led when we occasionally wake from timer, then go back to light sleep
|
||||
uint32_t secsSlept = 0;
|
||||
esp_sleep_source_t wakeCause = ESP_SLEEP_WAKEUP_UNDEFINED;
|
||||
|
||||
// Regardless of why we woke (for now) just transition to NB
|
||||
while (secsSlept < radioConfig.preferences.ls_secs)
|
||||
{
|
||||
// Briefly come out of sleep long enough to blink the led once every few seconds
|
||||
uint32_t sleepTime = 5;
|
||||
|
||||
setLed(false); // Never leave led on while in light sleep
|
||||
wakeCause = doLightSleep(sleepTime * 1000LL);
|
||||
if (wakeCause != ESP_SLEEP_WAKEUP_TIMER)
|
||||
break;
|
||||
|
||||
setLed(true); // briefly turn on led
|
||||
doLightSleep(1);
|
||||
if (wakeCause != ESP_SLEEP_WAKEUP_TIMER)
|
||||
break;
|
||||
}
|
||||
setLed(false);
|
||||
|
||||
// Regardless of why we woke (for now) just transition to NB (and that state will handle stuff like IRQs etc)
|
||||
powerFSM.trigger(EVENT_WAKE_TIMER);
|
||||
}
|
||||
|
||||
|
||||
@@ -651,13 +651,6 @@ void Screen::doTask()
|
||||
nodeDB.updateGUI = false;
|
||||
nodeDB.updateTextMessage = false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (millis() - lastPressMs > SCREEN_SLEEP_MS)
|
||||
{
|
||||
DEBUG_MSG("screen timeout, turn it off for now...\n");
|
||||
screen.setOn(false);
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -209,11 +209,11 @@ void setBluetoothEnable(bool on)
|
||||
*/
|
||||
esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more reasonable default
|
||||
{
|
||||
DEBUG_MSG("Enter light sleep\n");
|
||||
//DEBUG_MSG("Enter light sleep\n");
|
||||
uint64_t sleepUsec = sleepMsec * 1000LL;
|
||||
|
||||
Serial.flush(); // send all our characters before we stop cpu clock
|
||||
setBluetoothEnable(false); // has to be off before calling light sleep
|
||||
setLed(false); // Never leave led on while in light sleep
|
||||
|
||||
// NOTE! ESP docs say we must disable bluetooth and wifi before light sleep
|
||||
|
||||
@@ -228,7 +228,7 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
|
||||
assert(esp_sleep_enable_gpio_wakeup() == ESP_OK);
|
||||
assert(esp_sleep_enable_timer_wakeup(sleepUsec) == ESP_OK);
|
||||
assert(esp_light_sleep_start() == ESP_OK);
|
||||
DEBUG_MSG("Exit light sleep\n");
|
||||
//DEBUG_MSG("Exit light sleep\n");
|
||||
return esp_sleep_get_wakeup_cause();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user