saturday at foldspace
This commit is contained in:
parent
63d204364a
commit
ac19ab97ba
|
@ -23,7 +23,7 @@ BlumenLumen_MicListenJob(gs_thread_context* Ctx, u8* UserData)
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 1
|
||||||
// TODO(pjs): Removing this block for now - nothing is wrong with it except that SocketPeek is still blocking for some reason
|
// TODO(pjs): Removing this block for now - nothing is wrong with it except that SocketPeek is still blocking for some reason
|
||||||
if (SocketPeek(Data->SocketManager, Data->ListenSocket))
|
if (SocketPeek(Data->SocketManager, Data->ListenSocket))
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,7 @@ BlumenLumen_CustomInit(app_state* State, context Context)
|
||||||
BLState->MicListenJobData.OutgoingMsgQueue = &BLState->OutgoingMsgQueue;
|
BLState->MicListenJobData.OutgoingMsgQueue = &BLState->OutgoingMsgQueue;
|
||||||
BLState->MicListenJobData.ListenSocket = CreateSocket(Context.SocketManager, "127.0.0.1", "20185");
|
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");
|
gs_const_string SculpturePath = ConstString("data/test_blumen.fold");
|
||||||
LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath, State->GlobalLog);
|
LoadAssembly(&State->Assemblies, &State->LedSystem, State->Transient, Context, SculpturePath, State->GlobalLog);
|
||||||
|
@ -172,13 +172,13 @@ BlumenLumen_CustomInit(app_state* State, context Context)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 temp = 0;
|
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
||||||
{
|
{
|
||||||
blumen_lumen_state* BLState = (blumen_lumen_state*)UserData.Memory;
|
blumen_lumen_state* BLState = (blumen_lumen_state*)UserData.Memory;
|
||||||
|
|
||||||
|
MotorTimeElapsed += Context->DeltaTime;
|
||||||
|
|
||||||
gs_string BlueString = MakeString("blue");
|
gs_string BlueString = MakeString("blue");
|
||||||
gs_string GreenString = MakeString("green");
|
gs_string GreenString = MakeString("green");
|
||||||
gs_string ILoveYouString = MakeString("i_love_you");
|
gs_string ILoveYouString = MakeString("i_love_you");
|
||||||
|
@ -208,6 +208,20 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MotorTimeElapsed > OpenClosePeriod)
|
||||||
|
{
|
||||||
|
// NOTE(pjs):
|
||||||
|
MotorTimeElapsed = 0;
|
||||||
|
u8 Position = LastPosition;
|
||||||
|
if (LastPosition == 2)
|
||||||
|
{
|
||||||
|
LastPosition = ClosedValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LastPosition = OpenValue;
|
||||||
|
}
|
||||||
|
|
||||||
if ((BLState->OutgoingMsgQueue.WriteHead >= BLState->OutgoingMsgQueue.ReadHead) ||
|
if ((BLState->OutgoingMsgQueue.WriteHead >= BLState->OutgoingMsgQueue.ReadHead) ||
|
||||||
(BLState->OutgoingMsgQueue.WriteHead < BLState->OutgoingMsgQueue.ReadHead))
|
(BLState->OutgoingMsgQueue.WriteHead < BLState->OutgoingMsgQueue.ReadHead))
|
||||||
{
|
{
|
||||||
|
@ -219,10 +233,9 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
||||||
*Msg = PushSizeToData(&State->Permanent, sizeof(motor_packet));
|
*Msg = PushSizeToData(&State->Permanent, sizeof(motor_packet));
|
||||||
}
|
}
|
||||||
motor_packet* Packet = (motor_packet*)Msg->Memory;
|
motor_packet* Packet = (motor_packet*)Msg->Memory;
|
||||||
Packet->FlowerPositions[0] = temp;
|
Packet->FlowerPositions[0] = Position;
|
||||||
Packet->FlowerPositions[1] = temp + 1;
|
Packet->FlowerPositions[1] = Position;
|
||||||
Packet->FlowerPositions[2] = temp + 2;
|
Packet->FlowerPositions[2] = Position;
|
||||||
temp++;
|
|
||||||
|
|
||||||
// NOTE(pjs): We increment the write head AFTER we've written so that
|
// NOTE(pjs): We increment the write head AFTER we've written so that
|
||||||
// the network thread doesn't think the buffer is ready to send before
|
// the network thread doesn't think the buffer is ready to send before
|
||||||
|
@ -237,6 +250,7 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
||||||
BLState->OutgoingMsgQueue.WriteHead = 0;
|
BLState->OutgoingMsgQueue.WriteHead = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal user_space_desc
|
internal user_space_desc
|
||||||
|
|
|
@ -53,6 +53,62 @@ struct blumen_lumen_state
|
||||||
platform_thread_handle MicListenThread;
|
platform_thread_handle MicListenThread;
|
||||||
mic_listen_job_data MicListenJobData;
|
mic_listen_job_data MicListenJobData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// If you change anything, exit lumenarium if its running
|
||||||
|
// then in this application hit f1 to compile then
|
||||||
|
// go to remedybg (the debugger) and hit f5
|
||||||
|
|
||||||
|
|
||||||
|
// don't touch this
|
||||||
|
u8 LastPosition = 1;
|
||||||
|
|
||||||
|
u8 ClosedValue = 1;
|
||||||
|
u8 OpenValue = 2;
|
||||||
|
|
||||||
|
|
||||||
|
r64 MotorTimeElapsed = 0;
|
||||||
|
r64 OpenClosePeriod = 15.0f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BLUMEN_LUMEN_H
|
#define BLUMEN_LUMEN_H
|
||||||
|
|
|
@ -154,21 +154,55 @@ Win32CreateSocket(platform_socket* Socket, char* Address, char* DefaultPort)
|
||||||
InvalidCodePath;
|
InvalidCodePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If iMode == 0, blocking is enabled
|
||||||
|
// if iMode != 0, non-blocking mode is enabled
|
||||||
|
u_long iMode = 1;
|
||||||
|
Error = ioctlsocket(SocketHandle, FIONBIO, &iMode);
|
||||||
|
if (Error != NO_ERROR)
|
||||||
|
{
|
||||||
|
InvalidCodePath;
|
||||||
|
}
|
||||||
|
|
||||||
Error = connect(SocketHandle, InfoAt->ai_addr, (int)InfoAt->ai_addrlen);
|
Error = connect(SocketHandle, InfoAt->ai_addr, (int)InfoAt->ai_addrlen);
|
||||||
if (Error == SOCKET_ERROR)
|
if (Error == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
u32 Status = WSAGetLastError();
|
||||||
|
if (Status == WSAEWOULDBLOCK)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
TIMEVAL Timeout = { 0, 500 };
|
||||||
|
fd_set SocketSet = {};
|
||||||
|
FD_ZERO(&SocketSet);
|
||||||
|
FD_SET(SocketHandle, &SocketSet);
|
||||||
|
Assert(FD_ISSET(SocketHandle, &SocketSet));
|
||||||
|
Status = select(0, &SocketSet, 0, 0, {});
|
||||||
|
if (Status == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (Status == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
closesocket(SocketHandle);
|
closesocket(SocketHandle);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
|
|
||||||
Socket->PlatformHandle = (u8*)Win32Alloc(sizeof(SOCKET), 0);
|
Socket->PlatformHandle = (u8*)Win32Alloc(sizeof(SOCKET), 0);
|
||||||
*(SOCKET*)Socket->PlatformHandle = SocketHandle;
|
*(SOCKET*)Socket->PlatformHandle = SocketHandle;
|
||||||
Result = true;
|
Result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Error = WSAGetLastError();
|
Error = WSAGetLastError();
|
||||||
|
@ -212,8 +246,15 @@ Win32SocketPeek(platform_socket* Socket)
|
||||||
{
|
{
|
||||||
// TODO(pjs): Error handling
|
// TODO(pjs): Error handling
|
||||||
s32 Error = WSAGetLastError();
|
s32 Error = WSAGetLastError();
|
||||||
|
if (Error == WSAEWOULDBLOCK)
|
||||||
|
{
|
||||||
|
// NOTE(pjs):
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
InvalidCodePath;
|
InvalidCodePath;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue