From c68cb80ca48318b2fb0b74945c96acafb8d36a44 Mon Sep 17 00:00:00 2001 From: PS Date: Sun, 28 Feb 2021 17:13:51 -0800 Subject: [PATCH] Printing out based on messages received --- src/app/blumen_lumen.cpp | 36 ++++++++++++++++++++++++++---------- src/app/blumen_lumen.h | 3 ++- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/app/blumen_lumen.cpp b/src/app/blumen_lumen.cpp index c34e4e7..68aa25a 100644 --- a/src/app/blumen_lumen.cpp +++ b/src/app/blumen_lumen.cpp @@ -56,6 +56,8 @@ BlumenLumen_MicListenJob(gs_thread_context* Ctx, u8* UserData) u32 Port = WeathermanPort; s32 Flags = 0; SocketSend(Data->SocketManager, Data->ListenSocket, Address, Port, Msg, Flags); + + OutputDebugString("Sending Motor Packet\n"); } } } @@ -124,7 +126,7 @@ BlumenLumen_CustomInit(app_state* State, context Context) BLState->MicListenJobData.OutgoingMsgQueue = &BLState->OutgoingMsgQueue; BLState->MicListenJobData.ListenSocket = CreateSocket(Context.SocketManager, "127.0.0.1", "20185"); - //BLState->MicListenThread = CreateThread(Context.ThreadManager, BlumenLumen_MicListenJob, (u8*)&BLState->MicListenJobData); + BLState->MicListenThread = CreateThread(Context.ThreadManager, BlumenLumen_MicListenJob, (u8*)&BLState->MicListenJobData); gs_const_string SculpturePath = ConstString("data/test_blumen.fold"); LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath, State->GlobalLog); @@ -214,31 +216,45 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context) State->AnimationSystem.ActiveAnimationIndex = 2; } - if (BLState->MicPacketBuffer.ReadHead >= PACKETS_MAX) - { - BLState->MicPacketBuffer.ReadHead = 0; - } - - OutputDebugStringA("Received Pattern Packet"); + OutputDebugStringA("Received Pattern Packet\n"); }break; case PacketType_MotorState: { motor_packet Packet = *(motor_packet*)(PacketData.Memory + 1); - OutputDebugStringA("Received Motor Packet"); + BLState->LastKnownMotorState = Packet; + + gs_string Temp = PushStringF(State->Transient, 256, "Received Motor States: %d %d %d\n", + Packet.FlowerPositions[0], + Packet.FlowerPositions[1], + Packet.FlowerPositions[2]); + NullTerminate(&Temp); + + OutputDebugStringA(Temp.Str); }break; case PacketType_Temperature: { temp_packet Packet = *(temp_packet*)(PacketData.Memory + 1); - OutputDebugStringA("Received Temperature Packet"); + + gs_string Temp = PushStringF(State->Transient, 256, "Temperature: %d\n", + Packet.Temperature); + NullTerminate(&Temp); + + OutputDebugStringA(Temp.Str); }break; InvalidDefaultCase; } + + + if (BLState->MicPacketBuffer.ReadHead >= PACKETS_MAX) + { + BLState->MicPacketBuffer.ReadHead = 0; + } } - if (MotorTimeElapsed > 60) + if (false && MotorTimeElapsed > 0) { // NOTE(pjs): MotorTimeElapsed = 0; diff --git a/src/app/blumen_lumen.h b/src/app/blumen_lumen.h index 61e6026..2c47b22 100644 --- a/src/app/blumen_lumen.h +++ b/src/app/blumen_lumen.h @@ -66,9 +66,10 @@ struct blumen_lumen_state temp_job_req JobReq; - platform_thread_handle MicListenThread; mic_listen_job_data MicListenJobData; + + motor_packet LastKnownMotorState; };