Created a panel for the Awaken sequence

This commit is contained in:
PS 2021-04-09 01:48:29 -10:00
parent ee1163be95
commit 7e1e22ed5a
3 changed files with 255 additions and 130 deletions

View File

@ -7,6 +7,12 @@
#define FLOWER_COLORS_COUNT 12
internal void
Pattern_None(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData)
{
// just here so you can fade in from black
}
internal void
Pattern_AltBloomMask(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 Time, gs_memory_arena* Transient, u8* UserData)
{

View File

@ -201,6 +201,7 @@ BlumenLumen_LoadPatterns(app_state* State)
}
Patterns->Count = 0;
Patterns_PushPattern(Patterns, Pattern_None, PATTERN_SINGLETHREADED);
Patterns_PushPattern(Patterns, Pattern_HueShift, PATTERN_MULTITHREADED);
Patterns_PushPattern(Patterns, Pattern_Rainbow, PATTERN_MULTITHREADED);
Patterns_PushPattern(Patterns, Pattern_BasicFlowers, PATTERN_MULTITHREADED);
@ -307,6 +308,7 @@ BlumenLumen_UpdateLog(app_state* State, blumen_lumen_state* BLState, context Con
{
case BlumenPattern_Standard: { PatternMode = "Standard"; } break;
case BlumenPattern_VoiceCommand: { PatternMode = "Voice Command"; } break;
case BlumenPattern_NoControl: { PatternMode = "No Control: Someone's doing the Awaken sequence!"; } break;
}
AppendPrintF(&FileStr, "Pattern Mode: %s\n", PatternMode);
@ -394,6 +396,15 @@ BlumenLumen_CustomInit(app_state* State, context Context)
AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem, State->Patterns, Context, ConstString("data/blumen_animations/anim_demo.foldanim"));
BlumenLumen_SetPatternMode(BlumenPattern_Standard, GlobalAnimTransitionSpeed, &State->AnimationSystem, BLState);
BLState->AwakenHandle = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem,
State->Patterns,
Context,
ConstString("data/blumen_animations/awaken.foldanim"));
BLState->OffAnimHandle = AnimationSystem_LoadAnimationFromFile(&State->AnimationSystem,
State->Patterns,
Context,
ConstString("data/blumen_animations/off_anim.foldanim"));
#endif
State->AnimationSystem.TimelineShouldAdvance = true;
@ -587,7 +598,8 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
}
// Open / Close the Motor
if (MessageQueue_CanWrite(BLState->OutgoingMsgQueue))
if (MessageQueue_CanWrite(BLState->OutgoingMsgQueue) &&
!BLState->IgnoreTimeOfDay_MotorState)
{
for (u32 i = 0; i < MotorOpenTimesCount; i++)
{
@ -693,6 +705,8 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
}
}
if (!BLState->IgnoreTimeOfDay_LedDimming)
{
bool TimelineShouldAdvance = false;
r32 OverrideBrightness = 0.0f;
for (u32 i = 0; i < LedOnTimesCount; i++)
@ -710,7 +724,7 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
}
State->AnimationSystem.TimelineShouldAdvance = TimelineShouldAdvance;
BLState->BrightnessPercent = OverrideBrightness;
}
// Dim the leds based on temp data
if (!BLState->DEBUG_IgnoreWeatherDimmingLeds)
@ -769,8 +783,24 @@ US_CUSTOM_DEBUG_UI(BlumenLumen_DebugUI)
blumen_lumen_state* BLState = (blumen_lumen_state*)UserData.Memory;
ui_interface* I = &State->Interface;
ui_BeginRow(I, BlumenDebug_Count);
for (u32 i = 0; i < BlumenDebug_Count; i++)
{
if (ui_Button(I, MakeString(BlDebugUiModeStrings[i])))
{
BLState->DebugMode = (bl_debug_ui_mode)i;
}
}
ui_EndRow(I);
switch (BLState->DebugMode)
{
case BlumenDebug_Motors:
{
motor_packet PendingPacket = BLState->DEBUG_PendingMotorPacket;
BLState->IgnoreTimeOfDay_MotorState = ui_ToggleText(I, MakeString("Motors Ignore Time Limit"), BLState->IgnoreTimeOfDay_MotorState);
for (u32 MotorIndex = 0; MotorIndex < BL_FLOWER_COUNT; MotorIndex++)
{
gs_string Label = PushStringF(State->Transient, 32, "Motor %d", MotorIndex);
@ -810,8 +840,8 @@ US_CUSTOM_DEBUG_UI(BlumenLumen_DebugUI)
Packet.MotorPacket = BLState->DEBUG_PendingMotorPacket;
gs_data Msg = StructToData(&Packet, blumen_packet);
MessageQueue_Write(&BLState->OutgoingMsgQueue, Msg);
DEBUG_SentMotorCommand(Packet.MotorPacket, Context.ThreadContext);
}
motor_packet MotorPos = BLState->LastKnownMotorState;
@ -847,8 +877,6 @@ US_CUSTOM_DEBUG_UI(BlumenLumen_DebugUI)
}
}
BLState->DEBUG_IgnoreWeatherDimmingLeds = ui_LabeledToggle(I, MakeString("Ignore Weather Dimming Leds"), BLState->DEBUG_IgnoreWeatherDimmingLeds);
ui_Label(I, MakeString("Set Internal Motor State:"));
if (ui_Button(I, MakeString("Closed")))
{
@ -870,6 +898,13 @@ US_CUSTOM_DEBUG_UI(BlumenLumen_DebugUI)
BlumenLumen_UpdateMotorState(BLState, Motor, Context);
}
} break;
case BlumenDebug_Leds:
{
BLState->DEBUG_IgnoreWeatherDimmingLeds = ui_LabeledToggle(I, MakeString("Ignore Weather Dimming Leds"), BLState->DEBUG_IgnoreWeatherDimmingLeds);
BLState->IgnoreTimeOfDay_LedDimming = ui_ToggleText(I, MakeString("Leds Ignore Time Limit"), BLState->IgnoreTimeOfDay_LedDimming);
if (ui_BeginLabeledDropdown(I, MakeString("Phrase"), MakeString(BLState->PendingPhrase.Phrase)))
{
@ -894,6 +929,68 @@ US_CUSTOM_DEBUG_UI(BlumenLumen_DebugUI)
}
InterfaceAssert(I->PerFrameMemory);
}break;
case BlumenDebug_Awaken:
{
ui_Label(I, MakeString("Step 1:"));
ui_Label(I, MakeString("Leds off, flowers closed"));
if (ui_Button(I, MakeString("Prepare")))
{
// motors closed
blumen_packet M = {};
M.Type = PacketType_MotorState;
M.MotorPacket.FlowerPositions[0] = MotorState_Closed;
M.MotorPacket.FlowerPositions[1] = MotorState_Closed;
M.MotorPacket.FlowerPositions[2] = MotorState_Closed;
gs_data D = StructToData(&M, blumen_packet);
MessageQueue_Write(&BLState->OutgoingMsgQueue, D);
// animation
State->AnimationSystem.RepeatMode = AnimationRepeat_Single;
AnimationFadeGroup_FadeTo(&State->AnimationSystem.ActiveFadeGroup,
BLState->OffAnimHandle,
VoiceCommandFadeDuration);
BLState->PatternMode = BlumenPattern_NoControl;
BLState->IgnoreTimeOfDay_LedDimming = true;
BLState->IgnoreTimeOfDay_MotorState = true;
}
ui_Label(I, MakeString("Step 2:"));
if (ui_Button(I, MakeString("Begin Light Show")))
{
AnimationFadeGroup_FadeTo(&State->AnimationSystem.ActiveFadeGroup,
BLState->AwakenHandle,
VoiceCommandFadeDuration);
}
ui_Label(I, MakeString("Step 3:"));
if (ui_Button(I, MakeString("Open Flowers")))
{
// motors closed
blumen_packet M = {};
M.Type = PacketType_MotorState;
M.MotorPacket.FlowerPositions[0] = MotorState_Open;
M.MotorPacket.FlowerPositions[1] = MotorState_Open;
M.MotorPacket.FlowerPositions[2] = MotorState_Open;
gs_data D = StructToData(&M, blumen_packet);
MessageQueue_Write(&BLState->OutgoingMsgQueue, D);
}
ui_Label(I, MakeString("Step 4:"));
ui_Label(I, MakeString("Resets Lumenarium"));
if (ui_Button(I, MakeString("Complete")))
{
BLState->IgnoreTimeOfDay_LedDimming = false;
BLState->IgnoreTimeOfDay_MotorState = false;
BlumenLumen_SetPatternMode(BlumenPattern_Standard, GlobalAnimTransitionSpeed, &State->AnimationSystem,
BLState);
}
}break;
InvalidDefaultCase;
}
}
US_CUSTOM_CLEANUP(BlumenLumen_CustomCleanup)

View File

@ -7,10 +7,26 @@
#include "message_queue.h"
enum bl_debug_ui_mode
{
BlumenDebug_Motors,
BlumenDebug_Leds,
BlumenDebug_Awaken,
BlumenDebug_Count,
};
char* BlDebugUiModeStrings[] = {
"Motors",
"Leds",
"Awaken",
};
enum bl_pattern_mode
{
BlumenPattern_Standard,
BlumenPattern_VoiceCommand,
BlumenPattern_NoControl,
BlumenPattern_Count,
};
@ -172,6 +188,8 @@ struct blumen_lumen_state
bl_pattern_mode PatternMode;
animation_handle_array ModeAnimations[BlumenPattern_Count];
animation_handle OffAnimHandle;
animation_handle AwakenHandle;
phrase_hue_map PhraseHueMap;
@ -186,10 +204,14 @@ struct blumen_lumen_state
r32 PatternSpeed;
// Debug
bl_debug_ui_mode DebugMode;
motor_packet DEBUG_PendingMotorPacket;
bool DEBUG_IgnoreWeatherDimmingLeds;
bool ShouldUpdateLog;
bool IgnoreTimeOfDay_LedDimming;
bool IgnoreTimeOfDay_MotorState;
phrase_hue PendingPhrase;
};