Added brightness to profile loading and saving
* Bumped profile version to 3 * Loading a v1/v2 profile onto a device with brightness will work * Loading a v3 profile onto a device without brightness also works * Add profile version parameter to Get/SetModeDescription Commit amended for code style and to update versioning by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
6fd2ea9276
commit
a46eccef3c
6 changed files with 130 additions and 20 deletions
|
|
@ -90,9 +90,18 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
|
|||
data_size += sizeof(modes[mode_index].flags);
|
||||
data_size += sizeof(modes[mode_index].speed_min);
|
||||
data_size += sizeof(modes[mode_index].speed_max);
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
data_size += sizeof(modes[mode_index].brightness_min);
|
||||
data_size += sizeof(modes[mode_index].brightness_max);
|
||||
}
|
||||
data_size += sizeof(modes[mode_index].colors_min);
|
||||
data_size += sizeof(modes[mode_index].colors_max);
|
||||
data_size += sizeof(modes[mode_index].speed);
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
data_size += sizeof(modes[mode_index].brightness);
|
||||
}
|
||||
data_size += sizeof(modes[mode_index].direction);
|
||||
data_size += sizeof(modes[mode_index].color_mode);
|
||||
data_size += sizeof(mode_num_colors[mode_index]);
|
||||
|
|
@ -262,6 +271,19 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
|
|||
memcpy(&data_buf[data_ptr], &modes[mode_index].speed_max, sizeof(modes[mode_index].speed_max));
|
||||
data_ptr += sizeof(modes[mode_index].speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness_min and brightness_max (data) if |
|
||||
| protocol 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&data_buf[data_ptr], &modes[mode_index].brightness_min, sizeof(modes[mode_index].brightness_min));
|
||||
data_ptr += sizeof(modes[mode_index].brightness_min);
|
||||
|
||||
memcpy(&data_buf[data_ptr], &modes[mode_index].brightness_max, sizeof(modes[mode_index].brightness_max));
|
||||
data_ptr += sizeof(modes[mode_index].brightness_max);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -280,6 +302,15 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
|
|||
memcpy(&data_buf[data_ptr], &modes[mode_index].speed, sizeof(modes[mode_index].speed));
|
||||
data_ptr += sizeof(modes[mode_index].speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness (data) if protocol 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&data_buf[data_ptr], &modes[mode_index].brightness, sizeof(modes[mode_index].brightness));
|
||||
data_ptr += sizeof(modes[mode_index].brightness);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -468,7 +499,7 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
|
|||
data_ptr += name_len;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in vendor if profile version is 1 or higher |
|
||||
| Copy in vendor if protocol version is 1 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 1)
|
||||
{
|
||||
|
|
@ -574,6 +605,19 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
|
|||
memcpy(&new_mode.speed_max, &data_buf[data_ptr], sizeof(new_mode.speed_max));
|
||||
data_ptr += sizeof(new_mode.speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness min and max if protocol version |
|
||||
| is 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&new_mode.brightness_min, &data_buf[data_ptr], sizeof(new_mode.brightness_min));
|
||||
data_ptr += sizeof(new_mode.brightness_min);
|
||||
|
||||
memcpy(&new_mode.brightness_max, &data_buf[data_ptr], sizeof(new_mode.brightness_max));
|
||||
data_ptr += sizeof(new_mode.brightness_max);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -592,6 +636,15 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
|
|||
memcpy(&new_mode.speed, &data_buf[data_ptr], sizeof(new_mode.speed));
|
||||
data_ptr += sizeof(new_mode.speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness if protocol version is 3 or higher|
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&new_mode.brightness, &data_buf[data_ptr], sizeof(new_mode.brightness));
|
||||
data_ptr += sizeof(new_mode.brightness);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -790,7 +843,7 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
|
|||
SetupColors();
|
||||
}
|
||||
|
||||
unsigned char * RGBController::GetModeDescription(int mode)
|
||||
unsigned char * RGBController::GetModeDescription(int mode, unsigned int protocol_version)
|
||||
{
|
||||
unsigned int data_ptr = 0;
|
||||
unsigned int data_size = 0;
|
||||
|
|
@ -812,9 +865,18 @@ unsigned char * RGBController::GetModeDescription(int mode)
|
|||
data_size += sizeof(modes[mode].flags);
|
||||
data_size += sizeof(modes[mode].speed_min);
|
||||
data_size += sizeof(modes[mode].speed_max);
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
data_size += sizeof(modes[mode].brightness_min);
|
||||
data_size += sizeof(modes[mode].brightness_max);
|
||||
}
|
||||
data_size += sizeof(modes[mode].colors_min);
|
||||
data_size += sizeof(modes[mode].colors_max);
|
||||
data_size += sizeof(modes[mode].speed);
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
data_size += sizeof(modes[mode].brightness);
|
||||
}
|
||||
data_size += sizeof(modes[mode].direction);
|
||||
data_size += sizeof(modes[mode].color_mode);
|
||||
data_size += sizeof(mode_num_colors);
|
||||
|
|
@ -870,6 +932,19 @@ unsigned char * RGBController::GetModeDescription(int mode)
|
|||
memcpy(&data_buf[data_ptr], &modes[mode].speed_max, sizeof(modes[mode].speed_max));
|
||||
data_ptr += sizeof(modes[mode].speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness min and max if protocol version |
|
||||
| is 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].brightness_min, sizeof(modes[mode].brightness_min));
|
||||
data_ptr += sizeof(modes[mode].brightness_min);
|
||||
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].brightness_max, sizeof(modes[mode].brightness_max));
|
||||
data_ptr += sizeof(modes[mode].brightness_max);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -888,6 +963,15 @@ unsigned char * RGBController::GetModeDescription(int mode)
|
|||
memcpy(&data_buf[data_ptr], &modes[mode].speed, sizeof(modes[mode].speed));
|
||||
data_ptr += sizeof(modes[mode].speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness if protocol version is 3 or higher|
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].brightness, sizeof(modes[mode].brightness));
|
||||
data_ptr += sizeof(modes[mode].brightness);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -921,7 +1005,7 @@ unsigned char * RGBController::GetModeDescription(int mode)
|
|||
return(data_buf);
|
||||
}
|
||||
|
||||
void RGBController::SetModeDescription(unsigned char* data_buf)
|
||||
void RGBController::SetModeDescription(unsigned char* data_buf, unsigned int protocol_version)
|
||||
{
|
||||
int mode_idx;
|
||||
unsigned int data_ptr = sizeof(unsigned int);
|
||||
|
|
@ -984,6 +1068,19 @@ void RGBController::SetModeDescription(unsigned char* data_buf)
|
|||
memcpy(&new_mode->speed_max, &data_buf[data_ptr], sizeof(new_mode->speed_max));
|
||||
data_ptr += sizeof(new_mode->speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness_min and brightness_max (data) if |
|
||||
| protocol 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&new_mode->brightness_min, &data_buf[data_ptr], sizeof(new_mode->brightness_min));
|
||||
data_ptr += sizeof(new_mode->brightness_min);
|
||||
|
||||
memcpy(&new_mode->brightness_max, &data_buf[data_ptr], sizeof(new_mode->brightness_max));
|
||||
data_ptr += sizeof(new_mode->brightness_max);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -1002,6 +1099,15 @@ void RGBController::SetModeDescription(unsigned char* data_buf)
|
|||
memcpy(&new_mode->speed, &data_buf[data_ptr], sizeof(new_mode->speed));
|
||||
data_ptr += sizeof(new_mode->speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness (data) if protocol 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&new_mode->brightness, &data_buf[data_ptr], sizeof(new_mode->brightness));
|
||||
data_ptr += sizeof(new_mode->brightness);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue