Skip to content

Commit

Permalink
powermon gps support
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksville committed Jun 21, 2024
1 parent 809e06b commit b2a388b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion protobufs
2 changes: 1 addition & 1 deletion src/PowerMon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void PowerMon::clearState(_meshtastic_PowerMon_State state, const char *reason)
void PowerMon::emitLog(const char *reason)
{
// The nrf52 printf doesn't understand 64 bit ints, so if we ever reach that point this function will need to change.
LOG_INFO("S:PMon:C,0x%08lx,%s\n", (uint32_t)states, reason);
LOG_INFO("S:PM:C,0x%08lx,%s\n", (uint32_t)states, reason);
}

PowerMon *powerMon;
Expand Down
4 changes: 4 additions & 0 deletions src/gps/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Default.h"
#include "GPS.h"
#include "NodeDB.h"
#include "PowerMon.h"
#include "RTC.h"

#include "main.h" // pmu_found
Expand Down Expand Up @@ -799,9 +800,12 @@ void GPS::setGPSPower(bool on, bool standbyOnly, uint32_t sleepTime)
return;

if (on) {
powerMon->setState(meshtastic_PowerMon_State_GPS_Active);
clearBuffer(); // drop any old data waiting in the buffer before re-enabling
if (en_gpio)
digitalWrite(en_gpio, on ? GPS_EN_ACTIVE : !GPS_EN_ACTIVE); // turn this on if defined, every time
} else {
powerMon->clearState(meshtastic_PowerMon_State_GPS_Active);
}
isInPowersave = !on;
if (!standbyOnly && en_gpio != 0 &&
Expand Down
12 changes: 6 additions & 6 deletions src/mesh/generated/meshtastic/powermon.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ typedef enum _meshtastic_PowerMon_State {
meshtastic_PowerMon_State_Screen_On = 256,
meshtastic_PowerMon_State_Screen_Drawing = 512,
meshtastic_PowerMon_State_Wifi_On = 1024,
meshtastic_PowerMon_State_GPS_LowPower = 2048,
meshtastic_PowerMon_State_GPS_MediumPower = 4096,
meshtastic_PowerMon_State_GPS_HighPower = 8192
/* GPS is actively trying to find our location
See GPSPowerState for more details */
meshtastic_PowerMon_State_GPS_Active = 2048
} meshtastic_PowerMon_State;

/* Struct definitions */
/* the log messages will be short and complete (see PowerMon.Event in the protobufs for details).
something like "PwrMon,C,0x00001234,REASON" where the hex number is the bitmask of all current states.
something like "PwrMon:C,0x00001234,REASON" where the hex number is the bitmask of all current states.
(We use a bitmask for states so that if a log message gets lost it won't be fatal) */
typedef struct _meshtastic_PowerMon_Event {
/* Bitwise-OR of States */
Expand All @@ -47,8 +47,8 @@ extern "C" {

/* Helper constants for enums */
#define _meshtastic_PowerMon_State_MIN meshtastic_PowerMon_State_None
#define _meshtastic_PowerMon_State_MAX meshtastic_PowerMon_State_GPS_HighPower
#define _meshtastic_PowerMon_State_ARRAYSIZE ((meshtastic_PowerMon_State)(meshtastic_PowerMon_State_GPS_HighPower+1))
#define _meshtastic_PowerMon_State_MAX meshtastic_PowerMon_State_GPS_Active
#define _meshtastic_PowerMon_State_ARRAYSIZE ((meshtastic_PowerMon_State)(meshtastic_PowerMon_State_GPS_Active+1))



Expand Down

0 comments on commit b2a388b

Please sign in to comment.