Add controller flags field with flags for controller location and update behavior

This commit is contained in:
Adam Honse 2024-11-11 20:21:32 -06:00
parent 1967ec9526
commit bb79fbfc07
5 changed files with 75 additions and 5 deletions

View file

@ -58,6 +58,7 @@ zone::~zone()
RGBController::RGBController()
{
flags = 0;
DeviceThreadRunning = true;
DeviceCallThread = new std::thread(&RGBController::DeviceCallThreadFunction, this);
}
@ -288,6 +289,14 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
}
}
/*---------------------------------------------------------*\
| Controller flags |
\*---------------------------------------------------------*/
if(protocol_version >= 5)
{
data_size += sizeof(flags);
}
data_size += sizeof(num_colors);
data_size += num_colors * sizeof(RGBColor);
@ -731,6 +740,15 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
}
}
/*---------------------------------------------------------*\
| Controller flags data |
\*---------------------------------------------------------*/
if(protocol_version >= 5)
{
memcpy(&data_buf[data_ptr], &flags, sizeof(flags));
data_ptr += sizeof(flags);
}
delete[] mode_name_len;
delete[] zone_name_len;
delete[] led_name_len;
@ -1188,6 +1206,15 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
}
}
/*---------------------------------------------------------*\
| Copy in controller flags data |
\*---------------------------------------------------------*/
if(protocol_version >= 5)
{
memcpy(&flags, &data_buf[data_ptr], sizeof(flags));
data_ptr += sizeof(flags);
}
/*---------------------------------------------------------*\
| Setup colors |
\*---------------------------------------------------------*/
@ -2090,13 +2117,29 @@ void RGBController::DeviceCallThreadFunction()
{
if(CallFlag_UpdateMode.load() == true)
{
DeviceUpdateMode();
CallFlag_UpdateMode = false;
if(flags & CONTROLLER_FLAG_RESET_BEFORE_UPDATE)
{
CallFlag_UpdateMode = false;
DeviceUpdateMode();
}
else
{
DeviceUpdateMode();
CallFlag_UpdateMode = false;
}
}
if(CallFlag_UpdateLEDs.load() == true)
{
DeviceUpdateLEDs();
CallFlag_UpdateLEDs = false;
if(flags & CONTROLLER_FLAG_RESET_BEFORE_UPDATE)
{
CallFlag_UpdateLEDs = false;
DeviceUpdateLEDs();
}
else
{
DeviceUpdateLEDs();
CallFlag_UpdateLEDs = false;
}
}
else
{