Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Namespaces | Typedefs | Functions | Variables
lampda::user Namespace Reference

Contains code handling custom user mode functions for indexable strips. More...

Namespaces

namespace  custom
 Custom user mode groups.
 
namespace  default_behaviors
 Define default behavior that are shared between system types.
 

Typedefs

using ManagerTy = modes::ManagerForHiddenGroups< #ifdef NUDZ_MODES_ENABLED 1, #else 2, #endif modes::FixedModes, modes::legacy::CalmModes, modes::legacy::PartyModes, modes::legacy::SoundModes, custom::NudzModes, modes::bluetooth::BluetoothModes >
 

Functions

bool button_clicked_default (const uint8_t clicks)
 Called to handle button click events for default user mode behaviors.
 
bool button_hold_default (const uint8_t nbClickAndHold, const bool isEndOfHoldEvent, const uint32_t holdDuration)
 Called to handle button click+hold events for user mode behaviors.
 
void power_on_sequence ()
 Called when the system powers on (must be non blocking function!)
 
void power_off_sequence ()
 Called when the system powers off (must be non blocking function!)
 
void brightness_update (const lampda::brightness_t brightness)
 Called when the system changes the LED strip brightness.
 
void write_parameters ()
 Called when system wants to write parameters to filesystem.
 
void read_parameters ()
 Called when system wants to read parameters from filesystem.
 
bool button_start_click_default (const uint8_t clicks)
 Called to handle button click on lamp start.
 
bool button_start_hold_default (const uint8_t clicks, const bool isEndOfHoldEvent, const uint32_t holdDuration)
 Called to handle button hold on lamp start.
 
bool button_clicked_usermode (const uint8_t nbClick)
 Called to handle button click events if "usermode UI" is active.
 
bool button_hold_usermode (const uint8_t nbClickAndHold, const bool isEndOfHoldEvent, const uint32_t holdDuration)
 Called to handle button click+hold events if "usermode UI" is on.
 
void loop ()
 Called at each tick of the main loop.
 
bool should_spawn_thread ()
 Determine if a second user_thread() loop thread should be spawned.
 
void user_thread ()
 Called at each tick of the secondary thread.
 
void handle_user_command (const common::UserCommand &setCommand)
 Handle user command.
 
void set_color (const uint8_t color)
 
static auto get_context ()
 
static auto get_context ()
 

Variables

constexpr uint8_t minBrightness = 13
 
static hal::gpio::DigitalPin WhiteColorPin (hal::gpio::DigitalPin::GPIO::gpio6)
 
static hal::gpio::DigitalPin YellowColorPin (hal::gpio::DigitalPin::GPIO::gpio7)
 
constexpr uint32_t colorKey = utils::hash("color")
 
uint8_t currentColor = 0
 
uint8_t lastColor = 0
 
static uint8_t currentBrightness = 0
 

Detailed Description

Contains code handling custom user mode functions for indexable strips.

Add the nudz mode the compilation.

Function Documentation

◆ brightness_update()

void lampda::user::brightness_update ( const brightness_t  brightness)

Called when the system changes the LED strip brightness.

Parameters
[in]brightnessThe brightness value set by the system
Remarks
Use update_brightness() to change brightness in order for brightness_update() to be correctly called on brightness change

◆ button_clicked_default()

bool lampda::user::button_clicked_default ( const uint8_t  clicks)

Called to handle button click events for default user mode behaviors.

Parameters
[in]clicksThe number of clicks made by the user
Returns
True if an action was handled

◆ button_clicked_usermode()

bool lampda::user::button_clicked_usermode ( const uint8_t  nbClick)

Called to handle button click events if "usermode UI" is active.

Parameters
[in]nbClickThe number of clicks made by the user
Returns
Should return True if default UI action should be prevented
Remarks
Handler should return False, except if a custom action has been performed, or else the lamp may appear unresponsive to the user

◆ button_hold_default()

bool lampda::user::button_hold_default ( const uint8_t  nbClickAndHold,
const bool  isEndOfHoldEvent,
const uint32_t  holdDuration 
)

Called to handle button click+hold events for user mode behaviors.

Default behavior is the "default UI" navigation mode, that supports:

Event 1H/2H (brightness) is handled by button_hold_callback() in inputs.h

Parameters
[in]nbClickAndHoldThe number of clicks made by the user
[in]isEndOfHoldEventTrue if the user just released the button
[in]holdDurationThe duration of the on-going held event
Remarks
When isEndOfHoldEvent is True, then holdDuration is zero
Returns
True if an action was handled

Keep track of the lock click event

Keep track of the lock click event

◆ button_hold_usermode()

bool lampda::user::button_hold_usermode ( const uint8_t  nbClickAndHold,
const bool  isEndOfHoldEvent,
const uint32_t  holdDuration 
)

Called to handle button click+hold events if "usermode UI" is on.

Parameters
[in]nbClickAndHoldThe number of clicks made by the user
[in]isEndOfHoldEventTrue if the user just released the button
[in]holdDurationThe duration of the on-going hold event
Returns
Should return True if default UI action should be prevented
Remarks
When isEndOfHoldEvent is True, then holdDuration is zero

◆ button_start_click_default()

bool lampda::user::button_start_click_default ( const uint8_t  clicks)

Called to handle button click on lamp start.

Parameters
[in]clicksThe number of clicks made by the user

◆ button_start_hold_default()

bool lampda::user::button_start_hold_default ( const uint8_t  clicks,
const bool  isEndOfHoldEvent,
const uint32_t  holdDuration 
)

Called to handle button hold on lamp start.

Parameters
[in]clicksThe number of clicks made by the user
[in]isEndOfHoldEventTrue if the user just released the button
[in]holdDurationThe duration of the on-going held event
Remarks
When isEndOfHoldEvent is True, then holdDuration is zero

◆ handle_user_command()

void lampda::user::handle_user_command ( const common::UserCommand &  setCommand)

Handle user command.

Parameters
[in]setCommandThe command to handle

◆ loop()

void lampda::user::loop ( )

Called at each tick of the main loop.

By default, dispatched to modes::BasicMode::loop()

◆ should_spawn_thread()

bool lampda::user::should_spawn_thread ( )

Determine if a second user_thread() loop thread should be spawned.

Returns
Return True if user_thread() shall be executed in another thread

The thread is needed to update the strip, so non negociable.

◆ user_thread()

void lampda::user::user_thread ( )

Called at each tick of the secondary thread.

Remarks
This loop is only if should_spawn_thread() returned True when the system probed it to check if it needed a secondary thread