Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Classes | Static Public Member Functions | Static Public Attributes | List of all members
MyCustomMode Struct Reference
Inheritance diagram for MyCustomMode:
lampda::modes::BasicMode

Classes

struct  StateTy
 

Static Public Member Functions

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 brightness_update (auto &ctx, brightness_t brightness)
 
static void custom_ramp_update (auto &ctx, uint8_t rampValue)
 
static bool custom_click (auto &ctx, uint8_t nbClick)
 
static bool custom_hold (auto &ctx, uint8_t nbClickAndHold, bool isEndOfHoldEvent, uint32_t holdDuration)
 
static void power_on_sequence (auto &ctx)
 
static void power_off_sequence (auto &ctx)
 
static void read_parameters (auto &ctx)
 
static void write_parameters (auto &ctx)
 
static void user_thread (auto &ctx)
 
static void brightness_update (auto &ctx, brightness_t brightness)
 Custom callback when brightness changes (optional)
 

Static Public Attributes

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
 
static constexpr bool isGroupManager = false
 
static constexpr bool hasSunsetAnimation = false
 Toggles the use of custom BasicMode::sunset_update() callback.
 
static constexpr uint32_t storeId = 0
 Store identifier for persistent storage (optional)
 

Member Function Documentation

◆ brightness_update()

static void lampda::modes::BasicMode::brightness_update ( auto &  ctx,
brightness_t  brightness 
)
inlinestaticinherited

Custom callback when brightness changes (optional)

Callback active only if BasicMode::hasBrightCallback is True

Parameters
[in]ctxThe current context
[in]brightnessThe brightness value set by the system
Remarks
Use update_brightness() to change brightness in order for this callback to be correctly handled at runtime

Member Data Documentation

◆ storeId

constexpr uint32_t lampda::modes::BasicMode::storeId = 0
staticconstexprinherited

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();
// ... (use rampValue to pick a color or something) ...
}
static constexpr bool hasCustomRamp = true; // required

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();
// ... (use indexValue to change how something works) ...
// at some point, indexValue is modified:
indexValue += 1;
ctx.set_active_custom_index(indexValue);
// next time mode is enabled, or saved as favorite, both custom
// values (rampValue, indexValue) are remembered by default
}
static constexpr bool hasCustomRamp = true; // also required

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 :)


The documentation for this struct was generated from the following file: