23#include "src/modes/include/default_config.hpp"
47 static auto from(
const uint8_t* arr)
49 ActiveIndexTy index = {arr[0], arr[1], arr[2], arr[3]};
55template<
typename Config>
struct RampHandlerTy
57 using ConfigTy = Config;
58 static constexpr uint32_t startPeriod = Config::rampStartPeriodMs;
62 RampHandlerTy(uint32_t stepSpeed,
bool rampSaturates = Config::defaultRampSaturates) :
63 stepSpeed {stepSpeed},
65 lastTimeMeasured {1000},
67 animEffect {Config::defaultCustomRampAnimEffect},
68 animChoice {Config::defaultCustomRampAnimChoice}
72 void LMBD_INLINE reset()
75 stepSpeed = Config::defaultCustomRampStepSpeedMs;
77 animEffect = Config::defaultCustomRampAnimEffect;
78 animChoice = Config::defaultCustomRampAnimChoice;
81 void LMBD_INLINE update_ramp(uint8_t rampValue, uint32_t holdTime,
auto callback)
84 if (holdTime < lastTimeMeasured)
86 lastTimeMeasured = holdTime;
88 if (holdTime < startPeriod)
91 isForward = !isForward;
104 uint32_t lastCounter = lastTimeMeasured / stepSpeed;
105 uint32_t nextCounter = holdTime / stepSpeed;
106 if (nextCounter <= lastCounter)
110 for (uint32_t I = 0; I < nextCounter - lastCounter; ++I)
113 if (isForward && (!rampSaturates || rampValue < 255))
117 if (!isForward && (!rampSaturates || rampValue > 0))
124 lastTimeMeasured = holdTime;
131 uint32_t lastTimeMeasured;
138template<
typename Config,
typename AllGroups, u
int8_t h
iddenGroupsCount>
struct ModeManagerTy
140 using SelfTy = ModeManagerTy<Config, AllGroups, hiddenGroupsCount>;
141 using ConfigTy = Config;
142 using AllGroupsTy = AllGroups;
143 using AllStatesTy = details::StateTyFrom<AllGroups>;
146 static constexpr uint8_t nbGroupsTotal {std::tuple_size_v<AllGroupsTy>};
147 static constexpr uint8_t hiddenGroupCount = hiddenGroupsCount;
149 static_assert(nbGroupsTotal >= hiddenGroupsCount,
"Manager cannot operate without accessible groups");
152 static constexpr uint8_t nbAccessibleGroups = nbGroupsTotal - hiddenGroupsCount;
155 static_assert(nbGroupsTotal <= 15,
"Maximum of 15 groups has been exceeded.");
157 template<u
int8_t Idx>
using GroupAt = std::tuple_element_t<Idx, AllGroupsTy>;
160 using HasAnyGroup = details::anyOf<AllGroupsTy>;
161 static constexpr bool hasSunsetAnimation = HasAnyGroup::hasSunsetAnimation;
162 static constexpr bool hasBrightCallback = HasAnyGroup::hasBrightCallback;
163 static constexpr bool requireUserThread = HasAnyGroup::requireUserThread;
164 static constexpr bool hasCustomRamp = HasAnyGroup::hasCustomRamp;
165 static constexpr bool hasSystemCallbacks = hasCustomRamp || HasAnyGroup::hasSystemCallbacks;
166 static constexpr bool hasButtonCustomUI = HasAnyGroup::hasButtonCustomUI;
169 using EveryModeBool = details::asTableFor<AllGroupsTy>;
170 static constexpr auto everySunsetCallback = EveryModeBool::everySunsetCallback;
171 static constexpr auto everyBrightCallback = EveryModeBool::everyBrightCallback;
172 static constexpr auto everyRequireUserThread = EveryModeBool::everyRequireUserThread;
173 static constexpr auto everyCustomRamp = EveryModeBool::everyCustomRamp;
174 static constexpr auto everySystemCallbacks = EveryModeBool::everySystemCallbacks;
175 static constexpr auto everyButtonCustomUI = EveryModeBool::everyButtonCustomUI;
178 ModeManagerTy(hardware::LampTy& lamp) : activeIndex {ActiveIndexTy::from(Config::initialActiveIndex)}, lamp {lamp} {}
180 ModeManagerTy() =
delete;
181 ModeManagerTy(
const ModeManagerTy&) =
delete;
182 ModeManagerTy& operator=(
const ModeManagerTy&) =
delete;
185 auto get_context() {
return ContextTy<SelfTy, SelfTy>(*
this); }
188 template<
typename CallBack>
static void LMBD_INLINE dispatch_group(
auto& ctx, CallBack&& cb)
190 uint8_t groupId = ctx.get_active_group(nbGroupsTotal);
192 details::unroll<nbGroupsTotal>([&](
auto Idx) LMBD_INLINE {
201 template<
bool systemCallbacksOnly,
typename CallBack>
static void LMBD_INLINE foreach_group(
auto& ctx, CallBack&& cb)
203 if constexpr (systemCallbacksOnly)
205 details::unroll<nbGroupsTotal>([&](
auto Idx) LMBD_INLINE {
206 using GroupHere = GroupAt<Idx>;
207 constexpr bool hasCallbacks = GroupHere::hasSystemCallbacks;
209 if constexpr (hasCallbacks)
217 details::unroll<nbGroupsTotal>([&](
auto Idx) LMBD_INLINE {
228 enum class Store : uint16_t
238 static constexpr uint32_t storeId = modes::store::derivateStoreId<modes::store::hash(
"ManagerStoreId"), AllGroupsTy>;
255 std::array<ActiveIndexTy, maxFavoriteCount>
favorites = {};
258 static_assert(
maxFavoriteCount < 16,
"Maximum of 15 favorite as been exceeded");
275 RampHandlerTy<Config>
rampHandler = {Config::defaultCustomRampStepSpeedMs};
291 auto& self = ctx.state;
292 self.rampHandler.reset();
293 self.clearStripOnModeChange = Config::defaultClearStripOnModeChange;
299 auto& self = ctx.state;
300 if (self.clearStripOnModeChange)
308 template<
typename Group> StateTyOf<Group>* LMBD_INLINE getStateGroupOf()
310 using StateTy = StateTyOf<Group>;
311 using OptionalTy = std::optional<StateTy>;
313 StateTy* substate =
nullptr;
314 details::unroll<nbGroupsTotal>([&](
auto Idx) LMBD_INLINE {
315 using GroupHere = GroupAt<Idx>;
316 constexpr bool IsHere = std::is_same_v<GroupHere, Group>;
318 if constexpr (IsHere)
320 OptionalTy& opt = std::get<OptionalTy>(state.groupStates);
321 if (!opt.has_value())
326 StateTy& stateHere = *opt;
327 substate = &stateHere;
330 assert(substate !=
nullptr &&
"this should not have compiled at all!");
332 static_assert(details::ModeBelongsTo<Group, AllGroups>);
337 template<
typename Mode> StateTyOf<Mode>& LMBD_INLINE getStateOf()
339 using TargetStateTy = StateTyOf<Mode>;
342 if constexpr (std::is_same_v<TargetStateTy, NoState>)
348 else if constexpr (std::is_same_v<TargetStateTy, StateTy>)
354 else if constexpr (details::GroupBelongsTo<Mode, AllGroups>)
356 TargetStateTy* substate = getStateGroupOf<Mode>();
358 if (substate ==
nullptr)
360 substate = (TargetStateTy*)&placeholder;
361 assert(
false &&
"this code should be unreachable, but is it?");
368 static_assert(details::ModeExists<Mode, AllGroups>);
371 TargetStateTy* substate =
nullptr;
373 details::unroll<nbGroupsTotal>([&](
auto Idx) LMBD_INLINE {
374 using Group = GroupAt<Idx>;
375 using AllModes =
typename Group::AllModesTy;
376 if constexpr (details::ModeBelongsTo<Mode, AllModes>)
378 substate = Group::template getStateOf<Mode>(*
this);
381 assert(substate !=
nullptr &&
"this should not have compiled at all!");
383 if (substate ==
nullptr)
385 substate = (TargetStateTy*)&placeholder;
386 assert(
false &&
"this code should be unreachable, but is it?");
397 static constexpr bool isGroupManager =
true;
398 static constexpr bool isModeManager =
true;
401 static void next_group(
auto& ctx)
404 uint8_t groupIdBefore = ctx.get_active_group(nbAccessibleGroups);
405 ctx.set_active_group(groupIdBefore + 1, nbAccessibleGroups);
409 static void next_mode(
auto& ctx)
411 dispatch_group(ctx, [](
auto group) {
417 static void jump_to_new_active_index(
auto& ctx,
const ActiveIndexTy& newActiveIndex)
420 ctx.set_active_group(newActiveIndex.groupIndex, nbGroupsTotal);
421 ctx.set_active_mode(newActiveIndex.modeIndex);
423 ctx.modeManager.activeIndex.customIndex = newActiveIndex.customIndex;
424 ctx.modeManager.activeIndex.rampIndex = newActiveIndex.rampIndex;
427 if (ctx.modeManager.activeIndex.rawIndex != newActiveIndex.rawIndex)
429 ctx.modeManager.activeIndex = newActiveIndex;
430 custom_ramp_update(ctx, ctx.get_active_custom_ramp());
441 static bool jump_to_favorite(
auto& ctx, uint8_t which_one,
bool shouldSaveLastActiveIndex)
444 if (ctx.state.usedFavoriteCount <= 0)
448 which_one = (which_one % ctx.state.usedFavoriteCount);
449 ctx.state.lastFavoriteStep = which_one;
452 if (shouldSaveLastActiveIndex)
454 ctx.state.beforeFavoriteGroupIndex = ctx.modeManager.activeIndex.groupIndex;
455 ctx.state.beforeFavoriteModeIndex = ctx.modeManager.activeIndex.modeIndex;
458 if (which_one >= ctx.state.maxFavoriteCount)
461 const auto targetFavorite = ctx.state.favorites[which_one];
463 jump_to_new_active_index(ctx, targetFavorite);
467 display_favorite_number_ramp(ctx, which_one, ctx.state.usedFavoriteCount,
true, 1000);
478 static bool set_favorite_now(
auto& ctx, uint8_t which_one = 0)
481 if (which_one != ctx.state.maxFavoriteCount && which_one == ctx.state.usedFavoriteCount)
484 ctx.state.usedFavoriteCount = std::min<uint8_t>(ctx.state.usedFavoriteCount + 1, ctx.state.maxFavoriteCount);
487 if (which_one < ctx.state.maxFavoriteCount)
489 ctx.state.favorites[which_one] = ctx.modeManager.activeIndex;
500 static bool delete_favorite_now(
auto& ctx)
503 const auto which_one = ctx.state.lastFavoriteStep;
504 if (ctx.state.usedFavoriteCount > 0 and which_one < ctx.state.maxFavoriteCount)
506 ctx.state.usedFavoriteCount -= 1;
508 for (uint8_t i = which_one; i < ctx.state.maxFavoriteCount - 1; ++i)
511 ctx.state.favorites[i] = ctx.state.favorites[i + 1];
514 if (ctx.state.usedFavoriteCount > 0)
516 jump_to_new_active_index(ctx, ctx.state.favorites[which_one % ctx.state.usedFavoriteCount]);
523 ctx.state.isInFavoriteMockGroup =
false;
525 ctx.set_active_group(ctx.state.beforeFavoriteGroupIndex);
526 ctx.set_active_mode(ctx.state.beforeFavoriteModeIndex);
541 static void handle_scroll_modes(
auto& ctx, uint32_t holdDuration)
543 auto& scrollHandler = ctx.state.scrollHandler;
544 scrollHandler.isForward =
false;
546 static constexpr uint32_t scrollActivationTiming = 750;
547 if (holdDuration <= scrollActivationTiming)
550 overlay_animate_ramp(
551 ctx, holdDuration, scrollActivationTiming, colors::PaletteGradient<colors::White, colors::Cyan>);
555 scrollHandler.update_ramp(128, holdDuration, [&](uint8_t rampValue) {
556 uint8_t modeIndex = ctx.get_active_mode();
557 uint8_t groupIndex = ctx.get_active_group();
558 uint8_t modeCount = ctx.get_modes_count();
560 ctx.state.isLastScrollAGroupChange =
false;
569 ctx.set_active_mode(modeIndex - 1, modeCount);
575 ctx.state.isLastScrollAGroupChange =
true;
580 ctx.set_active_group(groupIndex - 1, nbAccessibleGroups);
587 ctx.set_active_group(nbAccessibleGroups - 1, nbAccessibleGroups);
591 modeCount = ctx.get_modes_count();
592 ctx.set_active_mode(modeCount - 1, modeCount);
601 if (modeIndex + 1 < modeCount)
609 ctx.state.isLastScrollAGroupChange =
true;
611 if (groupIndex + 1 < nbAccessibleGroups)
619 ctx.set_active_group(0, nbAccessibleGroups);
623 ctx.set_active_mode(0, modeCount);
634 static void enter_hidden_group(
auto& ctx, uint8_t index)
636 assert(index < hiddenGroupsCount);
637 ctx.set_active_group(nbAccessibleGroups + index, nbGroupsTotal);
641 static bool overlay_animate_ramp(
642 auto& ctx,
float holdDuration,
float stepSize,
const colors::PaletteTy& palette,
const uint32_t timeout = 0)
645 const uint32_t stepProgress = floor((holdDuration * 256.0) / stepSize);
646 return overlay_animate_ramp(ctx, stepProgress % 256, palette);
648 static bool overlay_animate_ramp(
auto& ctx,
651 const uint32_t timeout = 0)
667 return (progress >= 250);
671 static void overlay_animate_dot(
auto& ctx,
676 const uint32_t timeout = 0)
695 static uint8_t get_modes_count(
auto& ctx)
698 dispatch_group(ctx, [&](
auto group) {
699 value =
decltype(group)::LocalModeTy::nbModes;
705 static void enter_group(
auto& ctx,
const uint8_t value)
708 assert(value < nbGroupsTotal);
710 auto manager = ctx.modeManager.get_context();
713 ctx.modeManager.quit_mode(manager);
716 ctx.modeManager.activeIndex.groupIndex = value;
718 ctx.modeManager.activeIndex.modeIndex = ctx.state.lastModeMemory[value];
721 ctx.modeManager.enter_mode(manager);
725 static void quit_group(
auto& ctx)
728 uint8_t modeIdBefore = ctx.get_active_mode();
731 auto keyModeMemory = ctx.template storageFor<Store::modeMemory>(ctx.state.lastModeMemory);
734 uint8_t groupIdBefore = ctx.get_active_group(nbGroupsTotal);
735 ctx.state.lastModeMemory[groupIdBefore] = modeIdBefore;
739 static void enter_mode(
auto& ctx)
741 ctx.state.before_enter_mode(ctx);
744 dispatch_group(ctx, [](
auto group) {
748 ctx.state.after_enter_mode(ctx);
752 static void quit_mode(
auto& ctx)
754 dispatch_group(ctx, [](
auto group) {
764 static void loop(
auto& ctx)
767 if (ctx.state.isFavoritePending > 0)
769 ctx.state.isFavoritePending -= 1;
771 if (ctx.state.isFavoritePending == 0 && ctx.state.whichFavoritePending <= ctx.state.usedFavoriteCount)
773 if (ctx.set_favorite_now(ctx.state.whichFavoritePending))
781 if (ctx.state.isFavoriteDeletePending > 0)
783 ctx.state.isFavoriteDeletePending -= 1;
786 if (ctx.state.isFavoriteDeletePending == 0)
788 ctx.delete_favorite_now();
793 if (ctx.state.isSunsetTimingPending > 0)
795 ctx.state.isSunsetTimingPending -= 1;
796 if (ctx.state.isSunsetTimingPending == 0)
805 if (ctx.lamp.config.skipFirstLedsForEffect > 0)
807 ctx.lamp.config.skipFirstLedsForEffect -= 1;
810 if (ctx.state.skipNextFrameEffect > 0)
812 ctx.state.skipNextFrameEffect -= 1;
815 if (ctx.state.skipNextFrameEffect == 0)
817 ctx.lamp.restoreBrightness();
822 ctx.lamp.refresh_tick_value();
825 dispatch_group(ctx, [](
auto group) {
830 overlay.display_update(ctx);
838 static void sunset_update(
auto& ctx,
float progress)
840 dispatch_group(ctx, [&](
auto group) {
841 group.sunset_update(progress);
852 dispatch_group(ctx, [&](
auto group) {
853 group.brightness_update(brightness);
860 foreach_group<true>(ctx, [](
auto group) {
861 group.power_on_sequence();
865 if (ctx.state.isInFavoriteMockGroup && jump_to_favorite(ctx, ctx.state.lastFavoriteStep,
false))
872 uint8_t groupIdBefore = ctx.get_active_group(nbGroupsTotal);
873 ctx.set_active_group(groupIdBefore);
880 foreach_group<true>(ctx, [](
auto group) {
881 group.power_off_sequence();
892 ctx.template storageSaveOnly<Store::lastActive>(ctx.modeManager.activeIndex);
895 ctx.template storageSaveOnly<Store::usedFavoriteCount>(ctx.modeManager.state.usedFavoriteCount);
896 ctx.template storageSaveOnly<Store::favoriteModes>(ctx.modeManager.state.favorites);
897 ctx.template storageSaveOnly<Store::lastUsedFavorite>(ctx.modeManager.state.lastFavoriteStep);
898 ctx.template storageSaveOnly<Store::isInFavoriteGroup>(ctx.state.isInFavoriteMockGroup);
899 ctx.template storageSaveOnly<Store::modeMemory>(ctx.state.lastModeMemory);
901 foreach_group<not hasCustomRamp>(ctx, [&ctx](
auto group) {
902 if constexpr (group.hasCustomRamp)
904 using StoreHere =
typename decltype(group)::StoreEnum;
905 group.template storageSaveOnly<StoreHere::rampMemory>(group.state.customRampMemory);
906 group.template storageSaveOnly<StoreHere::indexMemory>(group.state.customIndexMemory);
909 group.write_parameters();
917 using LocalStore = details::LocalStoreOf<
decltype(ctx)>;
918 LocalStore::template migrateStoreIfNeeded<storeId>();
921 ctx.template storageLoadOnly<Store::lastActive>(ctx.modeManager.activeIndex);
924 ctx.template storageLoadOnly<Store::usedFavoriteCount>(ctx.modeManager.state.usedFavoriteCount);
925 ctx.template storageLoadOnly<Store::favoriteModes>(ctx.state.favorites);
926 ctx.template storageLoadOnly<Store::lastUsedFavorite>(ctx.modeManager.state.lastFavoriteStep);
927 ctx.template storageLoadOnly<Store::isInFavoriteGroup>(ctx.state.isInFavoriteMockGroup);
928 ctx.template storageLoadOnly<Store::modeMemory>(ctx.state.lastModeMemory);
931 foreach_group<not hasCustomRamp>(ctx, [&ctx](
auto group) {
932 using LocalStore = details::LocalStoreOf<
decltype(group)>;
933 LocalStore::template migrateStoreIfNeeded<storeId>();
935 if constexpr (group.hasCustomRamp)
937 using StoreHere =
typename LocalStore::EnumTy;
938 group.template storageLoadOnly<StoreHere::rampMemory>(group.state.customRampMemory);
939 group.template storageLoadOnly<StoreHere::indexMemory>(group.state.customIndexMemory);
942 group.read_parameters();
949 dispatch_group(ctx, [](
auto group) {
960 static void custom_ramp_update(
auto& ctx, uint8_t rampValue, uint32_t timeout = 0)
962 uint8_t groupId = ctx.get_active_group();
963 uint8_t modeId = ctx.get_active_mode();
965 if (ctx.everyCustomRamp[groupId][modeId] && ctx.state.rampHandler.animEffect)
967 switch (ctx.state.rampHandler.animChoice)
979 dispatch_group(ctx, [&](
auto group) {
980 group.custom_ramp_update(rampValue);
985 static bool custom_click(
auto& ctx, uint8_t nbClick)
988 dispatch_group(ctx, [&](
auto group) {
989 retVal = group.custom_click(nbClick);
995 static bool custom_hold(
auto& ctx, uint8_t nbClickAndHold,
bool isEndOfHoldEvent, uint32_t holdDuration)
998 dispatch_group(ctx, [&](
auto group) {
999 retVal = group.custom_hold(nbClickAndHold, isEndOfHoldEvent, holdDuration);
1016 static void display_favorite_number_ramp(
auto& ctx,
1017 const uint8_t favoriteIndex,
1018 const uint8_t maxFavoriteIndex,
1019 const bool display =
false,
1020 const uint32_t timeout = 0)
1022 const uint8_t maxPixelDisplay = std::min<uint8_t>(ctx.state.maxFavoriteCount, maxFavoriteIndex);
1023 for (uint8_t i = 0; i < maxPixelDisplay; ++i)
1025 const bool shouldDisplay = (display and i <= favoriteIndex);
1026 overlay_animate_dot(
1027 ctx, i, i, shouldDisplay ? 255 : 0, colors::PaletteGradient<colors::Black, colors::Cyan>, timeout);
1037 template<
bool displayFavoriteNumber = true>
1038 static void animate_favorite_pick(
auto& ctx,
float holdDuration,
float stepSize)
1042 const uint8_t numberOfFavoriteSet =
1043 ctx.state.usedFavoriteCount + ((ctx.state.usedFavoriteCount < ctx.state.maxFavoriteCount) ? 1 : 0);
1046 uint32_t stepCount = numberOfFavoriteSet + floor(holdDuration / stepSize);
1047 stepCount = stepCount % (numberOfFavoriteSet + 1);
1050 if (stepCount >= numberOfFavoriteSet)
1053 ctx.state.isFavoritePending = 0;
1056 if (holdDuration <= 2 * stepSize)
1058 overlay_animate_ramp(ctx, holdDuration, stepSize, colors::PaletteGradient<colors::White, colors::Cyan>);
1064 overlay_animate_ramp(ctx, holdDuration, stepSize, colors::PaletteGradient<colors::Green, colors::White>);
1067 if constexpr (displayFavoriteNumber)
1070 display_favorite_number_ramp(ctx, stepCount, numberOfFavoriteSet, stepCount < numberOfFavoriteSet);
1074 ctx.state.isFavoritePending = 10;
1075 ctx.state.whichFavoritePending = stepCount;
1085 template<
bool displayFavoriteNumber = true>
1086 static void animate_favorite_delete(
auto& ctx,
float holdDuration,
float stepSize)
1089 if (ctx.state.usedFavoriteCount <= 0)
1092 ctx.state.isInDeleteFavorite =
true;
1094 uint32_t stepCount = floor(holdDuration / stepSize);
1095 stepCount = stepCount % 2;
1099 if (overlay_animate_ramp(ctx, holdDuration, stepSize, colors::PaletteGradient<colors::Orange, colors::Red>))
1102 ctx.state.isFavoriteDeletePending = 2;
1107 ctx.state.isFavoriteDeletePending = 0;
1111 if constexpr (displayFavoriteNumber)
1114 display_favorite_number_ramp(ctx, ctx.state.lastFavoriteStep, ctx.state.usedFavoriteCount,
true);
1125 ActiveIndexTy activeIndex;
1128 hardware::LampTy& lamp;
1131 inline static draw::overlay::Manager<> overlay;
1139 NoState placeholder;
1149 ModeManagerTy<ManagerConfig, std::tuple<Groups...>, 0>;
1178 ModeManagerTy<ManagerConfig, std::tuple<Groups...>, hiddenGroupCnt>;
Handle the main alerts behavior.
Define assertions helpers.
void raise(const Type type)
Raise an alert.
Definition: alerts.cpp:858
ContextTy and associated definitions.
Filesystem interaction tools.
Define the main led strip interaction object.
AlertManager_t manager
Instanciation of the AlertManager.
Definition: alerts.cpp:27
void add_time_minutes(const uint8_t time_minutes)
add some time to the sunset timer. Limited to 10 minutes
Definition: sunset_timer.cpp:124
static constexpr PaletteTy PaletteBlackBodyColors
Black body radiation, with the high end changed to be nicer.
Definition: palettes.hpp:396
std::array< uint32_t, 16 > PaletteTy
Palette types.
Definition: palettes.hpp:18
static constexpr PaletteTy PaletteRainbowColors
HSV Rainbow.
Definition: palettes.hpp:360
@ DOT
Display a pixel dot.
@ indexable
Equivalent to LMBD_LAMP_TYPE__INDEXABLE.
static void clear_stored()
Force clear the stored parameters.
Definition: keystore.hpp:74
Contains basic interface types to implement custom user modes.
Definition: control_fixed_modes.hpp:12
ModeManagerTy< ManagerConfig, std::tuple< Groups... >, hiddenGroupCnt > ManagerFoHiddenConfig
Same as modes::ManagerFor but with custom defaults, and additional hidden groups.
Definition: manager_type.hpp:1178
ModeManagerTy< DefaultManagerConfig, std::tuple< Groups... >, hiddenGroupCnt > ManagerForHiddenGroups
Group together several mode groups defined through modes::GroupFor. Will use the last hiddenGroupCnt ...
Definition: manager_type.hpp:1171
ModeManagerTy< ManagerConfig, std::tuple< Groups... >, 0 > ManagerForConfig
Same as modes::ManagerFor but with custom defaults.
Definition: manager_type.hpp:1149
@ rampSaturates
(bool) Mode saturates on custom ramp, or else wrap?
ModeManagerTy< DefaultManagerConfig, std::tuple< Groups... >, 0 > ManagerFor
Group together several mode groups defined through modes::GroupFor.
Definition: manager_type.hpp:1159
static auto context_as(auto &ctx)
Bind provided context to another modes::BasicMode.
Definition: context_type.hpp:25
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
void loop()
Called at each tick of the main loop.
Definition: default_behavior.hpp:139
uint16_t brightness_t
Define the type of the brightness parameters.
Definition: constants.h:147
GlobalSimStateTy state
Store the global simulation state.
Definition: simulator_state.cpp:7
Default manager configuration, enables you to customize defaults.
Definition: default_config.hpp:42
Definition: manager_type.hpp:245
RampHandlerTy< Config > scrollHandler
Ramp handlers: mode scroll ramp.
Definition: manager_type.hpp:277
bool clearStripOnModeChange
Should clear the strip before switching mode.
Definition: manager_type.hpp:279
RampHandlerTy< Config > rampHandler
Ramp handlers: custom ramp (or "color ramp")
Definition: manager_type.hpp:275
bool isInFavoriteMockGroup
Indicates that we are in the fake favorite page.
Definition: manager_type.hpp:266
uint8_t beforeFavoriteModeIndex
store the mode index we need to go to when quitting the favorite page
Definition: manager_type.hpp:268
uint8_t lastFavoriteStep
last used favorite index
Definition: manager_type.hpp:265
AllStatesTy groupStates
All group states, containing all modes individual states.
Definition: manager_type.hpp:247
uint8_t isFavoriteDeletePending
indicate that the deletion of a favorite in in process
Definition: manager_type.hpp:264
uint8_t beforeFavoriteGroupIndex
store the group index we need to go to when quitting the favorite page
Definition: manager_type.hpp:267
uint8_t usedFavoriteCount
number of favorite set by user [0, maxFavoriteCount]
Definition: manager_type.hpp:256
bool isLastScrollAGroupChange
last mode change in scroll changed group
Definition: manager_type.hpp:271
uint8_t whichFavoritePending
indicates the favorite currently selected
Definition: manager_type.hpp:262
uint32_t lastScrollStopped
keep track of the last scrool release time
Definition: manager_type.hpp:272
static void LMBD_INLINE before_enter_mode(auto &ctx)
configuration-related actions done before entering mode
Definition: manager_type.hpp:289
uint8_t isSunsetTimingPending
Indicates that a sunset timer ramp is active.
Definition: manager_type.hpp:269
std::array< ActiveIndexTy, maxFavoriteCount > favorites
Store the active index of every favorite.
Definition: manager_type.hpp:255
uint8_t skipNextFrameEffect
should the next .loop() mode be skipped?
Definition: manager_type.hpp:282
std::array< uint8_t, nbGroupsTotal > lastModeMemory
When switching group, remember which mode was on last time we visited it.
Definition: manager_type.hpp:250
static constexpr uint8_t maxFavoriteCount
Maximum allowed favorite count.
Definition: manager_type.hpp:253
static void LMBD_INLINE after_enter_mode(auto &ctx)
configuration-related actions done after mode entering
Definition: manager_type.hpp:297
uint8_t isFavoritePending
indicate that the addition of a favorite in in process
Definition: manager_type.hpp:261
bool isInDeleteFavorite
indicates that we are in a favorite deletion process
Definition: manager_type.hpp:263
Logic of the sunset time, eg the system auto stops after a set delay.