Lumenarium now repeatedly sends the current motor position desired based on a variable in settings
This commit is contained in:
parent
fae031b746
commit
37c30e1cb2
|
@ -616,6 +616,10 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
|||
if (MessageQueue_CanWrite(BLState->OutgoingMsgQueue) &&
|
||||
!BLState->IgnoreTimeOfDay_MotorState)
|
||||
{
|
||||
u64 NanosSinceLastSend = Context->SystemTime_Current.NanosSinceEpoch - BLState->LastSendTime.NanosSinceEpoch;
|
||||
r32 SecondsSinceLastSend = (r64)NanosSinceLastSend * NanosToSeconds;
|
||||
bool ShouldSendCurrentState = SecondsSinceLastSend >= MotorResendStatePeriod;
|
||||
|
||||
for (u32 i = 0; i < MotorOpenTimesCount; i++)
|
||||
{
|
||||
time_range Range = MotorOpenTimes[i];
|
||||
|
@ -626,9 +630,13 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
|||
|
||||
bool LastTimeInRange = SystemTimeIsInTimeRange(Context->SystemTime_Last, Range);
|
||||
|
||||
#if 0
|
||||
bool SendOpen = CurrTimeInRange && !LastSendTimeInRange;
|
||||
bool SendClose = !CurrTimeInRange && LastSendTimeInRange;
|
||||
|
||||
#else
|
||||
bool SendOpen = CurrTimeInRange && ShouldSendCurrentState;
|
||||
bool SendClose = !CurrTimeInRange && ShouldSendCurrentState;
|
||||
#endif
|
||||
//SendOpen = SecondsSinceLastSend > 2;
|
||||
if (SendOpen)
|
||||
{
|
||||
|
@ -643,6 +651,7 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
|||
Packet.MotorPacket.FlowerPositions[1] = 2;
|
||||
Packet.MotorPacket.FlowerPositions[2] = 2;
|
||||
MotorCommand = Packet;
|
||||
break;
|
||||
}
|
||||
else if (SendClose)
|
||||
{
|
||||
|
@ -656,6 +665,7 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
|||
Packet.MotorPacket.FlowerPositions[1] = 1;
|
||||
Packet.MotorPacket.FlowerPositions[2] = 1;
|
||||
MotorCommand = Packet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,11 @@ global time_range MotorOpenTimes[] = {
|
|||
};
|
||||
global u32 MotorOpenTimesCount = CArrayLength(MotorOpenTimes); // do not edit
|
||||
|
||||
// Lumenarium repeatedly resends the current motor state to the python
|
||||
// server. This variable determines how much time elapses between each
|
||||
// message.
|
||||
global r32 MotorResendStatePeriod = 90.0f; // seconds
|
||||
|
||||
// The times of day when the leds should be on
|
||||
// Search for @TimeFormat to find documentation
|
||||
global time_range LedOnTimes[] = {
|
||||
|
|
Loading…
Reference in New Issue