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,7 +193,12 @@ 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;
|
|
||||||
|
u8 PacketType = PacketData.Memory[0];
|
||||||
|
switch (PacketType) {
|
||||||
|
case PacketType_PatternCommand:
|
||||||
|
{
|
||||||
|
microphone_packet Packet = *(microphone_packet*)(PacketData.Memory + 1);
|
||||||
|
|
||||||
u32 NameLen = CStringLength(Packet.AnimationFileName);
|
u32 NameLen = CStringLength(Packet.AnimationFileName);
|
||||||
if (StringEqualsCharArray(BlueString.ConstString, Packet.AnimationFileName, NameLen))
|
if (StringEqualsCharArray(BlueString.ConstString, Packet.AnimationFileName, NameLen))
|
||||||
|
@ -212,6 +218,24 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
||||||
{
|
{
|
||||||
BLState->MicPacketBuffer.ReadHead = 0;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MotorTimeElapsed > 60)
|
if (MotorTimeElapsed > 60)
|
||||||
|
|
|
@ -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