diff --git a/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp b/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp index 487d2ffd..e249c248 100644 --- a/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp +++ b/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp @@ -51,9 +51,6 @@ CorsairLightingNodeController::CorsairLightingNodeController(libusb_device_handl dev = dev_handle; endpoint = dev_endpoint; - channel_leds[0] = 60; - channel_leds[1] = 60; - SendFirmwareRequest(); /*-----------------------------------------------------*\ diff --git a/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h b/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h index 6a03f0de..e02a58de 100644 --- a/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h +++ b/Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h @@ -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(); diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp index f0e4ab1c..78b13e18 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp @@ -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() diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h index 24229e87..2614664b 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h @@ -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; diff --git a/RGBController/RGBController_CorsairLightingNode.cpp b/RGBController/RGBController_CorsairLightingNode.cpp index 49ba6495..010a0b35 100644 --- a/RGBController/RGBController_CorsairLightingNode.cpp +++ b/RGBController/RGBController_CorsairLightingNode.cpp @@ -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() diff --git a/RGBController/RGBController_ThermaltakeRiing.cpp b/RGBController/RGBController_ThermaltakeRiing.cpp index a30a0bb6..d7051f46 100644 --- a/RGBController/RGBController_ThermaltakeRiing.cpp +++ b/RGBController/RGBController_ThermaltakeRiing.cpp @@ -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() diff --git a/qt/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage.cpp index d822abec..539b9808 100644 --- a/qt/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage.cpp @@ -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]; + } } /*-----------------------------------------------------*\