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
15#include "src/modes/include/default_config.hpp"
16
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 auto LMBD_INLINE set_favorite_now(uint8_t which_one = 0)
135 {
136 if constexpr (LocalModeTy::isModeManager)
137 {
138 return LocalModeTy::set_favorite_now(*this, which_one);
139 }
140 else
141 {
142 auto manager = modeManager.get_context();
143 return manager.set_favorite_now(which_one);
144 }
145 }
146
148 auto LMBD_INLINE delete_favorite_now()
149 {
150 if constexpr (LocalModeTy::isModeManager)
151 {
152 return LocalModeTy::delete_favorite_now(*this);
153 }
154 else
155 {
156 auto manager = modeManager.get_context();
157 return manager.delete_favorite_now();
158 }
159 }
160
162 auto LMBD_INLINE handle_scroll_modes(const uint32_t holdDuration)
163 {
164 if constexpr (LocalModeTy::isModeManager)
165 {
166 return LocalModeTy::handle_scroll_modes(*this, holdDuration);
167 }
168 else
169 {
170 auto manager = modeManager.get_context();
171 return manager.handle_scroll_modes(holdDuration);
172 }
173 }
174
176 auto LMBD_INLINE enter_hidden_group(const uint8_t hiddenGroupIndex)
177 {
178 if constexpr (LocalModeTy::isModeManager)
179 {
180 return LocalModeTy::enter_hidden_group(*this, hiddenGroupIndex);
181 }
182 else
183 {
184 auto manager = modeManager.get_context();
185 return manager.enter_hidden_group(hiddenGroupIndex);
186 }
187 }
188
190 auto LMBD_INLINE overlay_animate_ramp(float holdDuration,
191 float stepSize,
192 const colors::PaletteTy& palette,
193 const uint32_t timeout = 0)
194 {
195 if constexpr (LocalModeTy::isModeManager)
196 {
197 return modeManager.overlay_animate_ramp(*this, holdDuration, stepSize, palette, timeout);
198 }
199 else
200 {
201 auto manager = modeManager.get_context();
202 return manager.overlay_animate_ramp(holdDuration, stepSize, palette, timeout);
203 }
204 }
205
207 auto LMBD_INLINE overlay_animate_ramp(uint8_t progress, const colors::PaletteTy& palette, const uint32_t timeout = 0)
208 {
209 if constexpr (LocalModeTy::isModeManager)
210 {
211 return modeManager.overlay_animate_ramp(*this, progress, palette, timeout);
212 }
213 else
214 {
215 auto manager = modeManager.get_context();
216 return manager.overlay_animate_ramp(progress, palette, timeout);
217 }
218 }
219
221 auto LMBD_INLINE get_groups_count() { return modeManager.nbGroupsTotal; }
223 auto LMBD_INLINE get_accessible_groups_count() { return modeManager.nbAccessibleGroups; }
225 auto LMBD_INLINE get_hidden_groups_count() { return modeManager.hiddenGroupCount; }
226
228 auto LMBD_INLINE get_modes_count()
229 {
230 if constexpr (LocalModeTy::isModeManager)
231 {
232 return modeManager.get_modes_count(*this);
233 }
234 else
235 {
236 auto manager = modeManager.get_context();
237 return manager.get_modes_count();
238 }
239 }
240
241 //
242 // getters / setters for activeIndex
243 //
244
246 uint8_t LMBD_INLINE get_active_group(uint8_t maxValueWrap = 255) const
247 {
248 uint8_t groupIndex = modeManager.activeIndex.groupIndex;
249 return (groupIndex + 1) > maxValueWrap ? 0 : groupIndex;
250 }
251
253 uint8_t LMBD_INLINE set_active_group(uint8_t value, uint8_t maxValueWrap = 255)
254 {
255 if (value + 1 > maxValueWrap)
256 value = 0;
257
258 // signal that we are quitting the group
259 quit_group();
260 // enter a new group
261 enter_group(value);
262 return value;
263 }
264
266 uint8_t LMBD_INLINE get_active_mode(uint8_t maxValueWrap = 255) const
267 {
268 uint8_t modeIndex = modeManager.activeIndex.modeIndex;
269 return (modeIndex + 1) > maxValueWrap ? 0 : modeIndex;
270 }
271
273 uint8_t LMBD_INLINE set_active_mode(uint8_t value, uint8_t maxValueWrap = 255)
274 {
275 if (value + 1 > maxValueWrap)
276 value = 0;
277
278 auto manager = modeManager.get_context();
279
280 // cancel any blip
281 // TODO: this should be in quit_mode
282 manager.cancel_blip();
283
284 // if next mode is the same as current one, add a blip to help user differenciate
285 if (modeManager.activeIndex.modeIndex == value)
286 {
287 // This is not complete, there is no group check, so the blip will be visible sometimes on modes with the same
288 // modeIndex in different groups
289
290 // blip to indicate a mode change to the same mode
291 manager.blip(100);
292 }
293
294 // signal that we are quitting the mode
295 modeManager.quit_mode(manager);
296 // switch mode
297 modeManager.activeIndex.modeIndex = value;
298 // signal that we entered a new mode
299 modeManager.enter_mode(manager);
300 return value;
301 }
302
307 uint8_t LMBD_INLINE get_active_custom_ramp() const { return modeManager.activeIndex.rampIndex; }
308
313 uint8_t LMBD_INLINE set_active_custom_ramp(uint8_t value)
314 {
315 modeManager.activeIndex.rampIndex = value;
316 return value;
317 }
318
320 uint8_t LMBD_INLINE get_active_custom_index() const { return modeManager.activeIndex.customIndex; }
321
323 uint8_t LMBD_INLINE set_active_custom_index(uint8_t value)
324 {
325 modeManager.activeIndex.customIndex = value;
326 return value;
327 }
328
329 //
330 // store
331 //
332
334 template<typename Mode> StateTyOf<Mode>& get_state_of_mode() { return modeManager.template getStateOf<Mode>(); }
335
337 template<typename Mode> static constexpr int get_group_id_of_mode()
338 {
339 return details::GroupIdFrom<Mode, typename ModeManagerTy::AllGroupsTy>;
340 }
341
343 template<typename Mode> static constexpr int get_mode_id()
344 {
345 return details::ModeIdFrom<Mode, typename ModeManagerTy::AllGroupsTy, get_group_id_of_mode<Mode>()>;
346 }
347
349 static constexpr int groupId = get_group_id_of_mode<LocalModeTy>();
350
352 static constexpr int modeId = get_mode_id<LocalModeTy>();
353
355 static constexpr auto prefix =
356 (isModeManager ? store::PrefixValues::managerKeys :
357 (isMode ? store::PrefixValues::generalKeys : store::PrefixValues::privateKeys));
358
360 using StoreEnum = StoreEnumOf<LocalModeTy>;
361
363 using LocalStore = store::KeyStore<StoreEnum, groupId, modeId, prefix>;
364
366 static constexpr bool hasStore = not std::is_same_v<StoreEnum, NoStoreHere>;
367
407 template<StoreEnum _key, typename T> struct KeyProxy
408 {
409 static_assert(std::is_same_v<T, std::conditional_t<hasStore, T, NoStoreId>>,
410 "KeyProxy can not be used when no storeId has been defined!");
411
413 static constexpr StoreEnum key = _key;
414
417
419 inline void LMBD_INLINE setValue(T value)
420 {
421 local = value;
422 LocalStore::template setValue<key, T>(value);
423 };
424
426 inline bool LMBD_INLINE getValue() { return LocalStore::template getValue<key, T>(local); }
427
429 inline void LMBD_INLINE getValue(T defVal) { LocalStore::template getValue<key, T>(local, defVal); }
430
432 inline bool LMBD_INLINE hasValue() { return LocalStore::template hasValue<key, T>(); }
433
434 //
435 // private API
436 //
437
439 inline void LMBD_INLINE forceSave() { LocalStore::template setValue<key, T>(local); }
440
441 //
442 // constructors
443 //
444
447
448 KeyProxy() = delete;
449 KeyProxy(const KeyProxy&) = delete;
450 KeyProxy& operator=(const KeyProxy&) = delete;
451
453 ~KeyProxy() { forceSave(); }
454 };
455
457 template<StoreEnum key, typename T = uint32_t>
458 static auto LMBD_INLINE storageFor(LMBD_USED T& local) // requires storeId :)
459 {
460 if constexpr (hasStore)
461 {
462 return KeyProxy<key, T> {local};
463 }
464 else
465 {
466 return NoStoreId {};
467 }
468 }
469
471 template<StoreEnum key, typename T = uint32_t> static bool LMBD_INLINE storageLoadOnly(LMBD_USED T& local)
472 {
473 return LocalStore::template getValue<key, T>(local);
474 }
475
477 template<StoreEnum key, typename T = uint32_t> static void LMBD_INLINE storageSaveOnly(LMBD_USED T& local)
478 {
479 return LocalStore::template setValue<key, T>(local);
480 }
481
482 //
483 // manager config
484 //
485
490 template<ConfigKeys key> void LMBD_INLINE set_config_bool(bool value)
491 {
492 auto ctx = modeManager.get_context();
493 switch (key)
494 {
496 ctx.state.rampHandler.rampSaturates = value;
497 break;
499 ctx.state.clearStripOnModeChange = value;
500 break;
502 ctx.state.rampHandler.animEffect = value;
503 break;
504 default:
505 assert(false && "unsupported config key for booleans!");
506 break;
507 }
508 }
509
514 template<ConfigKeys key> void LMBD_INLINE set_config_u32(uint32_t value)
515 {
516 auto ctx = modeManager.get_context();
517 switch (key)
518 {
520 ctx.state.rampHandler.stepSpeed = value;
521 break;
523 ctx.state.rampHandler.animChoice = value;
524 break;
525 default:
526 assert(false && "unsupported config key for u32!");
527 break;
528 }
529 }
530
531 //
532 // special effects
533 //
534
539 void blip(const uint32_t duration)
540 {
541 auto ctx = modeManager.get_context();
542 // skip the next frames
543 ctx.state.skipNextFrameEffect = ceil(duration / static_cast<float>(ctx.lamp.frameDurationMs));
544 // turn off the output
545 ctx.lamp.blip(duration);
546 }
547
549 void cancel_blip() const
550 {
551 auto ctx = modeManager.get_context();
552 // cancel skip
553 ctx.state.skipNextFrameEffect = 0;
554 ctx.lamp.cancel_blip();
555 }
556
558 bool is_bliping() const
559 {
560 auto ctx = modeManager.get_context();
561 return ctx.lamp.is_bliping();
562 }
563
572 void LMBD_INLINE skipFirstLedsForFrames(uint8_t amount, uint8_t count = 1)
573 {
574 auto ctx = modeManager.get_context();
575 ctx.lamp.config.skipFirstLedsForAmount = amount;
576 ctx.lamp.config.skipFirstLedsForEffect = count;
577 }
578
579 //
580 // Binder for group and mode enter/quit
581 //
582
584 void LMBD_INLINE enter_group(const uint8_t value)
585 {
586 if constexpr (LocalModeTy::isModeManager)
587 {
588 LocalModeTy::enter_group(*this, value);
589 }
590 else
591 {
592 auto& manager = modeManager.get_context();
593 return manager.enter_group(value);
594 }
595 }
596
598 void LMBD_INLINE quit_group()
599 {
600 if constexpr (LocalModeTy::isModeManager)
601 {
602 LocalModeTy::quit_group(*this);
603 }
604 else
605 {
606 auto& manager = modeManager.get_context();
607 return manager.quit_group();
608 }
609 }
610
612 void LMBD_INLINE enter_mode()
613 {
614 if constexpr (LocalModeTy::isModeManager)
615 {
616 LocalModeTy::enter_mode(*this);
617 }
618 else
619 {
620 auto& manager = modeManager.get_context();
621 return manager.enter_mode();
622 }
623 }
624
626 void LMBD_INLINE quit_mode()
627 {
628 if constexpr (LocalModeTy::isModeManager)
629 {
630 LocalModeTy::quit_mode(*this);
631 }
632 else
633 {
634 auto& manager = modeManager.get_context();
635 return manager.quit_mode();
636 }
637 }
638
639 //
640 // quick bindings to \p LocalModeTy
641 //
642
644 void LMBD_INLINE loop() { LocalModeTy::loop(*this); }
645
647 void LMBD_INLINE on_enter_mode()
648 {
649 if (hasStore)
650 {
651 LocalStore::template migrateStoreIfNeeded<LocalModeTy::storeId>();
652 }
653 LocalModeTy::on_enter_mode(*this);
654 }
655
657 void LMBD_INLINE on_exit_mode()
658 {
659 //
660 LocalModeTy::on_exit_mode(*this);
661 }
662
664 void LMBD_INLINE sunset_update(LMBD_USED float progress)
665 {
666 if constexpr (LocalModeTy::hasSunsetAnimation)
667 {
668 LocalModeTy::sunset_update(*this, progress);
669 }
670 }
671
673 void LMBD_INLINE brightness_update(LMBD_USED brightness_t brightness)
674 {
675 if constexpr (LocalModeTy::hasBrightCallback)
676 {
677 LocalModeTy::brightness_update(*this, brightness);
678 }
679 }
680
682 void LMBD_INLINE custom_ramp_update(LMBD_USED uint8_t rampValue, uint32_t timeout = 0)
683 {
684 if constexpr (LocalModeTy::isGroupManager)
685 {
686 LocalModeTy::custom_ramp_update(*this, rampValue, timeout);
687 }
688 else if constexpr (LocalModeTy::hasCustomRamp)
689 {
690 LocalModeTy::custom_ramp_update(*this, rampValue);
691 }
692 }
693
695 bool LMBD_INLINE custom_click(LMBD_USED uint8_t nbClick)
696 {
697 if constexpr (LocalModeTy::hasButtonCustomUI)
698 {
699 return LocalModeTy::custom_click(*this, nbClick);
700 }
701
702 return false;
703 }
704
706 bool LMBD_INLINE custom_hold(LMBD_USED uint8_t nbClickAndHold,
707 LMBD_USED bool isEndOfHoldEvent,
708 LMBD_USED uint32_t holdDuration)
709 {
710 if constexpr (LocalModeTy::hasButtonCustomUI)
711 {
712 return LocalModeTy::custom_hold(*this, nbClickAndHold, isEndOfHoldEvent, holdDuration);
713 }
714
715 return false;
716 }
717
718 template<bool displayFavoriteNumber = true> auto LMBD_INLINE animate_favorite_pick(float holdDuration, float stepSize)
719 {
720 if constexpr (LocalModeTy::isModeManager)
721 {
722 return modeManager.template animate_favorite_pick<displayFavoriteNumber>(*this, holdDuration, stepSize);
723 }
724 else
725 {
726 auto& manager = modeManager.get_context();
727 return manager.template animate_favorite_pick<displayFavoriteNumber>(holdDuration, stepSize);
728 }
729 }
730
731 template<bool displayFavoriteNumber = true>
732 auto LMBD_INLINE animate_favorite_delete(float holdDuration, float stepSize)
733 {
734 if constexpr (LocalModeTy::isModeManager)
735 {
736 return modeManager.template animate_favorite_delete<displayFavoriteNumber>(*this, holdDuration, stepSize);
737 }
738 else
739 {
740 auto& manager = modeManager.get_context();
741 return manager.template animate_favorite_delete<displayFavoriteNumber>(holdDuration, stepSize);
742 }
743 }
744
746 void LMBD_INLINE power_on_sequence()
747 {
748 if constexpr (LocalModeTy::hasSystemCallbacks)
749 {
750 LocalModeTy::power_on_sequence(*this);
751 }
752 }
753
755 void LMBD_INLINE power_off_sequence()
756 {
757 if constexpr (LocalModeTy::hasSystemCallbacks)
758 {
759 LocalModeTy::power_off_sequence(*this);
760 }
761 }
762
764 void LMBD_INLINE write_parameters()
765 {
766 if constexpr (LocalModeTy::hasSystemCallbacks)
767 {
768 LocalModeTy::write_parameters(*this);
769 }
770 }
771
773 void LMBD_INLINE read_parameters()
774 {
775 if constexpr (LocalModeTy::hasSystemCallbacks)
776 {
777 LocalModeTy::read_parameters(*this);
778 }
779 }
780
782 bool LMBD_INLINE should_spawn_thread() { return LocalModeTy::requireUserThread; }
783
785 void LMBD_INLINE user_thread()
786 {
787 if constexpr (LocalModeTy::requireUserThread)
788 {
789 LocalModeTy::user_thread(*this);
790 }
791 }
792
793 //
794 // context members for direct access
795 //
796
799
800private:
801 ModeManagerTy& modeManager;
802};
803
804} // namespace lampda::modes
805
806#endif
Filesystem interaction tools.
Define the main led strip interaction object.
AlertManager_t manager
Instanciation of the AlertManager.
Definition: alerts.cpp:27
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
Interface for the platform specific debug and prints.
(store) Binds a local variable of type T to key in storage (with automatic read & save)
Definition: context_type.hpp:408
void LMBD_INLINE getValue(T defVal)
(optional) Read key value, if not found, set local to defVal
Definition: context_type.hpp:429
void LMBD_INLINE setValue(T value)
(optional) Set local to value then write key to store
Definition: context_type.hpp:419
static constexpr StoreEnum key
Enumeration value uniquely identifying where local will be stored.
Definition: context_type.hpp:413
bool LMBD_INLINE getValue()
(optional) Read key from store, return True if local was written
Definition: context_type.hpp:426
T & local
Local variable reference bound to KeyProxy.
Definition: context_type.hpp:416
bool LMBD_INLINE hasValue()
(optional) Return True if key is set in store, False if unknown
Definition: context_type.hpp:432
KeyProxy(T &local)
Use ContextTy::storageFor to construct a KeyProxy bound to local.
Definition: context_type.hpp:446
Local context exposing system features to active BasicMode.
Definition: context_type.hpp:29
void LMBD_INLINE set_config_bool(bool value)
(setter) Set a configurable boolean to target value
Definition: context_type.hpp:490
void LMBD_INLINE power_on_sequence()
Binds to local BasicMode::power_on_sequence()
Definition: context_type.hpp:746
void LMBD_INLINE brightness_update(LMBD_USED brightness_t brightness)
Binds to local BasicMode::brightness_update()
Definition: context_type.hpp:673
void LMBD_INLINE enter_group(const uint8_t value)
Call when entering a group.
Definition: context_type.hpp:584
void LMBD_INLINE set_config_u32(uint32_t value)
(setter) Set a configurable integer (u32) to target value
Definition: context_type.hpp:514
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:706
void LMBD_INLINE on_exit_mode()
Binds to local BasicMode::on_exit_mode()
Definition: context_type.hpp:657
void LMBD_INLINE quit_group()
Call when quitting a group.
Definition: context_type.hpp:598
uint8_t LMBD_INLINE get_active_custom_index() const
(getter) Get active custom index (recalled when jumping favorites)
Definition: context_type.hpp:320
static constexpr bool hasStore
(store) True if LocalBasicMode has access to a local key store
Definition: context_type.hpp:366
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:313
void LMBD_INLINE read_parameters()
Binds to local BasicMode::read_parameters()
Definition: context_type.hpp:773
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:477
static constexpr int get_mode_id()
Return the.
Definition: context_type.hpp:343
uint8_t LMBD_INLINE get_active_custom_ramp() const
(getter) Get active custom ramp value (as configured by user)
Definition: context_type.hpp:307
void LMBD_INLINE loop()
Binds to local BasicMode::loop()
Definition: context_type.hpp:644
void LMBD_INLINE on_enter_mode()
Binds to local BasicMode::on_enter_mode()
Definition: context_type.hpp:647
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:273
void LMBD_INLINE write_parameters()
Binds to local BasicMode::write_parameters()
Definition: context_type.hpp:764
void LMBD_INLINE skipFirstLedsForFrames(uint8_t amount, uint8_t count=1)
Skip the first few LEDs update during several frames.
Definition: context_type.hpp:572
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:695
void cancel_blip() const
Cancel an ongoing blip of the ouput.
Definition: context_type.hpp:549
uint8_t LMBD_INLINE set_active_custom_index(uint8_t value)
(setter) Set active custom index (recalled when jumping favorites)
Definition: context_type.hpp:323
bool is_bliping() const
Return true if the systems is currently bliping the output.
Definition: context_type.hpp:558
void LMBD_INLINE power_off_sequence()
Binds to local BasicMode::power_off_sequence()
Definition: context_type.hpp:755
void LMBD_INLINE quit_mode()
Call when quitting a mode.
Definition: context_type.hpp:626
static auto LMBD_INLINE storageFor(LMBD_USED T &local)
(store) Get storage KeyProxy for key bound to local variable
Definition: context_type.hpp:458
StateTyOf< Mode > & get_state_of_mode()
Return the state of a given mode.
Definition: context_type.hpp:334
void blip(const uint32_t duration)
Turn off the output for a duration.
Definition: context_type.hpp:539
void LMBD_INLINE user_thread()
Binds to local BasicMode::user_thread()
Definition: context_type.hpp:785
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:266
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:664
hardware::LampTy & lamp
Interact with the lamp hardware.
Definition: context_type.hpp:797
static bool LMBD_INLINE storageLoadOnly(LMBD_USED T &local)
(store) Load key into local if available (single-shot)
Definition: context_type.hpp:471
void LMBD_INLINE enter_mode()
Call when entering a mode.
Definition: context_type.hpp:612
uint8_t LMBD_INLINE set_active_group(uint8_t value, uint8_t maxValueWrap=255)
(setter) Set active group index
Definition: context_type.hpp:253
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:246
StateTy & state
Interact with the current active mode state.
Definition: context_type.hpp:798
bool LMBD_INLINE should_spawn_thread()
Returns BasicMode::requireUserThread.
Definition: context_type.hpp:782
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:337
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:682
Main interface between the user and the hardware of the lamp.
Definition: lamp_type.hpp:114
Define templated tools to analyze the manager objects.