From 0c96f6bd19491725be506fe8b93aea049bfd4b8e Mon Sep 17 00:00:00 2001 From: PS Date: Fri, 9 Apr 2021 00:58:50 -1000 Subject: [PATCH] Added setting for turning leds off at certain times of day --- .../ambient_patterns/ambient_0.foldanim | 92 ------------------- src/app/ss_blumen_lumen/blumen_lumen.cpp | 19 ++++ .../ss_blumen_lumen/blumen_lumen_settings.h | 14 ++- 3 files changed, 31 insertions(+), 94 deletions(-) delete mode 100644 app_run_tree/data/blumen_animations/ambient_patterns/ambient_0.foldanim diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/ambient_0.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/ambient_0.foldanim deleted file mode 100644 index b965ed5..0000000 --- a/app_run_tree/data/blumen_animations/ambient_patterns/ambient_0.foldanim +++ /dev/null @@ -1,92 +0,0 @@ -lumenarium_animation_file; -animation_name: "ambient_0"; -layers_count: 2; -blocks_count: 9; -playable_range:{ - min: 0; - max: 1000; -}; -layers:{ - layer:{ - name: "Color"; - blend: "Add"; - }; - layer:{ - name: "Mask"; - blend: "Multiply"; - }; -}; -blocks:{ - block:{ - frame_range:{ - min: 88; - max: 315; - }; - layer_index: 0; - animation_name: "Pattern_Rotary"; - }; - block:{ - frame_range:{ - min: 156; - max: 429; - }; - layer_index: 1; - animation_name: "Pattern_LeafyPatchy"; - }; - block:{ - frame_range:{ - min: 403; - max: 675; - }; - layer_index: 1; - animation_name: "Pattern_Patchy"; - }; - block:{ - frame_range:{ - min: 643; - max: 997; - }; - layer_index: 1; - animation_name: "Pattern_LeafyPatchy"; - }; - block:{ - frame_range:{ - min: 253; - max: 571; - }; - layer_index: 0; - animation_name: "Pattern_VerticalLines"; - }; - block:{ - frame_range:{ - min: 522; - max: 772; - }; - layer_index: 0; - animation_name: "Pattern_Rotary"; - }; - block:{ - frame_range:{ - min: 737; - max: 998; - }; - layer_index: 0; - animation_name: "Pattern_VerticalLines"; - }; - block:{ - frame_range:{ - min: 0; - max: 117; - }; - layer_index: 0; - animation_name: "Pattern_VerticalLines"; - }; - block:{ - frame_range:{ - min: 0; - max: 179; - }; - layer_index: 1; - animation_name: "Pattern_StemSolid"; - }; -}; diff --git a/src/app/ss_blumen_lumen/blumen_lumen.cpp b/src/app/ss_blumen_lumen/blumen_lumen.cpp index 295a47d..be23b28 100644 --- a/src/app/ss_blumen_lumen/blumen_lumen.cpp +++ b/src/app/ss_blumen_lumen/blumen_lumen.cpp @@ -693,6 +693,25 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context) } } + bool TimelineShouldAdvance = false; + r32 OverrideBrightness = 0.0f; + for (u32 i = 0; i < LedOnTimesCount; i++) + { + time_range Range = LedOnTimes[i]; + bool CurrTimeInRange = SystemTimeIsInTimeRange(Context->SystemTime_Current, Range); + if (CurrTimeInRange) + { + // If we're in one of the specified time ranges, + // play animations and set brightness + OverrideBrightness = BLState->BrightnessPercent; + TimelineShouldAdvance = State->AnimationSystem.TimelineShouldAdvance; + break; + } + } + State->AnimationSystem.TimelineShouldAdvance = TimelineShouldAdvance; + BLState->BrightnessPercent = OverrideBrightness; + + // Dim the leds based on temp data if (!BLState->DEBUG_IgnoreWeatherDimmingLeds) { diff --git a/src/app/ss_blumen_lumen/blumen_lumen_settings.h b/src/app/ss_blumen_lumen/blumen_lumen_settings.h index b610b2b..129a54f 100644 --- a/src/app/ss_blumen_lumen/blumen_lumen_settings.h +++ b/src/app/ss_blumen_lumen/blumen_lumen_settings.h @@ -27,17 +27,27 @@ gs_const_string AmbientPatternFolder = ConstString("data/blumen_animations/ambie gs_const_string VoicePatternFolder = ConstString("data/blumen_animations/audio_responses/*.foldanim"); // The times of day when the motors should be open. +// +// @TimeFormat: documentation follows // these are in the format { Start_Hour, Start_Minute, End_Hour, End_Minute } // Hours are in the range 0-23 inclusive // Minutes are in the range 0-59 inclusive +// // NOTE: There is no need to modify the MotorOpenTimesCount variable - // it is a compile time constant that gets calculated automatically global time_range MotorOpenTimes[] = { - { 12, 45, 17, 45 }, - { 19, 00, 23, 00 }, + { 12, 45, 17, 45 }, // 12:45pm to 5:45pm + { 19, 00, 23, 00 }, // 7:00pm to 11:00pm }; global u32 MotorOpenTimesCount = CArrayLength(MotorOpenTimes); // do not edit +// The times of day when the leds should be on +// Search for @TimeFormat to find documentation +global time_range LedOnTimes[] = { + { 00, 00, 23, 59 }, // literally always +}; +global u32 LedOnTimesCount = CArrayLength(LedOnTimes); // do not edit + // How long it takes to fade from the default pattern to the // voice activated pattern r32 VoiceCommandFadeDuration = 1.0f; // in seconds