mirror of
https://github.com/meshtastic/firmware.git
synced 2026-08-02 19:39:01 -04:00
Every other .cpp/.h pair in src/ (350 of 351) uses identical capitalization between the two files. Power.cpp/power.h was the sole outlier; this aligns it with the rest of the codebase. No functional change — all includes already resolved this file the same way on case-sensitive filesystems. Assisted-by: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Andrew Yong <me@ndoo.sg> Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
#include "Default.h"
|
|
#include "NodeDB.h"
|
|
#include "Power.h"
|
|
#include "PowerFSM.h"
|
|
#include "concurrency/OSThread.h"
|
|
#include "configuration.h"
|
|
#include "main.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
|
|
{
|
|
#if !MESHTASTIC_EXCLUDE_POWER_FSM
|
|
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)
|
|
const State *state = powerFSM.getState();
|
|
canSleep = (state != &statePOWER) && (state != &stateSERIAL);
|
|
|
|
if (powerStatus->getHasUSB()) {
|
|
timeLastPowered = millis();
|
|
} else if (config.power.on_battery_shutdown_after_secs > 0 && config.power.on_battery_shutdown_after_secs != UINT32_MAX &&
|
|
millis() > (timeLastPowered +
|
|
Default::getConfiguredOrDefaultMs(
|
|
config.power.on_battery_shutdown_after_secs))) { // shutdown after 30 minutes unpowered
|
|
powerFSM.trigger(EVENT_SHUTDOWN);
|
|
}
|
|
|
|
return 100;
|
|
#else
|
|
return INT32_MAX;
|
|
#endif
|
|
}
|
|
};
|
|
|
|
} // namespace concurrency
|