Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
context_type.hpp
Go to the documentation of this file.
1#ifndef CONTEXT_TYPE_H
2#define CONTEXT_TYPE_H
3
9#include <cstdint>
10#include <type_traits>
11
13
17#include "src/modes/include/default_config.hpp"
18
19namespace lampda::modes {
20
25template<typename NewLocalMode> static auto context_as(auto& ctx) { return ctx.template context_as<NewLocalMode>(); }
26
28template<typename LocalBasicMode, typename ModeManager> struct ContextTy
29{
32
38 using LocalModeTy = LocalBasicMode;
40 using StateTy = StateTyOf<LocalModeTy>;
41
43 static constexpr bool isMode = is_mode<LocalModeTy>;
44
46 static constexpr bool isModeManager = std::is_same_v<LocalModeTy, ModeManagerTy>;
47 static constexpr bool isGroupManager = false;
48
49 // useful proxies (exposes mode properties)
50 static constexpr bool hasSunsetAnimation = LocalModeTy::hasSunsetAnimation;
51 static constexpr bool hasBrightCallback = LocalModeTy::hasBrightCallback;
52 static constexpr bool hasSystemCallbacks = LocalModeTy::hasSystemCallbacks;
53 static constexpr bool requireUserThread = LocalModeTy::requireUserThread;
54 static constexpr bool hasCustomRamp = LocalModeTy::hasCustomRamp;
55 static constexpr bool hasButtonCustomUI = LocalModeTy::hasButtonCustomUI;
56
57 // more proxies (exposes tables of mode properties)
58 static constexpr auto everySunsetCallback = LocalModeTy::everySunsetCallback;
59 static constexpr auto everyBrightCallback = LocalModeTy::everyBrightCallback;
60 static constexpr auto everySystemCallbacks = LocalModeTy::everySystemCallbacks;
61 static constexpr auto everyRequireUserThread = LocalModeTy::everyRequireUserThread;
62 static constexpr auto everyCustomRamp = LocalModeTy::everyCustomRamp;
63 static constexpr auto everyButtonCustomUI = LocalModeTy::everyButtonCustomUI;
64
65 //
66 // constructors
67 //
68
70 template<typename NewLocalMode> auto LMBD_INLINE context_as()
71 {
73 }
74
76 ContextTy(ModeManagerTy& modeManager) :
77 state {modeManager.template getStateOf<LocalModeTy>()},
78 lamp {modeManager.lamp},
79 modeManager {modeManager}
80 {
81 }
82
83 ContextTy() = delete;
84 ContextTy(const ContextTy&) = delete;
85 ContextTy& operator=(const ContextTy&) = delete;
86
87 //
88 // manager calls
89 //
90
92 auto LMBD_INLINE next_group()
93 {
94 if constexpr (LocalModeTy::isGroupManager)
95 {
96 LocalModeTy::next_group(*this);
97 }
98 else
99 {
100 auto manager = modeManager.get_context();
101 return manager.next_group();
102 }
103 }
104
106 auto LMBD_INLINE next_mode()
107 {
108 if constexpr (LocalModeTy::isModeManager)
109 {
110 LocalModeTy::next_mode(*this);
111 }
112 else
113 {
114 auto manager = modeManager.get_context();
115 return manager.next_mode();
116 }
117 }
118
120 bool LMBD_INLINE jump_to_favorite(uint8_t which_one, bool shouldSaveLastActiveIndex)
121 {
122 if constexpr (LocalModeTy::isModeManager)
123 {
124 return LocalModeTy::jump_to_favorite(*this, which_one, shouldSaveLastActiveIndex);
125 }
126 else
127 {
128 auto manager = modeManager.get_context();
129 return manager.jump_to_favorite(which_one, shouldSaveLastActiveIndex);
130 }
131 }
132
134 bool LMBD_INLINE exit_favorite_group(auto nextActiveIndex)
135 {
136 if constexpr (LocalModeTy::isModeManager)
137 {
138 return LocalModeTy::exit_favorite_group(*this, nextActiveIndex);
139 }
140 else
141 {
142 auto manager = modeManager.get_context();
143 return manager.exit_favorite_group(nextActiveIndex);
144 }
145 }
146
148 auto LMBD_INLINE set_favorite_now(uint8_t which_one = 0)
149 {
150 if constexpr (LocalModeTy::isModeManager)
151 {
152 return LocalModeTy::set_favorite_now(*this, which_one);
153 }
154 else
155 {
156 auto manager = modeManager.get_context();
157 return manager.set_favorite_now(which_one);
158 }
159 }
160
162 auto LMBD_INLINE delete_favorite_now()
163 {
164 if constexpr (LocalModeTy::isModeManager)
165 {
166 return LocalModeTy::delete_favorite_now(*this);
167 }
168 else
169 {
170 auto manager = modeManager.get_context();
171 return manager.delete_favorite_now();
172 }
173 }
174
176 auto LMBD_INLINE handle_scroll_modes(const uint32_t holdDuration)
177 {
178 if constexpr (LocalModeTy::isModeManager)
179 {
180 return LocalModeTy::handle_scroll_modes(*this, holdDuration);
181 }
182 else
183 {
184 auto manager = modeManager.get_context();
185 return manager.handle_scroll_modes(holdDuration);
186 }
187 }
188
190 auto LMBD_INLINE enter_hidden_group(const uint8_t hiddenGroupIndex)
191 {
192 if constexpr (LocalModeTy::isModeManager)
193 {
194 return LocalModeTy::enter_hidden_group(*this, hiddenGroupIndex);
195 }
196 else
197 {
198 auto manager = modeManager.get_context();
199 return manager.enter_hidden_group(hiddenGroupIndex);
200 }
201 }
202
204 auto LMBD_INLINE overlay_animate_ramp(float holdDuration,
205 float stepSize,
206 const colors::PaletteTy& palette,
207 const uint32_t timeout = 0)
208 {
209 if constexpr (LocalModeTy::isModeManager)
210 {
211 return modeManager.overlay_animate_ramp(*this, holdDuration, stepSize, palette, timeout);
212 }
213 else
214 {
215 auto manager = modeManager.get_context();
216 return manager.overlay_animate_ramp(holdDuration, stepSize, palette, timeout);
217 }
218 }
219
221 auto LMBD_INLINE overlay_animate_ramp(uint8_t progress, const colors::PaletteTy& palette, const uint32_t timeout = 0)
222 {
223 if constexpr (LocalModeTy::isModeManager)
224 {
225 return modeManager.overlay_animate_ramp(*this, progress, palette, timeout);
226 }
227 else
228 {
229 auto manager = modeManager.get_context();
230 return manager.overlay_animate_ramp(progress, palette, timeout);
231 }
232 }
233
235 auto LMBD_INLINE get_groups_count() { return modeManager.nbGroupsTotal; }
237 auto LMBD_INLINE get_accessible_groups_count() { return modeManager.nbAccessibleGroups; }
239 auto LMBD_INLINE get_hidden_groups_count() { return modeManager.hiddenGroupCount; }
240
242 auto LMBD_INLINE get_modes_count()
243 {
244 if constexpr (LocalModeTy::isModeManager)
245 {
246 return modeManager.get_modes_count(*this);
247 }
248 else
249 {
250 auto manager = modeManager.get_context();
251 return manager.get_modes_count();
252 }
253 }
254
255 //
256 // getters / setters for activeIndex
257 //
258
260 uint8_t LMBD_INLINE get_active_group(uint8_t maxValueWrap = 255) const
261 {
262 uint8_t groupIndex = modeManager.activeIndex.groupIndex;
263 return (groupIndex + 1) > maxValueWrap ? 0 : groupIndex;
264 }
265
267 uint8_t LMBD_INLINE set_active_group(uint8_t value, uint8_t maxValueWrap = 255)
268 {
269 if (value + 1 > maxValueWrap)
270 value = 0;
271
272 // signal that we are quitting the group
273 quit_group();
274 // enter a new group
275 enter_group(value);
276 return value;
277 }
278
280 uint8_t LMBD_INLINE get_active_mode(uint8_t maxValueWrap = 255) const
281 {
282 uint8_t modeIndex = modeManager.activeIndex.modeIndex;
283 return (modeIndex + 1) > maxValueWrap ? 0 : modeIndex;
284 }
285
287 uint8_t LMBD_INLINE set_active_mode(uint8_t value, uint8_t maxValueWrap = 255)
288 {
289 if (value + 1 > maxValueWrap)
290 value = 0;
291
292 auto manager = modeManager.get_context();
293
294 // cancel any blip
295 // TODO: this should be in quit_mode
296 manager.cancel_blip();
297
298 // if next mode is the same as current one, add a blip to help user differenciate
299 if (modeManager.activeIndex.modeIndex == value)
300 {
301 // This is not complete, there is no group check, so the blip will be visible sometimes on modes with the same
302 // modeIndex in different groups
303
304 // blip to indicate a mode change to the same mode
305 manager.blip(100);
306 }
307
308 // signal that we are quitting the mode
309 modeManager.quit_mode(manager);
310 // switch mode
311 modeManager.activeIndex.modeIndex = value;
312 // signal that we entered a new mode
313 modeManager.enter_mode(manager);
314 return value;
315 }
316
321 uint8_t LMBD_INLINE get_active_custom_ramp() const { return modeManager.activeIndex.rampIndex; }
322
327 uint8_t LMBD_INLINE set_active_custom_ramp(uint8_t value)
328 {
329 modeManager.activeIndex.rampIndex = value;
330 return value;
331 }
332
334 uint8_t LMBD_INLINE get_active_custom_index() const { return modeManager.activeIndex.customIndex; }
335
337 uint8_t LMBD_INLINE set_active_custom_index(uint8_t value)
338 {
339 modeManager.activeIndex.customIndex = value;
340 return value;
341 }
342
343 //
344 // store
345 //
346
348 template<typename Mode> StateTyOf<Mode>& get_state_of_mode() { return modeManager.template getStateOf<Mode>(); }
349
351 template<typename Mode> static constexpr int get_group_id_of_mode()
352 {
353 return details::GroupIdFrom<Mode, typename ModeManagerTy::AllGroupsTy>;
354 }
355
357 template<typename Mode> static constexpr int get_mode_id()
358 {
359 return details::ModeIdFrom<Mode, typename ModeManagerTy::AllGroupsTy, get_group_id_of_mode<Mode>()>;
360 }
361
363 static constexpr int groupId = get_group_id_of_mode<LocalModeTy>();
364
366 static constexpr int modeId = get_mode_id<LocalModeTy>();
367
369 static constexpr auto prefix =
370 (isModeManager ? store::PrefixValues::managerKeys :
371 (isMode ? store::PrefixValues::generalKeys : store::PrefixValues::privateKeys));
372
374 using StoreEnum = StoreEnumOf<LocalModeTy>;
375
377 using LocalStore = store::KeyStore<StoreEnum, groupId, modeId, prefix>;
378
380 static constexpr bool hasStore = not std::is_same_v<StoreEnum, NoStoreHere>;
381
421 template<StoreEnum _key, typename T> struct KeyProxy
422 {
423 static_assert(std::is_same_v<T, std::conditional_t<hasStore, T, NoStoreId>>,
424 "KeyProxy can not be used when no storeId has been defined!");
425
427 static constexpr StoreEnum key = _key;
428
431
433 inline void LMBD_INLINE setValue(T value)
434 {
435 local = value;
436 LocalStore::template setValue<key, T>(value);
437 };
438
440 inline bool LMBD_INLINE getValue() { return LocalStore::template getValue<key, T>(local); }
441
443 inline void LMBD_INLINE getValue(T defVal) { LocalStore::template getValue<key, T>(local, defVal); }
444
446 inline bool LMBD_INLINE hasValue() { return LocalStore::template hasValue<key, T>(); }
447
448 //
449 // private API
450 //
451
453 inline void LMBD_INLINE forceSave() { LocalStore::template setValue<key, T>(local); }
454
455 //
456 // constructors
457 //
458
461
462 KeyProxy() = delete;
463 KeyProxy(const KeyProxy&) = delete;
464 KeyProxy& operator=(const KeyProxy&) = delete;
465
467 ~KeyProxy() { forceSave(); }
468 };
469
471 template<StoreEnum key, typename T = uint32_t>
472 static auto LMBD_INLINE storageFor(LMBD_USED T& local) // requires storeId :)
473 {
474 if constexpr (hasStore)
475 {
476 return KeyProxy<key, T> {local};
477 }
478 else
479 {
480 return NoStoreId {};
481 }
482 }
483
485 template<StoreEnum key, typename T = uint32_t> static bool LMBD_INLINE storageLoadOnly(LMBD_USED T& local)
486 {
487 return LocalStore::template getValue<key, T>(local);
488 }
489
491 template<StoreEnum key, typename T = uint32_t>
492 static void LMBD_INLINE storageLoadOnly(LMBD_USED T& local, const T defaultValue)
493 {
494 LocalStore::template getValue<key, T>(local, defaultValue);
495 }
496
498 template<StoreEnum key, typename T = uint32_t> static void LMBD_INLINE storageSaveOnly(LMBD_USED T& local)
499 {
500 return LocalStore::template setValue<key, T>(local);
501 }
502
503 //
504 // manager config
505 //
506
511 template<ConfigKeys key> void LMBD_INLINE set_config_bool(bool value)
512 {
513 auto ctx = modeManager.get_context();
514 switch (key)
515 {
517 ctx.state.rampHandler.rampSaturates = value;
518 break;
520 ctx.state.clearStripOnModeChange = value;
521 break;
523 ctx.state.rampHandler.animEffect = value;
524 break;
525 default:
526 assert(false && "unsupported config key for booleans!");
527 break;
528 }
529 }
530
535 template<ConfigKeys key> void LMBD_INLINE set_config_u32(uint32_t value)
536 {
537 auto ctx = modeManager.get_context();
538 switch (key)
539 {
541 ctx.state.rampHandler.stepSpeed = value;
542 break;
544 ctx.state.rampHandler.animChoice = value;
545 break;
546 default:
547 assert(false && "unsupported config key for u32!");
548 break;
549 }
550 }
551
552 //
553 // special effects
554 //
555
560 void blip(const uint32_t duration)
561 {
562 auto ctx = modeManager.get_context();
563 // skip the next frames
564 ctx.state.skipNextFrameEffect = ceil(duration / static_cast<float>(ctx.lamp.frameDurationMs));
565 // turn off the output
566 ctx.lamp.blip(duration);
567 }
568
570 void cancel_blip() const
571 {
572 auto ctx = modeManager.get_context();
573 // cancel skip
574 ctx.state.skipNextFrameEffect = 0;
575 ctx.lamp.cancel_blip();
576 }
577
579 bool is_bliping() const
580 {
581 auto ctx = modeManager.get_context();
582 return ctx.lamp.is_bliping();
583 }
584
593 void LMBD_INLINE skipFirstLedsForFrames(uint8_t amount, uint8_t count = 1)
594 {
595 auto ctx = modeManager.get_context();
596 ctx.lamp.config.skipFirstLedsForAmount = amount;
597 ctx.lamp.config.skipFirstLedsForEffect = count;
598 }
599
600 //
601 // Binder for group and mode enter/quit
602 //
603
605 void LMBD_INLINE enter_group(const uint8_t value)
606 {
607 if constexpr (LocalModeTy::isModeManager)
608 {
609 LocalModeTy::enter_group(*this, value);
610 }
611 else
612 {
613 auto& manager = modeManager.get_context();
614 return manager.enter_group(value);
615 }
616 }
617
619 void LMBD_INLINE quit_group()
620 {
621 if constexpr (LocalModeTy::isModeManager)
622 {
623 LocalModeTy::quit_group(*this);
624 }
625 else
626 {
627 auto& manager = modeManager.get_context();
628 return manager.quit_group();
629 }
630 }
631
633 void LMBD_INLINE enter_mode()
634 {
635 if constexpr (LocalModeTy::isModeManager)
636 {
637 LocalModeTy::enter_mode(*this);
638 }
639 else
640 {
641 auto& manager = modeManager.get_context();
642 return manager.enter_mode();
643 }
644 }
645
647 void LMBD_INLINE quit_mode()
648 {
649 if constexpr (LocalModeTy::isModeManager)
650 {
651 LocalModeTy::quit_mode(*this);
652 }
653 else
654 {
655 auto& manager = modeManager.get_context();
656 return manager.quit_mode();
657 }
658 }
659
660 //
661 // quick bindings to \p LocalModeTy
662 //
663
665 void LMBD_INLINE loop() { LocalModeTy::loop(*this); }
666
668 void LMBD_INLINE on_enter_mode()
669 {
670 if (hasStore)
671 {
672 LocalStore::template migrateStoreIfNeeded<LocalModeTy::storeId>();
673 }
674 LocalModeTy::on_enter_mode(*this);
675 }
676
678 void LMBD_INLINE on_exit_mode()
679 {
680 //
681 LocalModeTy::on_exit_mode(*this);
682 }
683
685 void LMBD_INLINE sunset_update(LMBD_USED float progress)
686 {
687 if constexpr (LocalModeTy::hasSunsetAnimation)
688 {
689 LocalModeTy::sunset_update(*this, progress);
690 }
691 }
692
694 void LMBD_INLINE brightness_update(LMBD_USED brightness_t brightness)
695 {
696 if constexpr (LocalModeTy::hasBrightCallback)
697 {
698 LocalModeTy::brightness_update(*this, brightness);
699 }
700 }
701
703 void LMBD_INLINE custom_ramp_update(LMBD_USED uint8_t rampValue, uint32_t timeout = 0)
704 {
705 if constexpr (LocalModeTy::isGroupManager)
706 {
707 LocalModeTy::custom_ramp_update(*this, rampValue, timeout);
708 }
709 else if constexpr (LocalModeTy::hasCustomRamp)
710 {
711 LocalModeTy::custom_ramp_update(*this, rampValue);
712 }
713 }
714
716 bool LMBD_INLINE custom_click(LMBD_USED uint8_t nbClick)
717 {
718 if constexpr (LocalModeTy::hasButtonCustomUI)
719 {
720 return LocalModeTy::custom_click(*this, nbClick);
721 }
722
723 return false;
724 }
725
727 bool LMBD_INLINE custom_hold(LMBD_USED uint8_t nbClickAndHold,
728 LMBD_USED bool isEndOfHoldEvent,
729 LMBD_USED uint32_t holdDuration)
730 {
731 if constexpr (LocalModeTy::hasButtonCustomUI)
732 {
733 return LocalModeTy::custom_hold(*this, nbClickAndHold, isEndOfHoldEvent, holdDuration);
734 }
735
736 return false;
737 }
738
739 void display_favorite_number_ramp(const uint8_t favoriteIndex,
740 const uint8_t maxFavoriteIndex,
741 const bool display = false,
742 const uint32_t timeout = 0)
743 {
744 if constexpr (LocalModeTy::isModeManager)
745 {
746 modeManager.template display_favorite_number_ramp(*this, favoriteIndex, maxFavoriteIndex, display, timeout);
747 }
748 else
749 {
750 auto& manager = modeManager.get_context();
751 manager.display_favorite_number_ramp(favoriteIndex, maxFavoriteIndex, display, timeout);
752 }
753 }
754
755 template<bool displayFavoriteNumber = true>
756 auto set_current_mode_as_favorite(uint8_t favoriteIndex, uint32_t displayTimeout_s = 0)
757 {
758 if constexpr (LocalModeTy::isModeManager)
759 {
760 modeManager.template set_current_mode_as_favorite<displayFavoriteNumber>(*this, favoriteIndex, displayTimeout_s);
761 }
762 else
763 {
764 auto& manager = modeManager.get_context();
765 manager.set_current_mode_as_favorite<displayFavoriteNumber>(favoriteIndex, displayTimeout_s);
766 }
767 }
768
769 auto get_number_of_allowed_favorites()
770 {
771 if constexpr (LocalModeTy::isModeManager)
772 {
773 return modeManager.template get_number_of_allowed_favorites(*this);
774 }
775 else
776 {
777 auto& manager = modeManager.get_context();
778 return manager.get_number_of_allowed_favorites(*this);
779 }
780 }
781
782 template<bool displayFavoriteNumber = true> auto LMBD_INLINE animate_favorite_pick(float holdDuration, float stepSize)
783 {
784 if constexpr (LocalModeTy::isModeManager)
785 {
786 return modeManager.template animate_favorite_pick<displayFavoriteNumber>(*this, holdDuration, stepSize);
787 }
788 else
789 {
790 auto& manager = modeManager.get_context();
791 return manager.template animate_favorite_pick<displayFavoriteNumber>(holdDuration, stepSize);
792 }
793 }
794
795 template<bool displayFavoriteNumber = true>
796 auto LMBD_INLINE animate_favorite_delete(float holdDuration, float stepSize)
797 {
798 if constexpr (LocalModeTy::isModeManager)
799 {
800 return modeManager.template animate_favorite_delete<displayFavoriteNumber>(*this, holdDuration, stepSize);
801 }
802 else
803 {
804 auto& manager = modeManager.get_context();
805 return manager.template animate_favorite_delete<displayFavoriteNumber>(holdDuration, stepSize);
806 }
807 }
808
810 auto LMBD_INLINE get_custom_ramp_default_value() { return LocalModeTy::get_custom_ramp_default_value(*this); }
811
813 void LMBD_INLINE power_on_sequence()
814 {
815 if constexpr (LocalModeTy::hasSystemCallbacks)
816 {
817 LocalModeTy::power_on_sequence(*this);
818 }
819 }
820
822 void LMBD_INLINE power_off_sequence()
823 {
824 if constexpr (LocalModeTy::hasSystemCallbacks)
825 {
826 LocalModeTy::power_off_sequence(*this);
827 }
828 }
829
831 void LMBD_INLINE write_parameters()
832 {
833 if constexpr (LocalModeTy::hasSystemCallbacks)
834 {
835 LocalModeTy::write_parameters(*this);
836 }
837 }
838
840 void LMBD_INLINE read_parameters()
841 {
842 if constexpr (LocalModeTy::hasSystemCallbacks)
843 {
844 LocalModeTy::read_parameters(*this);
845 }
846 }
847
849 bool LMBD_INLINE should_spawn_thread() { return LocalModeTy::requireUserThread; }
850
852 void LMBD_INLINE user_thread()
853 {
854 if constexpr (LocalModeTy::requireUserThread)
855 {
856 LocalModeTy::user_thread(*this);
857 }
858 }
859
860 //
861 // context members for direct access
862 //
863
866
867private:
868 ModeManagerTy& modeManager;
869};
870
871} // namespace lampda::modes
872
873#endif
Filesystem interaction tools.
Define the main led strip interaction object.
AlertManager_t manager
Instanciation of the AlertManager.
Definition: alerts.cpp:29
std::array< uint32_t, 16 > PaletteTy
Palette types.
Definition: palettes.hpp:18
Contains basic interface types to implement custom user modes.
Definition: control_fixed_modes.hpp:12
@ customRampAnimEffect
(bool) Mode uses custom ramp anim. or not?
@ rampSaturates
(bool) Mode saturates on custom ramp, or else wrap?
@ clearStripOnModeChange
(bool) Mode clear strip after reset, or else do nothing?
@ customRampStepSpeedMs
(u32) Mode time step for incrementing custom ramp (ms)
@ customRampAnimChoice
(u32) Which custom ramp anim. to use (rainbow, etc)
static auto context_as(auto &ctx)
Bind provided context to another modes::BasicMode.
Definition: context_type.hpp:25
uint16_t brightness_t
Define the type of the brightness parameters.
Definition: constants.h:147
(store) Binds a local variable of type T to key in storage (with automatic read & save)
Definition: context_type.hpp:422
void LMBD_INLINE getValue(T defVal)
(optional) Read key value, if not found, set local to defVal
Definition: context_type.hpp:443
void LMBD_INLINE setValue(T value)
(optional) Set local to value then write key to store
Definition: context_type.hpp:433
static constexpr StoreEnum key
Enumeration value uniquely identifying where local will be stored.
Definition: context_type.hpp:427
bool LMBD_INLINE getValue()
(optional) Read key from store, return True if local was written
Definition: context_type.hpp:440
T & local
Local variable reference bound to KeyProxy.
Definition: context_type.hpp:430
bool LMBD_INLINE hasValue()
(optional) Return True if key is set in store, False if unknown
Definition: context_type.hpp:446
KeyProxy(T &local)
Use ContextTy::storageFor to construct a KeyProxy bound to local.
Definition: context_type.hpp:460
Local context exposing system features to active BasicMode.
Definition: context_type.hpp:29
static void LMBD_INLINE storageLoadOnly(LMBD_USED T &local, const T defaultValue)
(store) Load key into local if available (single-shot), or load the default value
Definition: context_type.hpp:492
void LMBD_INLINE set_config_bool(bool value)
(setter) Set a configurable boolean to target value
Definition: context_type.hpp:511
void LMBD_INLINE power_on_sequence()
Binds to local BasicMode::power_on_sequence()
Definition: context_type.hpp:813
void LMBD_INLINE brightness_update(LMBD_USED brightness_t brightness)
Binds to local BasicMode::brightness_update()
Definition: context_type.hpp:694
void LMBD_INLINE enter_group(const uint8_t value)
Call when entering a group.
Definition: context_type.hpp:605
void LMBD_INLINE set_config_u32(uint32_t value)
(setter) Set a configurable integer (u32) to target value
Definition: context_type.hpp:535
bool LMBD_INLINE custom_hold(LMBD_USED uint8_t nbClickAndHold, LMBD_USED bool isEndOfHoldEvent, LMBD_USED uint32_t holdDuration)
Binds to local BasicMode::custom_hold()
Definition: context_type.hpp:727
void LMBD_INLINE on_exit_mode()
Binds to local BasicMode::on_exit_mode()
Definition: context_type.hpp:678
void LMBD_INLINE quit_group()
Call when quitting a group.
Definition: context_type.hpp:619
uint8_t LMBD_INLINE get_active_custom_index() const
(getter) Get active custom index (recalled when jumping favorites)
Definition: context_type.hpp:334
static constexpr bool hasStore
(store) True if LocalBasicMode has access to a local key store
Definition: context_type.hpp:380
friend ModeManager
Friend class.
Definition: context_type.hpp:31
uint8_t LMBD_INLINE set_active_custom_ramp(uint8_t value)
(setter) Set active custom ramp value (overrides user choice)
Definition: context_type.hpp:327
void LMBD_INLINE read_parameters()
Binds to local BasicMode::read_parameters()
Definition: context_type.hpp:840
LocalBasicMode LocalModeTy
Type of a local mode.
Definition: context_type.hpp:38
static void LMBD_INLINE storageSaveOnly(LMBD_USED T &local)
(store) Save local into key storage (single-shot)
Definition: context_type.hpp:498
static constexpr int get_mode_id()
Return the.
Definition: context_type.hpp:357
uint8_t LMBD_INLINE get_active_custom_ramp() const
(getter) Get active custom ramp value (as configured by user)
Definition: context_type.hpp:321
void LMBD_INLINE loop()
Binds to local BasicMode::loop()
Definition: context_type.hpp:665
void LMBD_INLINE on_enter_mode()
Binds to local BasicMode::on_enter_mode()
Definition: context_type.hpp:668
uint8_t LMBD_INLINE set_active_mode(uint8_t value, uint8_t maxValueWrap=255)
(setter) Set active mode index (as numbered in local group)
Definition: context_type.hpp:287
void LMBD_INLINE write_parameters()
Binds to local BasicMode::write_parameters()
Definition: context_type.hpp:831
void LMBD_INLINE skipFirstLedsForFrames(uint8_t amount, uint8_t count=1)
Skip the first few LEDs update during several frames.
Definition: context_type.hpp:593
ModeManager ModeManagerTy
Type of the mode manager.
Definition: context_type.hpp:36
bool LMBD_INLINE custom_click(LMBD_USED uint8_t nbClick)
Binds to local BasicMode::custom_click()
Definition: context_type.hpp:716
void cancel_blip() const
Cancel an ongoing blip of the ouput.
Definition: context_type.hpp:570
uint8_t LMBD_INLINE set_active_custom_index(uint8_t value)
(setter) Set active custom index (recalled when jumping favorites)
Definition: context_type.hpp:337
bool is_bliping() const
Return true if the systems is currently bliping the output.
Definition: context_type.hpp:579
void LMBD_INLINE power_off_sequence()
Binds to local BasicMode::power_off_sequence()
Definition: context_type.hpp:822
void LMBD_INLINE quit_mode()
Call when quitting a mode.
Definition: context_type.hpp:647
static auto LMBD_INLINE storageFor(LMBD_USED T &local)
(store) Get storage KeyProxy for key bound to local variable
Definition: context_type.hpp:472
StateTyOf< Mode > & get_state_of_mode()
Return the state of a given mode.
Definition: context_type.hpp:348
void blip(const uint32_t duration)
Turn off the output for a duration.
Definition: context_type.hpp:560
void LMBD_INLINE user_thread()
Binds to local BasicMode::user_thread()
Definition: context_type.hpp:852
uint8_t LMBD_INLINE get_active_mode(uint8_t maxValueWrap=255) const
(getter) Get active mode index (as numbered in local group)
Definition: context_type.hpp:280
StateTyOf< LocalModeTy > StateTy
Type of the State of a local mode.
Definition: context_type.hpp:40
void LMBD_INLINE sunset_update(LMBD_USED float progress)
Binds to local BasicMode::sunset_update()
Definition: context_type.hpp:685
hardware::LampTy & lamp
Interact with the lamp hardware.
Definition: context_type.hpp:864
static bool LMBD_INLINE storageLoadOnly(LMBD_USED T &local)
(store) Load key into local if available (single-shot)
Definition: context_type.hpp:485
void LMBD_INLINE enter_mode()
Call when entering a mode.
Definition: context_type.hpp:633
uint8_t LMBD_INLINE set_active_group(uint8_t value, uint8_t maxValueWrap=255)
(setter) Set active group index
Definition: context_type.hpp:267
auto LMBD_INLINE context_as()
Get the same context, but for another mode, see modes::context_as()
Definition: context_type.hpp:70
uint8_t LMBD_INLINE get_active_group(uint8_t maxValueWrap=255) const
(getter) Get active group index
Definition: context_type.hpp:260
StateTy & state
Interact with the current active mode state.
Definition: context_type.hpp:865
bool LMBD_INLINE should_spawn_thread()
Returns BasicMode::requireUserThread.
Definition: context_type.hpp:849
static constexpr int get_group_id_of_mode()
Return the id of the group containing a target mode, or -1 if it does not exist.
Definition: context_type.hpp:351
auto LMBD_INLINE get_custom_ramp_default_value()
Return the default ramp values for all the modes under this group.
Definition: context_type.hpp:810
void LMBD_INLINE custom_ramp_update(LMBD_USED uint8_t rampValue, uint32_t timeout=0)
Binds to local BasicMode::custom_ramp_update()
Definition: context_type.hpp:703
Main interface between the user and the hardware of the lamp.
Definition: lamp_type.hpp:118
Convertion header to use the text out functions from C code.
Define templated tools to analyze the manager objects.