Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
mode_type.hpp
Go to the documentation of this file.
1#ifndef MODE_TYPE_H
2#define MODE_TYPE_H
3
9#include <cstdint>
10
12namespace lampda::modes {
13
53{
55 static constexpr bool isModeManager = false;
56 static constexpr bool isGroupManager = false;
57
59 struct StateTy
60 {
61 };
62
71 static void loop(auto& ctx) { return; }
72
77 static void on_enter_mode(auto& ctx) { return; }
78
83 static void on_exit_mode(auto& ctx) { return; }
84
86 static constexpr bool hasSunsetAnimation = false;
89 static constexpr bool usesSunsetGravityDissolveMode = false;
90
98 static void sunset_update(auto& ctx, float progress) { return; }
99
101 static constexpr bool hasSunriseAnimation = false;
104 static constexpr bool usesSunriseGravityAppearMode = false;
105
113 static void sunrise_update(auto& ctx, float progress) { return; }
114
116 static constexpr bool hasBrightCallback = false;
117
127 static void brightness_update(auto& ctx, brightness_t brightness) { return; }
128
133 static constexpr bool hasCustomRamp = false;
134
145 static void custom_ramp_update(auto& ctx, uint8_t rampValue) { return; }
146
148 static uint8_t get_custom_ramp_default_value(auto& ctx) { return 128; }
149
151 static constexpr bool hasButtonCustomUI = false;
152
161 static bool custom_click(auto& ctx, uint8_t nbClick) { return false; }
162
174 static bool custom_hold(auto& ctx, uint8_t nbClickAndHold, bool isEndOfHoldEvent, uint32_t holdDuration)
175 {
176 return false;
177 }
178
191 static constexpr bool hasSystemCallbacks = false;
192
200 static void power_on_sequence(auto& ctx) { return; }
201
209 static void power_off_sequence(auto& ctx) { return; }
210
217 static void read_parameters(auto& ctx) { return; }
218
225 static void write_parameters(auto& ctx) { return; }
226
232 static constexpr bool requireUserThread = false;
233
242 static void user_thread(auto& ctx) { return; }
243
286 static constexpr uint32_t storeId = 0;
287
288 // modes shall not implement any constructors
289 BasicMode() = delete;
290 BasicMode(const BasicMode&) = delete;
291 BasicMode& operator=(const BasicMode&) = delete;
292
293 // polyfill (to be ignored in this context)
294 static constexpr bool everySunsetCallback = false;
295 static constexpr bool everySunriseCallback = false;
296 static constexpr bool everyBrightCallback = false;
297 static constexpr bool everySystemCallbacks = false;
298 static constexpr bool everyRequireUserThread = false;
299 static constexpr bool everyCustomRamp = false;
300 static constexpr bool everyButtonCustomUI = false;
301};
302
303} // namespace lampda::modes
304
305#endif
Contains basic interface types to implement custom user modes.
Definition: control_fixed_modes.hpp:14
uint16_t brightness_t
Define the type of the brightness parameters.
Definition: constants.h:151
Mode custom static state, made available through context (optional)
Definition: mode_type.hpp:60
Parent object for all custom user modes.
Definition: mode_type.hpp:53
static void read_parameters(auto &ctx)
Custom callback to read parameters from filesystem (optional)
Definition: mode_type.hpp:217
static constexpr bool hasSystemCallbacks
Toggles advanced system callbacks, see list here .
Definition: mode_type.hpp:191
static void write_parameters(auto &ctx)
Custom callback to write parameters to filesystem (optional)
Definition: mode_type.hpp:225
static bool custom_click(auto &ctx, uint8_t nbClick)
Custom "usermode" button UI for "click" action (optional)
Definition: mode_type.hpp:161
static void user_thread(auto &ctx)
Custom secondary loop, executed in another thread (optional)
Definition: mode_type.hpp:242
static void on_exit_mode(auto &ctx)
Custom callback when mode goes outside of focus (optional)
Definition: mode_type.hpp:83
static constexpr bool hasCustomRamp
Toggles the use of custom ramps & BasicMode::custom_ramp_update()
Definition: mode_type.hpp:133
static constexpr bool usesSunriseGravityAppearMode
If hasSunriseAnimation is true, this can be used to toggle an internal handling that make the current...
Definition: mode_type.hpp:104
static uint8_t get_custom_ramp_default_value(auto &ctx)
Return the custom ramp default value, in case no preset is used.
Definition: mode_type.hpp:148
static constexpr bool hasSunriseAnimation
Toggles the use of custom BasicMode::sunrise_update() callback.
Definition: mode_type.hpp:101
static constexpr uint32_t storeId
Store identifier for persistent storage (optional)
Definition: mode_type.hpp:286
static void brightness_update(auto &ctx, brightness_t brightness)
Custom callback when brightness changes (optional)
Definition: mode_type.hpp:127
static constexpr bool hasButtonCustomUI
Toggles "usermode" button UI custom_click() and custom_hold()
Definition: mode_type.hpp:151
static void on_enter_mode(auto &ctx)
Custom callback when mode gains focus (optional)
Definition: mode_type.hpp:77
static constexpr bool usesSunsetGravityDissolveMode
If hasSunsetAnimation is true, this can be used to toggle an internal handling that dissolve the curr...
Definition: mode_type.hpp:89
static constexpr bool hasSunsetAnimation
Toggles the use of custom BasicMode::sunset_update() callback.
Definition: mode_type.hpp:86
static void sunrise_update(auto &ctx, float progress)
Custom callback when sunrise mode is updated (optional)
Definition: mode_type.hpp:113
static void loop(auto &ctx)
Custom user mode loop function (default)
Definition: mode_type.hpp:71
static constexpr bool hasBrightCallback
Toggles the use of custom BasicMode::brightness_update() callback.
Definition: mode_type.hpp:116
static constexpr bool requireUserThread
Toggles the use of custom BasicMode::user_thread() callback.
Definition: mode_type.hpp:232
static void power_off_sequence(auto &ctx)
Custom callback when the system powers off (optional)
Definition: mode_type.hpp:209
static void power_on_sequence(auto &ctx)
Custom callback when the system powers on (optional)
Definition: mode_type.hpp:200
static bool custom_hold(auto &ctx, uint8_t nbClickAndHold, bool isEndOfHoldEvent, uint32_t holdDuration)
Custom "usermode" button UI for "click+hold" action (optional)
Definition: mode_type.hpp:174
static void sunset_update(auto &ctx, float progress)
Custom callback when sunset mode is updated (optional)
Definition: mode_type.hpp:98
static void custom_ramp_update(auto &ctx, uint8_t rampValue)
Custom callback when system sets user ramp (optional)
Definition: mode_type.hpp:145