mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-23 13:34:46 +00:00
Adds a flag to turn the GPS power rail off entirely on tbeam
This commit is contained in:
parent
b1f3e117d1
commit
911083c49d
@ -5,6 +5,7 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "graphics/Screen.h"
|
#include "graphics/Screen.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
#include "GPS.h"
|
||||||
#include <OneButton.h>
|
#include <OneButton.h>
|
||||||
|
|
||||||
namespace concurrency
|
namespace concurrency
|
||||||
@ -159,9 +160,21 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
|
|
||||||
static void userButtonDoublePressed()
|
static void userButtonDoublePressed()
|
||||||
{
|
{
|
||||||
#if defined(USE_EINK) && defined(PIN_EINK_EN)
|
#if defined(USE_EINK) && defined(PIN_EINK_EN)
|
||||||
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(GPS_POWER_TOGGLE)
|
||||||
|
if(gps->gpsPowerflag)
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Flag set to false for gps power\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Flag set to true to restore power\n");
|
||||||
|
}
|
||||||
|
gps->gpsPowerflag = !(gps->gpsPowerflag);
|
||||||
|
doGPSpowersave(gps->gpsPowerflag);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void userButtonMultiPressed()
|
static void userButtonMultiPressed()
|
||||||
|
@ -276,7 +276,6 @@ bool GPS::setup()
|
|||||||
delay(10);
|
delay(10);
|
||||||
digitalWrite(PIN_GPS_RESET, 0);
|
digitalWrite(PIN_GPS_RESET, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setAwake(true); // Wake GPS power before doing any init
|
setAwake(true); // Wake GPS power before doing any init
|
||||||
bool ok = setupGPS();
|
bool ok = setupGPS();
|
||||||
|
|
||||||
|
@ -77,6 +77,8 @@ class GPS : private concurrency::OSThread
|
|||||||
/// Return true if we are connected to a GPS
|
/// Return true if we are connected to a GPS
|
||||||
bool isConnected() const { return hasGPS; }
|
bool isConnected() const { return hasGPS; }
|
||||||
|
|
||||||
|
bool gpsPowerflag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restart our lock attempt - try to get and broadcast a GPS reading ASAP
|
* Restart our lock attempt - try to get and broadcast a GPS reading ASAP
|
||||||
* called after the CPU wakes from light-sleep state
|
* called after the CPU wakes from light-sleep state
|
||||||
@ -128,7 +130,6 @@ class GPS : private concurrency::OSThread
|
|||||||
|
|
||||||
void setNumSatellites(uint8_t n);
|
void setNumSatellites(uint8_t n);
|
||||||
|
|
||||||
private:
|
|
||||||
/// Prepare the GPS for the cpu entering deep or light sleep, expect to be gone for at least 100s of msecs
|
/// Prepare the GPS for the cpu entering deep or light sleep, expect to be gone for at least 100s of msecs
|
||||||
/// always returns 0 to indicate okay to sleep
|
/// always returns 0 to indicate okay to sleep
|
||||||
int prepareSleep(void *unused);
|
int prepareSleep(void *unused);
|
||||||
@ -136,6 +137,7 @@ class GPS : private concurrency::OSThread
|
|||||||
/// Prepare the GPS for the cpu entering deep sleep, expect to be gone for at least 100s of msecs
|
/// Prepare the GPS for the cpu entering deep sleep, expect to be gone for at least 100s of msecs
|
||||||
/// always returns 0 to indicate okay to sleep
|
/// always returns 0 to indicate okay to sleep
|
||||||
int prepareDeepSleep(void *unused);
|
int prepareDeepSleep(void *unused);
|
||||||
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch the GPS into a mode where we are actively looking for a lock, or alternatively switch GPS into a low power mode
|
* Switch the GPS into a mode where we are actively looking for a lock, or alternatively switch GPS into a low power mode
|
||||||
|
@ -167,6 +167,22 @@ static void waitEnterSleep()
|
|||||||
notifySleep.notifyObservers(NULL);
|
notifySleep.notifyObservers(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void doGPSpowersave(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Turning GPS back on\n");
|
||||||
|
gps->forceWake(1);
|
||||||
|
setGPSPower(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Turning off GPS chip\n");
|
||||||
|
notifySleep.notifyObservers(NULL);
|
||||||
|
setGPSPower(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void doDeepSleep(uint64_t msecToWake)
|
void doDeepSleep(uint64_t msecToWake)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Entering deep sleep for %lu seconds\n", msecToWake / 1000);
|
DEBUG_MSG("Entering deep sleep for %lu seconds\n", msecToWake / 1000);
|
||||||
|
@ -13,7 +13,7 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t msecToWake);
|
|||||||
extern esp_sleep_source_t wakeCause;
|
extern esp_sleep_source_t wakeCause;
|
||||||
#endif
|
#endif
|
||||||
void setGPSPower(bool on);
|
void setGPSPower(bool on);
|
||||||
|
void doGPSpowersave(bool on);
|
||||||
// Perform power on init that we do on each wake from deep sleep
|
// Perform power on init that we do on each wake from deep sleep
|
||||||
void initDeepSleep();
|
void initDeepSleep();
|
||||||
|
|
||||||
|
@ -6,4 +6,5 @@ lib_deps =
|
|||||||
${esp32_base.lib_deps}
|
${esp32_base.lib_deps}
|
||||||
build_flags =
|
build_flags =
|
||||||
${esp32_base.build_flags} -D TBEAM_V10 -I variants/tbeam
|
${esp32_base.build_flags} -D TBEAM_V10 -I variants/tbeam
|
||||||
|
;-DGPS_POWER_TOGGLE ;uncomment this line to allow a double press on the user button to turn off gps entirely.
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
|
Loading…
Reference in New Issue
Block a user