diff --git a/src/app/blumen_lumen.cpp b/src/app/blumen_lumen.cpp index 323b8ae..c34e4e7 100644 --- a/src/app/blumen_lumen.cpp +++ b/src/app/blumen_lumen.cpp @@ -5,6 +5,7 @@ // #ifndef BLUMEN_LUMEN_CPP + internal void BlumenLumen_MicListenJob(gs_thread_context* Ctx, u8* UserData) { @@ -192,25 +193,48 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context) while (BLState->MicPacketBuffer.ReadHead != BLState->MicPacketBuffer.WriteHead) { gs_data PacketData = BLState->MicPacketBuffer.Values[BLState->MicPacketBuffer.ReadHead++]; - microphone_packet Packet = *(microphone_packet*)PacketData.Memory; - u32 NameLen = CStringLength(Packet.AnimationFileName); - if (StringEqualsCharArray(BlueString.ConstString, Packet.AnimationFileName, NameLen)) - { - State->AnimationSystem.ActiveAnimationIndex = 0; - } - else if (StringEqualsCharArray(GreenString.ConstString, Packet.AnimationFileName, NameLen)) - { - State->AnimationSystem.ActiveAnimationIndex = 1; - } - else if (StringEqualsCharArray(ILoveYouString.ConstString, Packet.AnimationFileName, NameLen)) - { - State->AnimationSystem.ActiveAnimationIndex = 2; - } - - if (BLState->MicPacketBuffer.ReadHead >= PACKETS_MAX) - { - BLState->MicPacketBuffer.ReadHead = 0; + u8 PacketType = PacketData.Memory[0]; + switch (PacketType) { + case PacketType_PatternCommand: + { + microphone_packet Packet = *(microphone_packet*)(PacketData.Memory + 1); + + u32 NameLen = CStringLength(Packet.AnimationFileName); + if (StringEqualsCharArray(BlueString.ConstString, Packet.AnimationFileName, NameLen)) + { + State->AnimationSystem.ActiveAnimationIndex = 0; + } + else if (StringEqualsCharArray(GreenString.ConstString, Packet.AnimationFileName, NameLen)) + { + State->AnimationSystem.ActiveAnimationIndex = 1; + } + else if (StringEqualsCharArray(ILoveYouString.ConstString, Packet.AnimationFileName, NameLen)) + { + State->AnimationSystem.ActiveAnimationIndex = 2; + } + + if (BLState->MicPacketBuffer.ReadHead >= PACKETS_MAX) + { + BLState->MicPacketBuffer.ReadHead = 0; + } + + OutputDebugStringA("Received Pattern Packet"); + }break; + + case PacketType_MotorState: + { + motor_packet Packet = *(motor_packet*)(PacketData.Memory + 1); + OutputDebugStringA("Received Motor Packet"); + }break; + + case PacketType_Temperature: + { + temp_packet Packet = *(temp_packet*)(PacketData.Memory + 1); + OutputDebugStringA("Received Temperature Packet"); + }break; + + InvalidDefaultCase; } } diff --git a/src/app/blumen_lumen.h b/src/app/blumen_lumen.h index 0ea9db5..61e6026 100644 --- a/src/app/blumen_lumen.h +++ b/src/app/blumen_lumen.h @@ -5,13 +5,21 @@ // #ifndef BLUMEN_LUMEN_H +enum bl_python_packet_type +{ + PacketType_Invalid = 0, + PacketType_PatternCommand = 1, + PacketType_MotorState = 2, + PacketType_Temperature = 3, +}; + +#pragma pack(push, 1) typedef struct motor_packet { u8 FlowerPositions[3]; } motor_packet; -#pragma pack(push, 1) -struct microphone_packet +typedef struct microphone_packet { b8 ChangeAnimation; char AnimationFileName[32]; @@ -21,7 +29,12 @@ struct microphone_packet b8 SetLayerParamColor; char LayerParamColor[7]; r32 OverrideDuration; -}; +} microphone_packet; + +typedef struct temp_packet +{ + s8 Temperature; +} temp_packet; #pragma pack(pop) #define BLUMEN_MESSAGE_QUEUE_COUNT 32