|
| static void | loop (auto &ctx) |
| | Custom user mode loop function (default)
|
| |
| static void | on_enter_mode (auto &ctx) |
| | Custom callback when mode gains focus (optional)
|
| |
| static void | on_exit_mode (auto &ctx) |
| | Custom callback when mode goes outside of focus (optional)
|
| |
| static void | sunset_update (auto &ctx, float progress) |
| | Custom callback when sunset mode is updated (optional)
|
| |
| static void | brightness_update (auto &ctx, brightness_t brightness) |
| | Custom callback when brightness changes (optional)
|
| |
| static void | custom_ramp_update (auto &ctx, uint8_t rampValue) |
| | Custom callback when system sets user ramp (optional)
|
| |
| static bool | custom_click (auto &ctx, uint8_t nbClick) |
| | Custom "usermode" button UI for "click" action (optional)
|
| |
| static bool | custom_hold (auto &ctx, uint8_t nbClickAndHold, bool isEndOfHoldEvent, uint32_t holdDuration) |
| | Custom "usermode" button UI for "click+hold" action (optional)
|
| |
| static void | power_on_sequence (auto &ctx) |
| | Custom callback when the system powers on (optional)
|
| |
| static void | power_off_sequence (auto &ctx) |
| | Custom callback when the system powers off (optional)
|
| |
| static void | read_parameters (auto &ctx) |
| | Custom callback to read parameters from filesystem (optional)
|
| |
| static void | write_parameters (auto &ctx) |
| | Custom callback to write parameters to filesystem (optional)
|
| |
| static void | user_thread (auto &ctx) |
| | Custom secondary loop, executed in another thread (optional)
|
| |
Parent object for all custom user modes.
Implement a custom user mode as follow:
static void loop(auto& ctx) {
ctx.lamp.setBrightness(200);
}
};
Definition: my_custom_mode.hpp:5
Parent object for all custom user modes.
Definition: mode_type.hpp:53
Once defined, you can enable the mode by adding it to indexable_functions.cpp :
ModeB,
...>,
Mode2>
>;
GroupTy< std::tuple< Modes... > > GroupFor
Group together many different modes::BasicMode.
Definition: group_type.hpp:335
ModeManagerTy< DefaultManagerConfig, std::tuple< Groups... >, 0 > ManagerFor
Group together several mode groups defined through modes::GroupFor.
Definition: manager_type.hpp:1159
You can start from the mode template below where you will need to remove the unused callbacks:
#ifndef MY_CUSTOM_MODE_H
#define MY_CUSTOM_MODE_H
{
static void loop(auto& ctx) {}
static void on_enter_mode(auto& ctx) {}
static void on_exit_mode(auto& ctx) {}
static void sunset_update(auto& ctx, float progress) {}
static void custom_ramp_update(auto& ctx, uint8_t rampValue) {}
static bool custom_click(auto& ctx, uint8_t nbClick) { return false; }
static bool custom_hold(auto& ctx, uint8_t nbClickAndHold, bool isEndOfHoldEvent, uint32_t holdDuration)
{
return false;
}
struct StateTy
{
};
static constexpr bool hasBrightCallback = false;
static constexpr bool hasCustomRamp = false;
static constexpr bool hasButtonCustomUI = false;
static constexpr bool hasSystemCallbacks = false;
static constexpr bool requireUserThread = false;
};
#endif
void brightness_update(const brightness_t brightness)
Called when the system changes the LED strip brightness.
Definition: default_behavior.hpp:56
void user_thread()
Called at each tick of the secondary thread.
Definition: default_behavior.hpp:159
void read_parameters()
Called when system wants to read parameters from filesystem.
Definition: default_behavior.hpp:93
void power_on_sequence()
Called when the system powers on (must be non blocking function!)
Definition: default_behavior.hpp:31
void write_parameters()
Called when system wants to write parameters to filesystem.
Definition: default_behavior.hpp:87
void power_off_sequence()
Called when the system powers off (must be non blocking function!)
Definition: default_behavior.hpp:42
Further examples of modes are available in src/modes/default
| constexpr uint32_t lampda::modes::BasicMode::storeId = 0 |
|
staticconstexpr |
Store identifier for persistent storage (optional)
By default, all modes are reset upon a shutdown, providing no persistence of their state across several on/off cycles. To expose to the user a way to configure your mode in a persistent fashion, you can use:
static void loop(
auto& ctx) {
uint8_t rampValue = ctx.get_active_custom_ramp();
}
static constexpr bool hasCustomRamp
Toggles the use of custom ramps & BasicMode::custom_ramp_update()
Definition: mode_type.hpp:115
static void loop(auto &ctx)
Custom user mode loop function (default)
Definition: mode_type.hpp:71
This value is configurable through user interaction with the button. If you need a persistent value, private to your mode, you can use:
static void loop(
auto& ctx) {
uint8_t indexValue = ctx.get_active_custom_index();
indexValue += 1;
ctx.set_active_custom_index(indexValue);
}
These are the two always-available persistent state that a mode can configure by default. However, for more advanced modes (like games, with a list of high-scores, for example) more flexibility can be required.
If you need such extended storage, see ContextTy::KeyProxy for usage.
If you don't need these capabilities, just ignore this identifier :)