Loom_Sleep_Manager class

Submanager to manage sleep functionality.

Base classes

class LoomModule
Abstract root of Loom component modules inheritance hierarchy.

Public types

enum Mode { IDLE, STANDBY, OPENS_LOWPOWER }
Different options available to sleep in.

Protected variables

Loom_Interrupt_Manager* interrupt_manager
Pointer to interrupt_manager instance.
bool use_LED
Whether or not to use LED to indicate wake status.
bool delay_on_wake
Whether to provide delay on wake.
Mode sleep_mode
Which sleep mode to use.
byte power_off_pin
Which pin to use to power board off (requires power board)

CONSTRUCTORS / DESTRUCTOR

Loom_Sleep_Manager(LoomManager* manager, const bool use_LED = true, const bool delay_on_wake = false, const Mode sleep_mode = Mode::STANDBY, const byte power_off_pin = A5)
Sleep Manager module constructor.
Loom_Sleep_Manager(LoomManager* manager, JsonArrayConst p)
Constructor that takes Json Array, extracts args and delegates to regular constructor.
~Loom_Sleep_Manager() defaulted
Destructor.

OPERATION

void package(JsonObject json) override
No package necessary.
auto sleep() -> bool
Put into low power state.

GETTERS

auto get_sleep_mode() const -> Mode
Get the current sleep mode.

SETTERS

void link_interrupt_manager(Loom_Interrupt_Manager* IM)
Set pointer to interrupt manager.
void set_sleep_mode(const Mode mode)
Set the sleep mode to use.

MISCELLANEOUS

void link_device_manager(LoomManager* LM) override
Add pointer back to device manager.
static auto enum_sleep_mode_string(const Mode m) -> const char*
Convert enum of sleep mode to a c-string.

Enum documentation

enum Loom_Sleep_Manager::Mode

Different options available to sleep in.

Enumerators
IDLE

Idle.

STANDBY

Standby.

OPENS_LOWPOWER

OPEnS board to shut board off completely.

Function documentation

Loom_Sleep_Manager::Loom_Sleep_Manager(LoomManager* manager, const bool use_LED = true, const bool delay_on_wake = false, const Mode sleep_mode = Mode::STANDBY, const byte power_off_pin = A5)

Sleep Manager module constructor.

Parameters
manager
use_LED in Bool | <true> | {true, false} | Whether or not to use LED to indicate wake state
delay_on_wake in Bool | <false> | {true, false} | Whether or not to delay upon waking to allow time to open Serial Monitor
sleep_mode in Set(Mode) | <1> | { 0("Idle"), 1("Standby"), 2("Opens Low Power")} | Which Mode to use
power_off_pin in Set(Int) | <10> | {5, 6, 9, 10, 11, 12, 13, 14("A0"), 15("A1"), 16("A2"), 17("A3"), 18("A4"), 19("A5")} | Which pin should be used to power off board

Loom_Sleep_Manager::Loom_Sleep_Manager(LoomManager* manager, JsonArrayConst p)

Constructor that takes Json Array, extracts args and delegates to regular constructor.

Parameters
manager
in The array of constuctor args to expand

void Loom_Sleep_Manager::package(JsonObject json) override

No package necessary.

Implement with empty body.

bool Loom_Sleep_Manager::sleep()

Put into low power state.

Returns Whether or not sleep was successful

On wake, program will continue from where it went to sleep

Mode Loom_Sleep_Manager::get_sleep_mode() const

Get the current sleep mode.

Returns The current sleep mode

void Loom_Sleep_Manager::link_interrupt_manager(Loom_Interrupt_Manager* IM)

Set pointer to interrupt manager.

Parameters
IM in Pointer to an interrupt manager

void Loom_Sleep_Manager::set_sleep_mode(const Mode mode)

Set the sleep mode to use.

Parameters
mode in The Mode to set to

void Loom_Sleep_Manager::link_device_manager(LoomManager* LM) override

Add pointer back to device manager.

Parameters
LM in LoomManager to point to

Generally only called when device manager links module to provide pointer both directions. Derived modules may override this for increased function, such as linking a submanager or RTC module.

static const char* Loom_Sleep_Manager::enum_sleep_mode_string(const Mode m)

Convert enum of sleep mode to a c-string.

Parameters
in Sleep to get string of
Returns C-string of sleep mode

Variable documentation

bool Loom_Sleep_Manager::delay_on_wake protected

Whether to provide delay on wake.

Used to allow user to restart Serial Monitor