Blumen lumen now reads packet headers before attempting to interpret them
This commit is contained in:
parent
64879c0e2d
commit
f8d0f904ce
|
@ -5,6 +5,7 @@
|
||||||
//
|
//
|
||||||
#ifndef BLUMEN_LUMEN_CPP
|
#ifndef BLUMEN_LUMEN_CPP
|
||||||
|
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
BlumenLumen_MicListenJob(gs_thread_context* Ctx, u8* UserData)
|
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)
|
while (BLState->MicPacketBuffer.ReadHead != BLState->MicPacketBuffer.WriteHead)
|
||||||
{
|
{
|
||||||
gs_data PacketData = BLState->MicPacketBuffer.Values[BLState->MicPacketBuffer.ReadHead++];
|
gs_data PacketData = BLState->MicPacketBuffer.Values[BLState->MicPacketBuffer.ReadHead++];
|
||||||
microphone_packet Packet = *(microphone_packet*)PacketData.Memory;
|
|
||||||
|
|
||||||
u32 NameLen = CStringLength(Packet.AnimationFileName);
|
u8 PacketType = PacketData.Memory[0];
|
||||||
if (StringEqualsCharArray(BlueString.ConstString, Packet.AnimationFileName, NameLen))
|
switch (PacketType) {
|
||||||
{
|
case PacketType_PatternCommand:
|
||||||
State->AnimationSystem.ActiveAnimationIndex = 0;
|
{
|
||||||
}
|
microphone_packet Packet = *(microphone_packet*)(PacketData.Memory + 1);
|
||||||
else if (StringEqualsCharArray(GreenString.ConstString, Packet.AnimationFileName, NameLen))
|
|
||||||
{
|
u32 NameLen = CStringLength(Packet.AnimationFileName);
|
||||||
State->AnimationSystem.ActiveAnimationIndex = 1;
|
if (StringEqualsCharArray(BlueString.ConstString, Packet.AnimationFileName, NameLen))
|
||||||
}
|
{
|
||||||
else if (StringEqualsCharArray(ILoveYouString.ConstString, Packet.AnimationFileName, NameLen))
|
State->AnimationSystem.ActiveAnimationIndex = 0;
|
||||||
{
|
}
|
||||||
State->AnimationSystem.ActiveAnimationIndex = 2;
|
else if (StringEqualsCharArray(GreenString.ConstString, Packet.AnimationFileName, NameLen))
|
||||||
}
|
{
|
||||||
|
State->AnimationSystem.ActiveAnimationIndex = 1;
|
||||||
if (BLState->MicPacketBuffer.ReadHead >= PACKETS_MAX)
|
}
|
||||||
{
|
else if (StringEqualsCharArray(ILoveYouString.ConstString, Packet.AnimationFileName, NameLen))
|
||||||
BLState->MicPacketBuffer.ReadHead = 0;
|
{
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,21 @@
|
||||||
//
|
//
|
||||||
#ifndef BLUMEN_LUMEN_H
|
#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
|
typedef struct motor_packet
|
||||||
{
|
{
|
||||||
u8 FlowerPositions[3];
|
u8 FlowerPositions[3];
|
||||||
} motor_packet;
|
} motor_packet;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
typedef struct microphone_packet
|
||||||
struct microphone_packet
|
|
||||||
{
|
{
|
||||||
b8 ChangeAnimation;
|
b8 ChangeAnimation;
|
||||||
char AnimationFileName[32];
|
char AnimationFileName[32];
|
||||||
|
@ -21,7 +29,12 @@ struct microphone_packet
|
||||||
b8 SetLayerParamColor;
|
b8 SetLayerParamColor;
|
||||||
char LayerParamColor[7];
|
char LayerParamColor[7];
|
||||||
r32 OverrideDuration;
|
r32 OverrideDuration;
|
||||||
};
|
} microphone_packet;
|
||||||
|
|
||||||
|
typedef struct temp_packet
|
||||||
|
{
|
||||||
|
s8 Temperature;
|
||||||
|
} temp_packet;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#define BLUMEN_MESSAGE_QUEUE_COUNT 32
|
#define BLUMEN_MESSAGE_QUEUE_COUNT 32
|
||||||
|
|
Loading…
Reference in New Issue