mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 18:09:04 +00:00
Merge branch 'meshtastic:master' into router
This commit is contained in:
commit
8eaaf842ab
2
proto
2
proto
@ -1 +1 @@
|
|||||||
Subproject commit 7c49bdad99f53332d17796188fc89fd5c29e0ce3
|
Subproject commit f6ba3722be8a51c3c0c1446bb08e730a0be568e0
|
38
src/PowerFSMThread.h
Normal file
38
src/PowerFSMThread.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include "configuration.h"
|
||||||
|
#include "concurrency/OSThread.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "PowerFSM.h"
|
||||||
|
#include "power.h"
|
||||||
|
#include "NodeDB.h"
|
||||||
|
|
||||||
|
namespace concurrency
|
||||||
|
{
|
||||||
|
/// Wrapper to convert our powerFSM stuff into a 'thread'
|
||||||
|
class PowerFSMThread : public OSThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// callback returns the period for the next callback invocation (or 0 if we should no longer be called)
|
||||||
|
PowerFSMThread() : OSThread("PowerFSM") {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int32_t runOnce() override
|
||||||
|
{
|
||||||
|
powerFSM.run_machine();
|
||||||
|
|
||||||
|
/// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake
|
||||||
|
/// cpu for serial rx - FIXME)
|
||||||
|
auto state = powerFSM.getState();
|
||||||
|
canSleep = (state != &statePOWER) && (state != &stateSERIAL);
|
||||||
|
|
||||||
|
if (powerStatus->getHasUSB()) {
|
||||||
|
timeLastPowered = millis();
|
||||||
|
} else if (radioConfig.preferences.on_battery_shutdown_after_secs > 0 &&
|
||||||
|
millis() > timeLastPowered + (1000 * radioConfig.preferences.on_battery_shutdown_after_secs)) { //shutdown after 30 minutes unpowered
|
||||||
|
powerFSM.trigger(EVENT_SHUTDOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
31
src/main.cpp
31
src/main.cpp
@ -43,8 +43,9 @@
|
|||||||
#include "SX1262Interface.h"
|
#include "SX1262Interface.h"
|
||||||
#include "SX1268Interface.h"
|
#include "SX1268Interface.h"
|
||||||
#include "LLCC68Interface.h"
|
#include "LLCC68Interface.h"
|
||||||
#include "ButtonThread.h"
|
|
||||||
|
|
||||||
|
#include "ButtonThread.h"
|
||||||
|
#include "PowerFSMThread.h"
|
||||||
|
|
||||||
using namespace concurrency;
|
using namespace concurrency;
|
||||||
|
|
||||||
@ -92,34 +93,6 @@ static int32_t ledBlinker()
|
|||||||
|
|
||||||
uint32_t timeLastPowered = 0;
|
uint32_t timeLastPowered = 0;
|
||||||
|
|
||||||
/// Wrapper to convert our powerFSM stuff into a 'thread'
|
|
||||||
class PowerFSMThread : public OSThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// callback returns the period for the next callback invocation (or 0 if we should no longer be called)
|
|
||||||
PowerFSMThread() : OSThread("PowerFSM") {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int32_t runOnce() override
|
|
||||||
{
|
|
||||||
powerFSM.run_machine();
|
|
||||||
|
|
||||||
/// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake
|
|
||||||
/// cpu for serial rx - FIXME)
|
|
||||||
auto state = powerFSM.getState();
|
|
||||||
canSleep = (state != &statePOWER) && (state != &stateSERIAL);
|
|
||||||
|
|
||||||
if (powerStatus->getHasUSB()) {
|
|
||||||
timeLastPowered = millis();
|
|
||||||
} else if (radioConfig.preferences.on_battery_shutdown_after_secs > 0 &&
|
|
||||||
millis() > timeLastPowered + (1000 * radioConfig.preferences.on_battery_shutdown_after_secs)) { //shutdown after 30 minutes unpowered
|
|
||||||
powerFSM.trigger(EVENT_SHUTDOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
bool ButtonThread::shutdown_on_long_stop = false;
|
bool ButtonThread::shutdown_on_long_stop = false;
|
||||||
|
|
||||||
static Periodic *ledPeriodic;
|
static Periodic *ledPeriodic;
|
||||||
|
@ -21,6 +21,8 @@ extern graphics::Screen *screen;
|
|||||||
// Return a human readable string of the form "Meshtastic_ab13"
|
// Return a human readable string of the form "Meshtastic_ab13"
|
||||||
const char *getDeviceName();
|
const char *getDeviceName();
|
||||||
|
|
||||||
|
extern uint32_t timeLastPowered;
|
||||||
|
|
||||||
extern uint32_t rebootAtMsec;
|
extern uint32_t rebootAtMsec;
|
||||||
extern uint32_t shutdownAtMsec;
|
extern uint32_t shutdownAtMsec;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user