Remove controller-side LED count from Corsair Lighting Node and ThermalTake Riing controllers, initialize them to zero LED count
This commit is contained in:
parent
18c18e3999
commit
4919b03bd1
7 changed files with 84 additions and 59 deletions
|
|
@ -51,9 +51,6 @@ CorsairLightingNodeController::CorsairLightingNodeController(libusb_device_handl
|
|||
dev = dev_handle;
|
||||
endpoint = dev_endpoint;
|
||||
|
||||
channel_leds[0] = 60;
|
||||
channel_leds[1] = 60;
|
||||
|
||||
SendFirmwareRequest();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ public:
|
|||
);
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors);
|
||||
unsigned int channel_leds[CORSAIR_LIGHTING_NODE_NUM_CHANNELS];
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,6 @@ ThermaltakeRiingController::ThermaltakeRiingController(libusb_device_handle* dev
|
|||
dev = dev_handle;
|
||||
|
||||
SendInit();
|
||||
|
||||
channel_leds[0] = 9;
|
||||
channel_leds[1] = 9;
|
||||
channel_leds[2] = 9;
|
||||
channel_leds[3] = 0;
|
||||
channel_leds[4] = 0;
|
||||
}
|
||||
|
||||
ThermaltakeRiingController::~ThermaltakeRiingController()
|
||||
|
|
|
|||
|
|
@ -52,8 +52,6 @@ public:
|
|||
|
||||
void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors);
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
|
||||
unsigned int channel_leds[THERMALTAKE_NUM_CHANNELS];
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
|
|
|
|||
|
|
@ -167,47 +167,60 @@ RGBController_CorsairLightingNode::RGBController_CorsairLightingNode(CorsairLigh
|
|||
void RGBController_CorsairLightingNode::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing zone/LED configuration |
|
||||
| Only set LED count on the first run |
|
||||
\*-------------------------------------------------*/
|
||||
bool first_run = false;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
zones.clear();
|
||||
colors.clear();
|
||||
zones.resize(CORSAIR_LIGHTING_NODE_NUM_CHANNELS);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_LIGHTING_NODE_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
if(corsair->channel_leds[channel_idx] > 0)
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
|
||||
zones[channel_idx].name = "Corsair Channel ";
|
||||
zones[channel_idx].name.append(ch_idx_string);
|
||||
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 |
|
||||
\*-------------------------------------------------*/
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = 96;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
zones[channel_idx].leds_count = 0;
|
||||
}
|
||||
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
new_zone->name = "Corsair Channel ";
|
||||
new_zone->name.append(ch_idx_string);
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
led new_led;
|
||||
new_led.name = "Corsair Channel ";
|
||||
new_led.name.append(ch_idx_string);
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
|
||||
new_zone->leds_min = 0;
|
||||
new_zone->leds_max = 60;
|
||||
new_zone->leds_count = corsair->channel_leds[channel_idx];
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < corsair->channel_leds[channel_idx]; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "Corsair Channel ";
|
||||
new_led.name.append(ch_idx_string);
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
|
||||
leds.push_back(new_led);
|
||||
leds_channel.push_back(channel_idx);
|
||||
}
|
||||
|
||||
zones.push_back(*new_zone);
|
||||
leds.push_back(new_led);
|
||||
leds_channel.push_back(channel_idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -216,9 +229,12 @@ void RGBController_CorsairLightingNode::SetupZones()
|
|||
|
||||
void RGBController_CorsairLightingNode::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
corsair->channel_leds[zone] = new_size;
|
||||
if((new_size >= zones[zone].leds_min) && (new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairLightingNode::UpdateLEDs()
|
||||
|
|
|
|||
|
|
@ -107,30 +107,47 @@ RGBController_ThermaltakeRiing::RGBController_ThermaltakeRiing(ThermaltakeRiingC
|
|||
void RGBController_ThermaltakeRiing::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing zone/LED configuration |
|
||||
| Only set LED count on the first run |
|
||||
\*-------------------------------------------------*/
|
||||
bool first_run = false;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
zones.clear();
|
||||
colors.clear();
|
||||
zones.resize(THERMALTAKE_NUM_CHANNELS);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
for (unsigned int channel_idx = 0; channel_idx < THERMALTAKE_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
|
||||
new_zone->name = "Riing Channel ";
|
||||
new_zone->name.append(ch_idx_string);
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
zones[channel_idx].name = "Riing Channel ";
|
||||
zones[channel_idx].name.append(ch_idx_string);
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
|
||||
new_zone->leds_min = 0;
|
||||
new_zone->leds_max = 20;
|
||||
new_zone->leds_count = riing->channel_leds[channel_idx];
|
||||
/*-------------------------------------------------*\
|
||||
| The maximum number of colors that would fit in the|
|
||||
| Riing protocol is 20 |
|
||||
\*-------------------------------------------------*/
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = 20;
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < riing->channel_leds[channel_idx]; led_ch_idx++)
|
||||
if(first_run)
|
||||
{
|
||||
zones[channel_idx].leds_count = 0;
|
||||
}
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
|
@ -144,8 +161,6 @@ void RGBController_ThermaltakeRiing::SetupZones()
|
|||
leds.push_back(new_led);
|
||||
leds_channel.push_back(channel_idx);
|
||||
}
|
||||
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
|
|
@ -153,9 +168,12 @@ void RGBController_ThermaltakeRiing::SetupZones()
|
|||
|
||||
void RGBController_ThermaltakeRiing::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
riing->channel_leds[zone] = new_size;
|
||||
if((new_size >= zones[zone].leds_min) && (new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_ThermaltakeRiing::UpdateLEDs()
|
||||
|
|
|
|||
|
|
@ -162,7 +162,10 @@ void Ui::OpenRGBDevicePage::on_LEDBox_currentIndexChanged(int index)
|
|||
{
|
||||
selected_zone = selected_zone - 1;
|
||||
|
||||
color = device->zones[selected_zone].colors[index];
|
||||
if(index < device->zones[selected_zone].leds_count)
|
||||
{
|
||||
color = device->zones[selected_zone].colors[index];
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue