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
{

View file

@ -215,6 +215,19 @@ enum
DEVICE_TYPE_UNKNOWN,
};
/*------------------------------------------------------------------*\
| Controller Flags |
\*------------------------------------------------------------------*/
enum
{
CONTROLLER_FLAG_LOCAL = (1 << 0), /* Device is local to this instance */
CONTROLLER_FLAG_REMOTE = (1 << 1), /* Device is on a remote instance */
CONTROLLER_FLAG_VIRTUAL = (1 << 2), /* Device is a virtual device */
CONTROLLER_FLAG_RESET_BEFORE_UPDATE = (1 << 8), /* Device resets update flag before */
/* calling update function */
};
/*------------------------------------------------------------------*\
| RGBController Callback Types |
\*------------------------------------------------------------------*/
@ -313,6 +326,7 @@ public:
int active_mode = 0;/* active mode */
std::vector<std::string>
led_alt_names; /* alternate LED names */
unsigned int flags; /* controller flags */
/*---------------------------------------------------------*\
| RGBController base class constructor |