forked from meshtastic/firmware
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03033ec
commit b9d2d49
Showing
5 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "PowerMon.h" | ||
|
||
void PowerMon::setState(_meshtastic_PowerMon_State state, const char *reason) {} | ||
void PowerMon::clearState(_meshtastic_PowerMon_State state, const char *reason) {} | ||
|
||
PowerMon *powerMon; | ||
|
||
void powerMonInit() | ||
{ | ||
powerMon = new PowerMon(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
#include "configuration.h" | ||
|
||
#include "meshtastic/powermon.pb.h" | ||
|
||
/** | ||
* The singleton class for monitoring power consumption of device | ||
* subsystems/modes. | ||
* | ||
* For more information see the PowerMon docs. | ||
*/ | ||
class PowerMon | ||
{ | ||
uint64_t states = 0UL; | ||
|
||
public: | ||
PowerMon() {} | ||
|
||
void setState(_meshtastic_PowerMon_State state, const char *reason); | ||
void clearState(_meshtastic_PowerMon_State state, const char *reason); | ||
}; | ||
|
||
extern PowerMon *powerMon; | ||
|
||
void powerMonInit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* Automatically generated nanopb constant definitions */ | ||
/* Generated by nanopb-0.4.8 */ | ||
|
||
#include "meshtastic/powermon.pb.h" | ||
#if PB_PROTO_HEADER_VERSION != 40 | ||
#error Regenerate this file with the current version of nanopb generator. | ||
#endif | ||
|
||
PB_BIND(meshtastic_PowerMon_Event, meshtastic_PowerMon_Event, AUTO) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* Automatically generated nanopb header */ | ||
/* Generated by nanopb-0.4.8 */ | ||
|
||
#ifndef PB_MESHTASTIC_POWERMON_MESHTASTIC_POWERMON_PB_H_INCLUDED | ||
#define PB_MESHTASTIC_POWERMON_MESHTASTIC_POWERMON_PB_H_INCLUDED | ||
#include <pb.h> | ||
|
||
#if PB_PROTO_HEADER_VERSION != 40 | ||
#error Regenerate this file with the current version of nanopb generator. | ||
#endif | ||
|
||
/* Enum definitions */ | ||
/* Any significant power changing event in meshtastic should be tagged with a powermon state transition. | ||
If you are making new meshtastic features feel free to add new entries at the end of this definition. */ | ||
typedef enum _meshtastic_PowerMon_State { | ||
meshtastic_PowerMon_State_None = 0, | ||
meshtastic_PowerMon_State_CPU_DeepSleep = 1, | ||
meshtastic_PowerMon_State_CPU_Sleep = 2, | ||
meshtastic_PowerMon_State_CPU_Awake = 4, | ||
meshtastic_PowerMon_State_Lora_RXOn = 8, | ||
meshtastic_PowerMon_State_Lora_TXOn = 16, | ||
meshtastic_PowerMon_State_Lora_RXActive = 32, | ||
meshtastic_PowerMon_State_BT_On = 64, | ||
meshtastic_PowerMon_State_LED_On = 128, | ||
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 | ||
} 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. | ||
(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 */ | ||
bool has_states; | ||
uint64_t states; | ||
} meshtastic_PowerMon_Event; | ||
|
||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* 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)) | ||
|
||
|
||
|
||
/* Initializer values for message structs */ | ||
#define meshtastic_PowerMon_Event_init_default {false, 0} | ||
#define meshtastic_PowerMon_Event_init_zero {false, 0} | ||
|
||
/* Field tags (for use in manual encoding/decoding) */ | ||
#define meshtastic_PowerMon_Event_states_tag 1 | ||
|
||
/* Struct field encoding specification for nanopb */ | ||
#define meshtastic_PowerMon_Event_FIELDLIST(X, a) \ | ||
X(a, STATIC, OPTIONAL, UINT64, states, 1) | ||
#define meshtastic_PowerMon_Event_CALLBACK NULL | ||
#define meshtastic_PowerMon_Event_DEFAULT NULL | ||
|
||
extern const pb_msgdesc_t meshtastic_PowerMon_Event_msg; | ||
|
||
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ | ||
#define meshtastic_PowerMon_Event_fields &meshtastic_PowerMon_Event_msg | ||
|
||
/* Maximum encoded size of messages (where known) */ | ||
#define MESHTASTIC_POWERMON_MESHTASTIC_POWERMON_PB_H_MAX_SIZE meshtastic_PowerMon_Event_size | ||
#define meshtastic_PowerMon_Event_size 11 | ||
|
||
#ifdef __cplusplus | ||
} /* extern "C" */ | ||
#endif | ||
|
||
#endif |