Allow up to 200 LEDs per channel on Corsair Lighting Node devices

This commit is contained in:
Adam Honse 2020-04-02 16:23:55 -05:00
parent c7b9fe90a6
commit 7f865cfee9
2 changed files with 31 additions and 109 deletions

View file

@ -151,8 +151,12 @@ void CorsairLightingNodeController::SetChannelEffect(unsigned char channel,
void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
{
unsigned char color_data[50];
unsigned char pkt_max;
unsigned char red_color_data[50];
unsigned char grn_color_data[50];
unsigned char blu_color_data[50];
unsigned char pkt_offset = 0;
unsigned char pkt_size = 0;
unsigned int colors_remaining = num_colors;
/*-----------------------------------------------------*\
| Send Port State packet |
@ -160,114 +164,32 @@ void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBCol
SendPortState(channel, CORSAIR_LIGHTING_NODE_PORT_STATE_SOFTWARE);
/*-----------------------------------------------------*\
| Send red channel packet 1 |
| Loop through colors and send 50 at a time |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > num_colors)
while(colors_remaining > 0)
{
pkt_max = (unsigned char)num_colors;
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetRValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED, color_data);
/*-----------------------------------------------------*\
| Send red channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (num_colors > 50)
{
pkt_max = (unsigned char)(num_colors - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
if(colors_remaining < 50)
{
color_data[idx] = RGBGetRValue(colors[idx+50]);
pkt_size = colors_remaining;
}
else
{
pkt_size = 50;
}
for(int color_idx = 0; color_idx < pkt_size; color_idx++)
{
red_color_data[color_idx] = RGBGetRValue(colors[pkt_offset + color_idx]);
grn_color_data[color_idx] = RGBGetGValue(colors[pkt_offset + color_idx]);
blu_color_data[color_idx] = RGBGetBValue(colors[pkt_offset + color_idx]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED, color_data);
}
SendDirect(channel, pkt_offset, pkt_size, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED, red_color_data);
SendDirect(channel, pkt_offset, pkt_size, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN, grn_color_data);
SendDirect(channel, pkt_offset, pkt_size, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE, blu_color_data);
/*-----------------------------------------------------*\
| Send green channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > num_colors)
{
pkt_max = (unsigned char)num_colors;
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetGValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN, color_data);
/*-----------------------------------------------------*\
| Send green channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (num_colors > 50)
{
pkt_max = (unsigned char)(num_colors - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetGValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN, color_data);
}
/*-----------------------------------------------------*\
| Send blue channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > num_colors)
{
pkt_max = (unsigned char)num_colors;
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetBValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE, color_data);
/*-----------------------------------------------------*\
| Send blue channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (num_colors > 50)
{
pkt_max = (unsigned char)(num_colors - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetBValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE, color_data);
colors_remaining -= pkt_size;
pkt_offset += pkt_size;
}
/*-----------------------------------------------------*\

View file

@ -196,12 +196,12 @@ void RGBController_CorsairLightingNode::SetupZones()
zones[channel_idx].type = ZONE_TYPE_LINEAR;
/*-------------------------------------------------*\
| According to some research on Corsair forums, the |
| maximum number of LEDs supported by Corsair Link |
| devices is 96 |
| I did some experimenting and determined that the |
| maximum number of LEDs the Corsair Commander Pro |
| can support is 200. |
\*-------------------------------------------------*/
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = 96;
zones[channel_idx].leds_max = 200;
if(first_run)
{
@ -210,7 +210,7 @@ void RGBController_CorsairLightingNode::SetupZones()
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
{
char led_idx_string[3];
char led_idx_string[4];
sprintf(led_idx_string, "%d", led_ch_idx + 1);
led new_led;