diff --git a/Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.cpp b/Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.cpp index 2e2ff5291..d65c713d7 100755 --- a/Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.cpp +++ b/Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.cpp @@ -194,6 +194,16 @@ RGBController_PolychromeUSB::~RGBController_PolychromeUSB() void RGBController_PolychromeUSB::SetupZones() { + /*-----------------------------------------------------*\ + | 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 | \*-------------------------------------------------*/ @@ -204,28 +214,54 @@ void RGBController_PolychromeUSB::SetupZones() /*-------------------------------------------------*\ | Set zones and leds | \*-------------------------------------------------*/ - for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++) + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) { PolychromeDeviceInfo device_info = controller->GetPolychromeDevices()[channel_idx]; - zones[channel_idx].type = ZONE_TYPE_LINEAR; - if(device_info.device_type== PolychromeDeviceType::ADDRESSABLE) { - zones[channel_idx].name = polychrome_USB_zone_names[device_info.zone_type]; - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = ASROCK_ADDRESSABLE_MAX_LEDS; - zones[channel_idx].leds_count = device_info.num_leds; + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = ASROCK_ADDRESSABLE_MAX_LEDS; + + if(first_run) + { + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = polychrome_USB_zone_names[device_info.zone_type]; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = device_info.num_leds; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); + } } else if(device_info.device_type==PolychromeDeviceType::FIXED) { - zones[channel_idx].name = polychrome_USB_zone_names[device_info.zone_type]; - zones[channel_idx].leds_min = device_info.num_leds; - zones[channel_idx].leds_max = device_info.num_leds; - zones[channel_idx].leds_count = device_info.num_leds; + zones[channel_idx].name = polychrome_USB_zone_names[device_info.zone_type]; + zones[channel_idx].type = ZONE_TYPE_LINEAR; + zones[channel_idx].leds_min = device_info.num_leds; + zones[channel_idx].leds_max = device_info.num_leds; + zones[channel_idx].leds_count = device_info.num_leds; } - for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { led new_led; @@ -278,10 +314,14 @@ void RGBController_PolychromeUSB::SetupZones() } } -void RGBController_PolychromeUSB::DeviceResizeZone(int zone, int new_size) +void RGBController_PolychromeUSB::DeviceConfigureZone(int zone_idx) { - zones[zone].leds_count = (unsigned char) new_size; - controller->SetZoneSize(zones_info[zone].zone, new_size); + if((size_t)zone_idx < zones.size()) + { + controller->SetZoneSize(zones_info[zone_idx].zone, zones[zone_idx].leds_count); + + SetupZones(); + } } void RGBController_PolychromeUSB::DeviceUpdateLEDs() diff --git a/Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.h b/Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.h index 859782565..b37b9ed92 100755 --- a/Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.h +++ b/Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.h @@ -23,7 +23,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/ASRockSMBusController/ASRockPolychromeV1SMBusController/RGBController_ASRockPolychromeV1SMBus.cpp b/Controllers/ASRockSMBusController/ASRockPolychromeV1SMBusController/RGBController_ASRockPolychromeV1SMBus.cpp index 5a065c12c..90a42b482 100644 --- a/Controllers/ASRockSMBusController/ASRockPolychromeV1SMBusController/RGBController_ASRockPolychromeV1SMBus.cpp +++ b/Controllers/ASRockSMBusController/ASRockPolychromeV1SMBusController/RGBController_ASRockPolychromeV1SMBus.cpp @@ -298,10 +298,9 @@ void RGBController_ASRockPolychromeV1SMBus::SetupZones() SetupColors(); } -void RGBController_ASRockPolychromeV1SMBus::DeviceResizeZone(int zone, int new_size) +void RGBController_ASRockPolychromeV1SMBus::DeviceConfigureZone(int zone_idx) { - LOG_TRACE("[%s] DeviceResizeZone(%02X, %02X)", name.c_str(), zone, new_size); - controller-> SetARGBSize(new_size & 0xFF); + controller-> SetARGBSize(zones[zone_idx].leds_count & 0xFF); zones[POLYCHROME_V1_ZONE_ADDRESSABLE].leds_count = 1; } diff --git a/Controllers/ASRockSMBusController/ASRockPolychromeV1SMBusController/RGBController_ASRockPolychromeV1SMBus.h b/Controllers/ASRockSMBusController/ASRockPolychromeV1SMBusController/RGBController_ASRockPolychromeV1SMBus.h index 0190df099..5f7fa2845 100644 --- a/Controllers/ASRockSMBusController/ASRockPolychromeV1SMBusController/RGBController_ASRockPolychromeV1SMBus.h +++ b/Controllers/ASRockSMBusController/ASRockPolychromeV1SMBusController/RGBController_ASRockPolychromeV1SMBus.h @@ -23,7 +23,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/ASRockSMBusController/ASRockPolychromeV2SMBusController/RGBController_ASRockPolychromeV2SMBus.cpp b/Controllers/ASRockSMBusController/ASRockPolychromeV2SMBusController/RGBController_ASRockPolychromeV2SMBus.cpp index 46d18da4d..5edd065b8 100644 --- a/Controllers/ASRockSMBusController/ASRockPolychromeV2SMBusController/RGBController_ASRockPolychromeV2SMBus.cpp +++ b/Controllers/ASRockSMBusController/ASRockPolychromeV2SMBusController/RGBController_ASRockPolychromeV2SMBus.cpp @@ -281,7 +281,7 @@ void RGBController_ASRockPolychromeV2SMBus::SetupZones() SetupColors(); } -void RGBController_ASRockPolychromeV2SMBus::DeviceResizeZone(int /*zone*/, int /*new_size*/) +void RGBController_ASRockPolychromeV2SMBus::DeviceConfigureZone(int /*zone_idx*/) { /*---------------------------------------------------------*\ | This device does not support resizing zones | diff --git a/Controllers/ASRockSMBusController/ASRockPolychromeV2SMBusController/RGBController_ASRockPolychromeV2SMBus.h b/Controllers/ASRockSMBusController/ASRockPolychromeV2SMBusController/RGBController_ASRockPolychromeV2SMBus.h index 53b2365a6..e2332dd51 100644 --- a/Controllers/ASRockSMBusController/ASRockPolychromeV2SMBusController/RGBController_ASRockPolychromeV2SMBus.h +++ b/Controllers/ASRockSMBusController/ASRockPolychromeV2SMBusController/RGBController_ASRockPolychromeV2SMBus.h @@ -23,7 +23,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/AsusAuraUSBController/AsusAuraUSBController/RGBController_AsusAuraUSB.cpp b/Controllers/AsusAuraUSBController/AsusAuraUSBController/RGBController_AsusAuraUSB.cpp index 3d1405c21..21c31bbd6 100644 --- a/Controllers/AsusAuraUSBController/AsusAuraUSBController/RGBController_AsusAuraUSB.cpp +++ b/Controllers/AsusAuraUSBController/AsusAuraUSBController/RGBController_AsusAuraUSB.cpp @@ -147,41 +147,67 @@ void RGBController_AuraUSB::SetupZones() | Set zones and leds | \*-------------------------------------------------*/ int addressableCounter = 1; - for (unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++) + + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) { AuraDeviceInfo device_info = controller->GetAuraDevices()[channel_idx]; - zones[channel_idx].type = ZONE_TYPE_LINEAR; - if(device_info.device_type == AuraDeviceType::FIXED) { - zones[channel_idx].name = "Aura Mainboard"; - zones[channel_idx].leds_min = device_info.num_leds; - zones[channel_idx].leds_max = device_info.num_leds; - zones[channel_idx].leds_count = device_info.num_leds; + zones[channel_idx].name = "Aura Mainboard"; + zones[channel_idx].type = ZONE_TYPE_LINEAR; + zones[channel_idx].leds_min = device_info.num_leds; + zones[channel_idx].leds_max = device_info.num_leds; + zones[channel_idx].leds_count = device_info.num_leds; } else { - zones[channel_idx].name = "Aura Addressable "; - zones[channel_idx].name.append(std::to_string(addressableCounter)); - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = AURA_ADDRESSABLE_MAX_LEDS; - - addressableCounter++; + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = AURA_ADDRESSABLE_MAX_LEDS; if(first_run) { - zones[channel_idx].leds_count = 0; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = "Addressable RGB Header "; + zones[channel_idx].name.append(std::to_string(addressableCounter)); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); + } + + addressableCounter++; } unsigned int num_mainboard_leds = device_info.num_leds - device_info.num_headers; - for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { unsigned led_idx = led_ch_idx + 1; led new_led; new_led.name = zones[channel_idx].name; + if(device_info.device_type == AuraDeviceType::FIXED && led_ch_idx >= num_mainboard_leds) { new_led.name.append(", RGB Header "); @@ -191,6 +217,7 @@ void RGBController_AuraUSB::SetupZones() { new_led.name.append(", LED "); } + new_led.name.append(std::to_string(led_idx)); new_led.value = channel_idx; @@ -202,17 +229,10 @@ void RGBController_AuraUSB::SetupZones() SetupColors(); } -void RGBController_AuraUSB::DeviceResizeZone(int zone, int new_size) +void RGBController_AuraUSB::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/AsusAuraUSBController/AsusAuraUSBController/RGBController_AsusAuraUSB.h b/Controllers/AsusAuraUSBController/AsusAuraUSBController/RGBController_AsusAuraUSB.h index e249c333d..4ce8d875e 100644 --- a/Controllers/AsusAuraUSBController/AsusAuraUSBController/RGBController_AsusAuraUSB.h +++ b/Controllers/AsusAuraUSBController/AsusAuraUSBController/RGBController_AsusAuraUSB.h @@ -24,7 +24,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/BlinkyTapeController/RGBController_BlinkyTape.cpp b/Controllers/BlinkyTapeController/RGBController_BlinkyTape.cpp index 0835df071..154642bfd 100644 --- a/Controllers/BlinkyTapeController/RGBController_BlinkyTape.cpp +++ b/Controllers/BlinkyTapeController/RGBController_BlinkyTape.cpp @@ -51,81 +51,82 @@ RGBController_BlinkyTape::~RGBController_BlinkyTape() void RGBController_BlinkyTape::SetupZones() { - zones.clear(); + /*-------------------------------------------------*\ + | 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(); + colors.clear(); + zones.resize(1); - zone led_zone; - led_zone.name = "LED Strip"; - led_zone.type = ZONE_TYPE_LINEAR; - led_zone.leds_min = 0; - led_zone.leds_max = 512; - led_zone.leds_count = 0; - zones.push_back(led_zone); + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + zones[0].leds_min = 0; + zones[0].leds_max = 512; - DeviceResizeZone(0, led_zone.leds_count); -} - -void RGBController_BlinkyTape::DeviceResizeZone(int zone, int new_size) -{ - /*-------------------------------------------------*\ - | Explicitly cast these to avoid compiler warnings | - \*-------------------------------------------------*/ - const unsigned int zone_u = static_cast(zone); - const unsigned int new_size_u = static_cast(new_size); - - /*-------------------------------------------------*\ - | Check that the zone is in bounds | - \*-------------------------------------------------*/ - if((zone_u > zones.size()) || (zone < 0)) + if(first_run) { - return; + zones[0].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - /*-------------------------------------------------*\ - | And that the new size is in bounds | - \*-------------------------------------------------*/ - if((new_size_u > zones.at(zone).leds_max) || (new_size_u < zones.at(zone).leds_min)) + if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) { - return; + zones[0].name = "Addressable RGB Header"; } - /*-------------------------------------------------*\ - | And that there's actually a change | - \*-------------------------------------------------*/ - if(zones.at(zone).leds_count == new_size_u) + if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) { - return; + zones[0].leds_count = 0; } - /*-------------------------------------------------*\ - | If the new size is less than the current size, | - | just chop off the end | - \*-------------------------------------------------*/ - if(leds.size() > new_size_u) + if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) { - leds.resize(new_size); + zones[0].type = ZONE_TYPE_LINEAR; } - /*-------------------------------------------------*\ - | Otherwise, add new LEDs to the end | - \*-------------------------------------------------*/ - if(leds.size() < new_size_u) + if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) { - for(size_t led_idx = leds.size(); led_idx < new_size_u; led_idx++) - { - led new_led; - new_led.name = "LED "; - new_led.name.append(std::to_string(led_idx)); - - leds.push_back(new_led); - } + zones[0].matrix_map.width = 0; + zones[0].matrix_map.height = 0; + zones[0].matrix_map.map.resize(0); } - zones.at(zone).leds_count = new_size; + /*-----------------------------------------------------*\ + | Set up LEDs | + \*-----------------------------------------------------*/ + for(size_t led_idx = leds.size(); led_idx < zones[0].leds_count; led_idx++) + { + led new_led; + new_led.name = zones[0].name + ", LED "; + new_led.name.append(std::to_string(led_idx)); + + leds.push_back(new_led); + } SetupColors(); } +void RGBController_BlinkyTape::DeviceConfigureZone(int zone_idx) +{ + if((size_t)zone_idx < zones.size()) + { + SetupZones(); + } +} + void RGBController_BlinkyTape::DeviceUpdateLEDs() { controller->SetLEDs(colors); diff --git a/Controllers/BlinkyTapeController/RGBController_BlinkyTape.h b/Controllers/BlinkyTapeController/RGBController_BlinkyTape.h index 3efa151ab..401f701bc 100644 --- a/Controllers/BlinkyTapeController/RGBController_BlinkyTape.h +++ b/Controllers/BlinkyTapeController/RGBController_BlinkyTape.h @@ -23,7 +23,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/CoolerMasterController/CMARGBController/RGBController_CMARGBController.cpp b/Controllers/CoolerMasterController/CMARGBController/RGBController_CMARGBController.cpp index 0e4a43695..6669bb29d 100644 --- a/Controllers/CoolerMasterController/CMARGBController/RGBController_CMARGBController.cpp +++ b/Controllers/CoolerMasterController/CMARGBController/RGBController_CMARGBController.cpp @@ -398,29 +398,46 @@ void RGBController_CMARGBController::SetupZones() \*-----------------------------------------------------*/ for(unsigned int channel_idx = 0; channel_idx < 4; channel_idx++) { - char ch_idx_string[2]; - snprintf(ch_idx_string, 2, "%d", channel_idx + 1); - - zones[channel_idx].name = "Addressable RGB Header "; - zones[channel_idx].name.append(ch_idx_string); - zones[channel_idx].type = ZONE_TYPE_LINEAR; - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = 48; + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = 48; if(first_run) { - zones[channel_idx].leds_count = 0; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = "Addressable RGB Header "; + zones[channel_idx].name.append(std::to_string(channel_idx + 1)); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); } for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { - char led_idx_string[4]; - snprintf(led_idx_string, 4, "%d", led_ch_idx + 1); - led new_led; new_led.name = zones[channel_idx].name; new_led.name.append(", LED "); - new_led.name.append(led_idx_string); + new_led.name.append(std::to_string(led_ch_idx + 1)); new_led.value = channel_idx; leds.push_back(new_led); @@ -444,18 +461,11 @@ void RGBController_CMARGBController::SetupZones() SetupColors(); } -void RGBController_CMARGBController::DeviceResizeZone(int zone, int new_size) +void RGBController_CMARGBController::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - - controller->SetPortLEDCount(zone, zones[zone].leds_count); + controller->SetPortLEDCount(zone_idx, zones[zone_idx].leds_count); SetupZones(); } diff --git a/Controllers/CoolerMasterController/CMARGBController/RGBController_CMARGBController.h b/Controllers/CoolerMasterController/CMARGBController/RGBController_CMARGBController.h index 612a945aa..72f8fe2fc 100644 --- a/Controllers/CoolerMasterController/CMARGBController/RGBController_CMARGBController.h +++ b/Controllers/CoolerMasterController/CMARGBController/RGBController_CMARGBController.h @@ -24,7 +24,7 @@ public: void SetupModes(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/CoolerMasterController/CMARGBGen2A1Controller/RGBController_CMARGBGen2A1Controller.cpp b/Controllers/CoolerMasterController/CMARGBGen2A1Controller/RGBController_CMARGBGen2A1Controller.cpp index edb922cc3..0a39a01aa 100644 --- a/Controllers/CoolerMasterController/CMARGBGen2A1Controller/RGBController_CMARGBGen2A1Controller.cpp +++ b/Controllers/CoolerMasterController/CMARGBGen2A1Controller/RGBController_CMARGBGen2A1Controller.cpp @@ -220,10 +220,8 @@ void RGBController_CMARGBGen2A1Controller::SetupZones() SetupColors(); } -void RGBController_CMARGBGen2A1Controller::DeviceResizeZone(int zone, int new_size) +void RGBController_CMARGBGen2A1Controller::DeviceConfigureZone(int zone_idx) { - zones[zone].leds_count = new_size; - unsigned int total_leds = 0; for(unsigned int channel = 0; channel < CM_ARGB_GEN2_A1_CHANNEL_COUNT; channel++) @@ -238,7 +236,7 @@ void RGBController_CMARGBGen2A1Controller::DeviceResizeZone(int zone, int new_si leds[i].name = "LED " + std::to_string(i + 1); } - controller->SetupZoneSize(zone, new_size); + controller->SetupZoneSize(zone_idx, zones[zone_idx].leds_count); SetupColors(); } diff --git a/Controllers/CoolerMasterController/CMARGBGen2A1Controller/RGBController_CMARGBGen2A1Controller.h b/Controllers/CoolerMasterController/CMARGBGen2A1Controller/RGBController_CMARGBGen2A1Controller.h index 1aba83a54..1d5a3e372 100644 --- a/Controllers/CoolerMasterController/CMARGBGen2A1Controller/RGBController_CMARGBGen2A1Controller.h +++ b/Controllers/CoolerMasterController/CMARGBGen2A1Controller/RGBController_CMARGBGen2A1Controller.h @@ -23,7 +23,7 @@ public: ~RGBController_CMARGBGen2A1Controller(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); void UpdateSegmentLEDs(int zone, int subchannel); diff --git a/Controllers/CoolerMasterController/CMSmallARGBController/CMSmallARGBController.cpp b/Controllers/CoolerMasterController/CMSmallARGBController/CMSmallARGBController.cpp index b477d05be..c56adab6b 100644 --- a/Controllers/CoolerMasterController/CMSmallARGBController/CMSmallARGBController.cpp +++ b/Controllers/CoolerMasterController/CMSmallARGBController/CMSmallARGBController.cpp @@ -18,11 +18,10 @@ cm_small_argb_headers cm_small_argb_header_data[1] = { "CM Small ARGB", 0x01, true, 12 } }; -CMSmallARGBController::CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx) +CMSmallARGBController::CMSmallARGBController(hid_device* dev_handle, char *_path) { dev = dev_handle; location = _path; - zone_index = _zone_idx; current_speed = CM_SMALL_ARGB_SPEED_NORMAL; /*---------------------------------------------------------*\ @@ -51,7 +50,7 @@ void CMSmallARGBController::GetStatus() { unsigned char buffer[CM_SMALL_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x01, 0x01 }; int buffer_size = (sizeof(buffer) / sizeof(buffer[0])); - int header = zone_index - 1; + int header = 0 - 1; buffer[CM_SMALL_ARGB_ZONE_BYTE] = header; buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x01; @@ -98,11 +97,6 @@ std::string CMSmallARGBController::GetLocation() return("HID: " + location); } -unsigned char CMSmallARGBController::GetZoneIndex() -{ - return(zone_index); -} - unsigned char CMSmallARGBController::GetMode() { return(current_mode); @@ -177,7 +171,7 @@ void CMSmallARGBController::SetLedsDirect(RGBColor* led_colours, unsigned int le colours.push_back( RGBGetBValue(colour) ); } - buffer[CM_SMALL_ARGB_ZONE_BYTE] = zone_index - 1; //argb_header_data[zone_index].header; + buffer[CM_SMALL_ARGB_ZONE_BYTE] = 0 - 1; //argb_header_data[zone_index].header; buffer[CM_SMALL_ARGB_MODE_BYTE] = led_count; unsigned char buffer_idx = CM_SMALL_ARGB_MODE_BYTE + 1; @@ -225,7 +219,7 @@ void CMSmallARGBController::SendUpdate() buffer[CM_SMALL_ARGB_COMMAND_BYTE] = 0x0b; buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = (false) ? 0x01 : 0x02; //This controls custom mode TODO - buffer[CM_SMALL_ARGB_ZONE_BYTE] = cm_small_argb_header_data[zone_index].header; + buffer[CM_SMALL_ARGB_ZONE_BYTE] = cm_small_argb_header_data[0].header; buffer[CM_SMALL_ARGB_MODE_BYTE] = current_mode; buffer[CM_SMALL_ARGB_SPEED_BYTE] = current_speed; buffer[CM_SMALL_ARGB_COLOUR_INDEX_BYTE] = (bool_random) ? 0x00 : 0x10; //This looks to still be the colour index and controls random colours diff --git a/Controllers/CoolerMasterController/CMSmallARGBController/CMSmallARGBController.h b/Controllers/CoolerMasterController/CMSmallARGBController/CMSmallARGBController.h index e94584cbe..19d2bb8fe 100644 --- a/Controllers/CoolerMasterController/CMSmallARGBController/CMSmallARGBController.h +++ b/Controllers/CoolerMasterController/CMSmallARGBController/CMSmallARGBController.h @@ -74,14 +74,13 @@ enum class CMSmallARGBController { public: - CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx); + CMSmallARGBController(hid_device* dev_handle, char *_path); ~CMSmallARGBController(); std::string GetDeviceName(); std::string GetSerial(); std::string GetLocation(); - unsigned char GetZoneIndex(); unsigned char GetMode(); unsigned char GetLedRed(); unsigned char GetLedGreen(); @@ -97,7 +96,6 @@ private: std::string location; hid_device* dev; - unsigned char zone_index; unsigned char current_mode; unsigned char current_speed; diff --git a/Controllers/CoolerMasterController/CMSmallARGBController/RGBController_CMSmallARGBController.cpp b/Controllers/CoolerMasterController/CMSmallARGBController/RGBController_CMSmallARGBController.cpp index 0eaadc848..401b0c1c9 100644 --- a/Controllers/CoolerMasterController/CMSmallARGBController/RGBController_CMSmallARGBController.cpp +++ b/Controllers/CoolerMasterController/CMSmallARGBController/RGBController_CMSmallARGBController.cpp @@ -29,7 +29,7 @@ RGBController_CMSmallARGBController::RGBController_CMSmallARGBController(CMSmall controller = controller_ptr; unsigned char speed = controller->GetLedSpeed(); - name = cm_small_argb_header_data[controller->GetZoneIndex()].name; + name = cm_small_argb_header_data[0].name; vendor = "Cooler Master"; type = DEVICE_TYPE_LEDSTRIP; description = controller->GetDeviceName(); @@ -152,7 +152,6 @@ RGBController_CMSmallARGBController::RGBController_CMSmallARGBController(CMSmall PassThru.color_mode = MODE_COLORS_NONE; modes.push_back(PassThru); - Init_Controller(); //Only processed on first run SetupZones(); int temp_mode = controller->GetMode(); @@ -186,57 +185,69 @@ RGBController_CMSmallARGBController::~RGBController_CMSmallARGBController() delete controller; } -void RGBController_CMSmallARGBController::Init_Controller() -{ - int zone_idx = controller->GetZoneIndex(); - int zone_led_count = cm_small_argb_header_data[zone_idx].count; - bool boolSingleLED = ( zone_led_count == 1 ); //If argb_header_data[zone_idx].count == 1 then the zone is ZONE_TYPE_SINGLE - - zone ARGB_zone; - ARGB_zone.name = std::to_string(zone_idx); - ARGB_zone.type = (boolSingleLED) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR; - ARGB_zone.leds_min = CM_SMALL_ARGB_MIN_LEDS; - ARGB_zone.leds_max = CM_SMALL_ARGB_MAX_LEDS; - ARGB_zone.leds_count = zone_led_count; - zones.push_back(ARGB_zone); -} - void RGBController_CMSmallARGBController::SetupZones() { - /*-------------------------------------------------*\ - | Clear any existing color/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(); colors.clear(); + zones.resize(1); - /*---------------------------------------------------------*\ - | Set up zones | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Set up zones and LEDs | + \*-----------------------------------------------------*/ for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE); //Calculated for later use + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = CM_SMALL_ARGB_MAX_LEDS; - if (!boolSingleLED) + if(first_run) { - controller->SetLedCount(cm_small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count); + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = "Addressable RGB Header"; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); } for(unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++) { - led new_led; - unsigned int i = std::stoi(zones[zone_idx].name); - - if(boolSingleLED) - { - new_led.name = i; - new_led.value = cm_small_argb_header_data[i].header; - } - else - { - new_led.name = i; - new_led.name.append(" LED " + std::to_string(lp_idx)); - new_led.value = cm_small_argb_header_data[i].header; - } + led new_led; + new_led.name = zones[zone_idx].name; + new_led.name.append(", LED " + std::to_string(lp_idx)); leds.push_back(new_led); } @@ -245,16 +256,11 @@ void RGBController_CMSmallARGBController::SetupZones() SetupColors(); } -void RGBController_CMSmallARGBController::DeviceResizeZone(int zone, int new_size) +void RGBController_CMSmallARGBController::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; + controller->SetLedCount(cm_small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count); SetupZones(); } diff --git a/Controllers/CoolerMasterController/CMSmallARGBController/RGBController_CMSmallARGBController.h b/Controllers/CoolerMasterController/CMSmallARGBController/RGBController_CMSmallARGBController.h index e60c8d44c..d91b53b44 100644 --- a/Controllers/CoolerMasterController/CMSmallARGBController/RGBController_CMSmallARGBController.h +++ b/Controllers/CoolerMasterController/CMSmallARGBController/RGBController_CMSmallARGBController.h @@ -27,7 +27,7 @@ public: ~RGBController_CMSmallARGBController(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp b/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp index 387ead882..ebe6c9e46 100644 --- a/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp +++ b/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp @@ -326,7 +326,7 @@ DetectedControllers DetectCoolerMasterSmallARGB(hid_device_info* info, const std if(dev) { - CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path, 0); + CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path); RGBController_CMSmallARGBController* rgb_controller = new RGBController_CMSmallARGBController(controller); detected_controllers.push_back(rgb_controller); diff --git a/Controllers/CorsairCommanderCoreController/RGBController_CorsairCommanderCore.cpp b/Controllers/CorsairCommanderCoreController/RGBController_CorsairCommanderCore.cpp index 18d714078..3caceefe0 100644 --- a/Controllers/CorsairCommanderCoreController/RGBController_CorsairCommanderCore.cpp +++ b/Controllers/CorsairCommanderCoreController/RGBController_CorsairCommanderCore.cpp @@ -51,22 +51,23 @@ static unsigned int matrix_map24[11][11] = RGBController_CorsairCommanderCore::RGBController_CorsairCommanderCore(CorsairCommanderCoreController* controller_ptr) { - controller = controller_ptr; + controller = controller_ptr; - name = controller->GetNameString(); - vendor = "Corsair"; - description = "Corsair Commander Core Device"; - version = controller->GetFirmwareString(); - type = DEVICE_TYPE_COOLER; - location = controller->GetLocationString(); - SetupZones(); + name = controller->GetNameString(); + vendor = "Corsair"; + description = "Corsair Commander Core Device"; + version = controller->GetFirmwareString(); + type = DEVICE_TYPE_COOLER; + location = controller->GetLocationString(); mode Direct; - Direct.name = "Direct"; - Direct.value = 0; - Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Direct.color_mode = MODE_COLORS_PER_LED; + Direct.name = "Direct"; + Direct.value = 0; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; modes.push_back(Direct); + + SetupZones(); } RGBController_CorsairCommanderCore::~RGBController_CorsairCommanderCore() @@ -78,31 +79,70 @@ RGBController_CorsairCommanderCore::~RGBController_CorsairCommanderCore() void RGBController_CorsairCommanderCore::SetupZones() { - std::atomic first_run; - first_run = 0; + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ + bool first_run = false; if(zones.size() == 0) { - first_run = 1; + first_run = true; } - std::vector led_count = controller->GetLedCounts(); + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ + leds.clear(); + colors.clear(); zones.resize(7); + + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + std::vector led_count = controller->GetLedCounts(); + if(controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID) { - zones[0].name = "External RGB Port"; - zones[0].type = ZONE_TYPE_LINEAR; - zones[0].leds_min = zones[0].leds_min; - zones[0].leds_max = 204; - zones[0].leds_count = zones[0].leds_count; + zones[0].leds_min = 0; + zones[0].leds_max = 204; + + if(first_run) + { + zones[0].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[0].name = "Corsair RGB Header"; + } + + if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[0].leds_count = 0; + } + + if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[0].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[0].matrix_map.width = 0; + zones[0].matrix_map.height = 0; + zones[0].matrix_map.map.resize(0); + } } else { - zones[0].name = "Pump"; - zones[0].type = ZONE_TYPE_MATRIX; - zones[0].leds_min = led_count.at(0); - zones[0].leds_max = led_count.at(0); - zones[0].leds_count = led_count.at(0); + zones[0].name = "Pump"; + zones[0].type = ZONE_TYPE_MATRIX; + zones[0].leds_min = led_count.at(0); + zones[0].leds_max = led_count.at(0); + zones[0].leds_count = led_count.at(0); if(led_count.at(0) == 24) { @@ -114,28 +154,51 @@ void RGBController_CorsairCommanderCore::SetupZones() } } - for(unsigned int i = 1; i < (CORSAIR_COMMANDER_CORE_NUM_CHANNELS + 1); i++) + for(unsigned int zone_idx = 1; zone_idx < (CORSAIR_COMMANDER_CORE_NUM_CHANNELS + 1); zone_idx++) { - zones[i].name = "RGB Port " + std::to_string(i); - zones[i].type = ZONE_TYPE_LINEAR; - zones[i].leds_min = 0; - zones[i].leds_max = 34; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 34; if(first_run) { - zones[i].leds_count = (led_count.size() > i) ? led_count.at(i) : 0; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = "Corsair Fan Header " + std::to_string(zone_idx); + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); } } - leds.clear(); - colors.clear(); - + /*-----------------------------------------------------*\ + | Set up LEDs | + \*-----------------------------------------------------*/ for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++) { for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) { led new_led; - new_led.name = zones[zone_idx].name + " LED " + std::to_string(led_idx+1); + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx+1); leds.push_back(new_led); } @@ -144,28 +207,23 @@ void RGBController_CorsairCommanderCore::SetupZones() SetupColors(); } -void RGBController_CorsairCommanderCore::DeviceResizeZone(int zone, int new_size) +void RGBController_CorsairCommanderCore::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - if(zone == 0 && controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID) + if(zone_idx == 0 && controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID) { - if(new_size > 0) + if(zones[zone_idx].leds_count > 0) { controller->SetFanMode(true); - controller->SetLedAmount(new_size); + controller->SetLedAmount(zones[zone_idx].leds_count); } else { controller->SetFanMode(false); } } + SetupZones(); } } diff --git a/Controllers/CorsairCommanderCoreController/RGBController_CorsairCommanderCore.h b/Controllers/CorsairCommanderCoreController/RGBController_CorsairCommanderCore.h index cf8f95f1c..d2fffe014 100644 --- a/Controllers/CorsairCommanderCoreController/RGBController_CorsairCommanderCore.h +++ b/Controllers/CorsairCommanderCoreController/RGBController_CorsairCommanderCore.h @@ -22,7 +22,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); void DeviceUpdateSingleLED(int led); diff --git a/Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.cpp b/Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.cpp index 7872f4519..6d0f0d270 100644 --- a/Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.cpp +++ b/Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.cpp @@ -51,7 +51,6 @@ RGBController_CorsairHydroPlatinum::RGBController_CorsairHydroPlatinum(CorsairHy Direct.color_mode = MODE_COLORS_PER_LED; modes.push_back(Direct); - Init_Controller(); SetupZones(); } @@ -62,46 +61,90 @@ RGBController_CorsairHydroPlatinum::~RGBController_CorsairHydroPlatinum() delete controller; } -void RGBController_CorsairHydroPlatinum::Init_Controller() +void RGBController_CorsairHydroPlatinum::SetupZones() { - zone cpu_block_zone; - cpu_block_zone.name = "CPU Block"; - cpu_block_zone.type = ZONE_TYPE_MATRIX; - cpu_block_zone.leds_min = 16; - cpu_block_zone.leds_max = 16; - cpu_block_zone.leds_count = 16; - cpu_block_zone.matrix_map.Set(5, 5, (unsigned int *)&matrix_map); - zones.push_back(cpu_block_zone); + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ + bool first_run = false; + + if(zones.size() == 0) + { + first_run = true; + } /*-----------------------------------------------------*\ - | If the device is RGB fan-capable, set up fan zones. | + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ + leds.clear(); + colors.clear(); + if(controller->HaveRgbFan()) + { + zones.resize(2); + } + else + { + zones.resize(1); + } + + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + zones[0].name = "CPU Block"; + zones[0].type = ZONE_TYPE_MATRIX; + zones[0].leds_min = 16; + zones[0].leds_max = 16; + zones[0].leds_count = 16; + zones[0].matrix_map.Set(5, 5, (unsigned int *)&matrix_map); + + /*-----------------------------------------------------*\ + | If the device is RGB fan-capable, set up fan zone. | \*-----------------------------------------------------*/ if(controller->HaveRgbFan()) { - zone fans_zone; - fans_zone.name = "Fans"; - fans_zone.type = ZONE_TYPE_LINEAR; - fans_zone.leds_min = 0; - fans_zone.leds_max = 32; - fans_zone.leds_count = 0; - zones.push_back(fans_zone); + zones[1].leds_min = 0; + zones[1].leds_max = 32; + + if(first_run) + { + zones[1].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[1].name = "Corsair Fan Header"; + } + + if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[1].leds_count = 0; + } + + if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[1].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[1].matrix_map.width = 0; + zones[1].matrix_map.height = 0; + zones[1].matrix_map.map.resize(0); + } } -} - -void RGBController_CorsairHydroPlatinum::SetupZones() -{ - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ - leds.clear(); - colors.clear(); + /*-----------------------------------------------------*\ + | Set up LEDs | + \*-----------------------------------------------------*/ for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++) { for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) { led new_led; - new_led.name = zones[zone_idx].name + " " + std::to_string(led_idx);; + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx);; leds.push_back(new_led); } } @@ -109,17 +152,10 @@ void RGBController_CorsairHydroPlatinum::SetupZones() SetupColors(); } -void RGBController_CorsairHydroPlatinum::DeviceResizeZone(int zone, int new_size) +void RGBController_CorsairHydroPlatinum::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.h b/Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.h index adf7f2060..438f97f97 100644 --- a/Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.h +++ b/Controllers/CorsairHydroPlatinumController/RGBController_CorsairHydroPlatinum.h @@ -23,7 +23,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.cpp b/Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.cpp index ffd739439..6b848d1bc 100644 --- a/Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.cpp +++ b/Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.cpp @@ -297,9 +297,9 @@ void RGBController_CorsairLightingNode::SetupModes() void RGBController_CorsairLightingNode::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -307,68 +307,74 @@ void RGBController_CorsairLightingNode::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.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++) + /*-----------------------------------------------------*\ + | Set zones and leds | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - char ch_idx_string[2]; - snprintf(ch_idx_string, 2, "%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; - /*-------------------------------------------------*\ | 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 = 204; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 204; if(first_run) { - zones[channel_idx].leds_count = 0; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) { - char led_idx_string[4]; - snprintf(led_idx_string, 4, "%d", led_ch_idx + 1); + zones[zone_idx].name = "Corsair RGB Header "; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[zone_idx].leds_count; led_ch_idx++) + { 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_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1); leds.push_back(new_led); - leds_channel.push_back(channel_idx); + leds_channel.push_back(zone_idx); } } SetupColors(); } -void RGBController_CorsairLightingNode::DeviceResizeZone(int zone, int new_size) +void RGBController_CorsairLightingNode::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.h b/Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.h index 42cb1cc25..fad6ccb11 100644 --- a/Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.h +++ b/Controllers/CorsairLightingNodeController/RGBController_CorsairLightingNode.h @@ -23,7 +23,7 @@ public: void SetupModes(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/CreativeController/RGBController_CreativeSoundBlasterAE5_Windows.cpp b/Controllers/CreativeController/RGBController_CreativeSoundBlasterAE5_Windows.cpp index 580d99618..57eed8aca 100644 --- a/Controllers/CreativeController/RGBController_CreativeSoundBlasterAE5_Windows.cpp +++ b/Controllers/CreativeController/RGBController_CreativeSoundBlasterAE5_Windows.cpp @@ -50,56 +50,91 @@ RGBController_CreativeSoundBlasterAE5::~RGBController_CreativeSoundBlasterAE5() void RGBController_CreativeSoundBlasterAE5::SetupZones() { - zone internal_zone; - internal_zone.name = "Internal"; - internal_zone.type = ZONE_TYPE_LINEAR; - internal_zone.leds_min = 5; - internal_zone.leds_max = 5; - internal_zone.leds_count = 5; - zones.push_back(internal_zone); + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ + bool first_run = false; - for(unsigned int led_idx = 0; led_idx < 5; led_idx++) + if(zones.size() == 0) { - led new_led; - new_led.name = "Internal LED " + std::to_string(led_idx + 1); - leds.push_back(new_led); + first_run = true; } - zone external_zone; - external_zone.name = "External"; - external_zone.type = ZONE_TYPE_LINEAR; - external_zone.leds_min = 0; - external_zone.leds_max = 100; - external_zone.leds_count = controller->GetExternalLEDCount(); - zones.push_back(external_zone); + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ + leds.clear(); + colors.clear(); + zones.resize(2); - for(unsigned int led_idx = 0; led_idx < controller->GetExternalLEDCount(); led_idx++) + /*-----------------------------------------------------*\ + | Set up internal zone | + \*-----------------------------------------------------*/ + zones[0].name = "Internal"; + zones[0].type = ZONE_TYPE_LINEAR; + zones[0].leds_min = 5; + zones[0].leds_max = 5; + zones[0].leds_count = 5; + + /*-----------------------------------------------------*\ + | Set up internal zone and LEDs | + \*-----------------------------------------------------*/ + zones[1].leds_min = 0; + zones[1].leds_max = 100; + + if(first_run) { - led new_led; - new_led.name = "External LED " + std::to_string(led_idx + 1); - leds.push_back(new_led); + zones[1].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[1].name = "Addressable RGB Header"; + } + + if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[1].leds_count = controller->GetExternalLEDCount();; + } + + if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[1].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[1].matrix_map.width = 0; + zones[1].matrix_map.height = 0; + zones[1].matrix_map.map.resize(0); + } + + /*-----------------------------------------------------*\ + | Set up LEDs | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) + { + for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + { + led new_led; + new_led.name = zones[0].name + ", LED " + std::to_string(led_idx + 1); + leds.push_back(new_led); + } } SetupColors(); } -void RGBController_CreativeSoundBlasterAE5::DeviceResizeZone(int zone, int new_size) +void RGBController_CreativeSoundBlasterAE5::DeviceConfigureZone(int zone_idx) { - if(zone == 1) // External zone + if((size_t)zone_idx < zones.size()) { - zones[zone].leds_count = new_size; + controller->SetExternalLEDCount(zones[zone_idx].leds_count); - leds.resize(5); - - for(unsigned int led_idx = 0; led_idx < (unsigned int)new_size; led_idx++) - { - led new_led; - new_led.name = "External LED " + std::to_string(led_idx + 1); - leds.push_back(new_led); - } - - controller->SetExternalLEDCount(new_size); - SetupColors(); + SetupZones(); } } diff --git a/Controllers/CreativeController/RGBController_CreativeSoundBlasterAE5_Windows.h b/Controllers/CreativeController/RGBController_CreativeSoundBlasterAE5_Windows.h index 6ecaf7078..c4dbbe47e 100644 --- a/Controllers/CreativeController/RGBController_CreativeSoundBlasterAE5_Windows.h +++ b/Controllers/CreativeController/RGBController_CreativeSoundBlasterAE5_Windows.h @@ -20,7 +20,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/DRGBController/DRGBController.cpp b/Controllers/DRGBController/DRGBController.cpp index 8fb98bb71..ad34ba4e6 100644 --- a/Controllers/DRGBController/DRGBController.cpp +++ b/Controllers/DRGBController/DRGBController.cpp @@ -20,7 +20,21 @@ DRGBController::DRGBController(hid_device* dev_handle, const char* path, unsigne dev = dev_handle; location = path; name = dev_name; - device_pid = pid; + + /*-----------------------------------------------------*\ + | Loop through all known devices to look for a PID | + | match | + \*-----------------------------------------------------*/ + for(unsigned int i = 0; i < DRGB_NUM_DEVICES; i++) + { + if(drgb_device_list[i]->pid == pid) + { + /*---------------------------------------------*\ + | Set device index | + \*---------------------------------------------*/ + device_index = i; + } + } /*-----------------------------------------------------*\ | Exit hardware effects. Start a thread to continuously| @@ -38,20 +52,6 @@ DRGBController::~DRGBController() hid_close(dev); } -void DRGBController::KeepaliveThread() -{ - unsigned char sleep_buf[65]; - sleep_buf[0] = 0x65; - while(keepalive_thread_run.load()) - { - if((std::chrono::steady_clock::now() - last_commit_time) > std::chrono::milliseconds(500)) - { - SendPacketFS(sleep_buf, 1, 0); - } - std::this_thread::sleep_for(300ms); - } -} - std::string DRGBController::GetFirmwareString() { return "v"+std::to_string(version[0]) + "." + std::to_string(version[1]) + "." + std::to_string(version[2]) + "." + std::to_string(version[3]); @@ -82,7 +82,99 @@ std::string DRGBController::GetSerialString() unsigned short DRGBController::GetDevicePID() { - return(device_pid); + return(drgb_device_list[device_index]->pid); +} + +unsigned char DRGBController::GetNumChannels() +{ + return(drgb_device_list[device_index]->channels); +} + +unsigned short DRGBController::GetLEDsPerChannel() +{ + return(drgb_device_list[device_index]->leds_per_channel); +} + +unsigned short DRGBController::GetVersion() +{ + return(drgb_device_list[device_index]->version); +} + +std::string DRGBController::GetChannelName(unsigned char channel) +{ + std::string channel_name; + + if(drgb_device_list[device_index]->channels == 6) + { + if(channel == 0) + { + channel_name = "Strimer ATX" + std::to_string(channel + 1); + } + else if(channel < 3) + { + channel_name = "Channel C" + std::to_string(channel); + } + else if(channel == 3) + { + channel_name = "Strimer GPU" + std::to_string(channel - 2); + } + else if(channel < 6) + { + channel_name = "Channel D" + std::to_string(channel - 3); + } + } + else if(drgb_device_list[device_index]->channels == 10 || drgb_device_list[device_index]->channels == 12) + { + channel_name = "Channel " + std::to_string(channel + 1); + } + else if(drgb_device_list[device_index]->channels == 14) + { + if(channel < 4) + { + channel_name = "LCD " + std::to_string(channel + 1); + } + else if(channel < 6) + { + channel_name = "LED " + std::to_string(channel + 1); + } + else if(channel < 16) + { + channel_name = "ARGB " + std::to_string(channel - 5); + } + } + else if(channel < 8) + { + channel_name = "Channel A" + std::to_string(channel + 1); + } + else if(channel < 16) + { + channel_name = "Channel B" + std::to_string(channel - 7); + } + else if(drgb_device_list[device_index]->channels == 30) + { + if(channel < 24) + { + channel_name = "Channel C" + std::to_string(channel - 15); + } + else if(channel < 30) + { + channel_name = "Channel D" + std::to_string(channel - 23); + } + } + else if(channel < 22) + { + channel_name = "Channel C" + std::to_string(channel - 15); + } + else if(channel < 28) + { + channel_name = "Channel D" + std::to_string(channel - 21); + } + else if(channel < 36) + { + channel_name = "Channel E" + std::to_string(channel - 27); + } + + return(channel_name); } void DRGBController::SetChannelLEDs(unsigned char /*channel*/, RGBColor* /*colors*/, unsigned int /*num_colors*/) @@ -153,3 +245,17 @@ void DRGBController::SendPacketFS(unsigned char* colors, unsigned int buf_packet hid_write(dev, usb_buf, 65); } } + +void DRGBController::KeepaliveThread() +{ + unsigned char sleep_buf[65]; + sleep_buf[0] = 0x65; + while(keepalive_thread_run.load()) + { + if((std::chrono::steady_clock::now() - last_commit_time) > std::chrono::milliseconds(500)) + { + SendPacketFS(sleep_buf, 1, 0); + } + std::this_thread::sleep_for(300ms); + } +} diff --git a/Controllers/DRGBController/DRGBController.h b/Controllers/DRGBController/DRGBController.h index ec24f3c7d..d9bad1ffb 100644 --- a/Controllers/DRGBController/DRGBController.h +++ b/Controllers/DRGBController/DRGBController.h @@ -14,6 +14,7 @@ #include #include #include +#include "DRGBDevices.h" #include "RGBController.h" #define DRGB_V4_ONE_PACKAGE_SIZE 316 @@ -27,15 +28,24 @@ public: DRGBController(hid_device* dev_handle, const char* path, unsigned short pid, std::string dev_name); ~DRGBController(); - void KeepaliveThread(); std::string GetFirmwareString(); std::string GetLocationString(); std::string GetNameString(); std::string GetSerialString(); + unsigned short GetDevicePID(); + unsigned char GetNumChannels(); + unsigned short GetLEDsPerChannel(); + unsigned short GetVersion(); + + std::string GetChannelName(unsigned char channel); + void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors); - void SendPacket(unsigned char* colors,unsigned int buf_packets ,unsigned int LEDtotal); - void SendPacketFS(unsigned char* colors,unsigned int buf_packets ,unsigned int Array); + void SendPacket(unsigned char* colors, unsigned int buf_packets, unsigned int LEDtotal); + void SendPacketFS(unsigned char* colors, unsigned int buf_packets, unsigned int Array); + + void KeepaliveThread(); + private: hid_device* dev; std::string location; @@ -44,5 +54,5 @@ private: std::atomic keepalive_thread_run; std::chrono::time_point last_commit_time; unsigned char version[4] = {0, 0, 0,0}; - unsigned short device_pid; + unsigned int device_index; }; diff --git a/Controllers/DRGBController/DRGBControllerDetect.cpp b/Controllers/DRGBController/DRGBControllerDetect.cpp index 40ba7f3f6..9bd35468b 100644 --- a/Controllers/DRGBController/DRGBControllerDetect.cpp +++ b/Controllers/DRGBController/DRGBControllerDetect.cpp @@ -23,10 +23,6 @@ DetectedControllers DetectDRGBControllers(hid_device_info* info, const std::stri if(dev) { - wchar_t product[128]; - hid_get_product_string(dev, product, 128); - std::wstring product_str(product); - DRGBController* controller = new DRGBController(dev, info->path, info->product_id, name); RGBController_DRGB* rgb_controller = new RGBController_DRGB(controller); @@ -55,7 +51,7 @@ REGISTER_HID_DETECTOR("DeepRGB C16 V5F", DetectDRGBControllers, DRGBV REGISTER_HID_DETECTOR("DeepRGB S16 V5F", DetectDRGBControllers, DRGBV4_VID, DRGB_S16_V5F_PID); REGISTER_HID_DETECTOR("DeepRGB LED", DetectDRGBControllers, DRGBV3_VID, DRGB_LED_V3_PID); -REGISTER_HID_DETECTOR("DeepRGB Ultra V3", DetectDRGBControllers, DRGBV3_VID, DRGB_Ultra_V3_PID); +REGISTER_HID_DETECTOR("DeepRGB Ultra V3", DetectDRGBControllers, DRGBV3_VID, DRGB_ULTRA_V3_PID); REGISTER_HID_DETECTOR("DeepRGB CORE V3", DetectDRGBControllers, DRGBV3_VID, DRGB_CORE_V3_PID); REGISTER_HID_DETECTOR("DeepRGB E8 F", DetectDRGBControllers, DRGBV3_VID, DRGB_E8_F_PID); REGISTER_HID_DETECTOR("DeepRGB E8", DetectDRGBControllers, DRGBV3_VID, DRGB_E8_PID); @@ -67,7 +63,7 @@ REGISTER_HID_DETECTOR("DeepRGB LED Controller", DetectDRGBControllers, DRGBV REGISTER_HID_DETECTOR("DeepRGB ULTRA", DetectDRGBControllers, DRGBV2_VID, DRGB_ULTRA_PID); REGISTER_HID_DETECTOR("DeepRGB SIG AB", DetectDRGBControllers, DRGBV2_VID, DRGB_SIG_AB_PID); REGISTER_HID_DETECTOR("DeepRGB SIG CD", DetectDRGBControllers, DRGBV2_VID, DRGB_SIG_CD_PID); -REGISTER_HID_DETECTOR("DeepRGB Strimer Controller", DetectDRGBControllers, DRGBV2_VID, DRGB_Strimer_PID); +REGISTER_HID_DETECTOR("DeepRGB Strimer Controller", DetectDRGBControllers, DRGBV2_VID, DRGB_STRIMER_PID); REGISTER_HID_DETECTOR("YICO 8 ELITE", DetectDRGBControllers, YICO_VID, YICO_8_PID); REGISTER_HID_DETECTOR("YICO 08 ELITE", DetectDRGBControllers, YICO_VID, YICO_08_PID); diff --git a/Controllers/DRGBController/DRGBDevices.cpp b/Controllers/DRGBController/DRGBDevices.cpp new file mode 100644 index 000000000..52bd0cda9 --- /dev/null +++ b/Controllers/DRGBController/DRGBDevices.cpp @@ -0,0 +1,322 @@ +/*---------------------------------------------------------*\ +| DRGBDevices.cpp | +| | +| Device list for DRGB devices | +| | +| Adam Honse (CalcProgrammer1) 16 Mar 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include "DRGBDevices.h" + +/*---------------------------------------------------------*\ +| DRGB Devices | +\*---------------------------------------------------------*/ +static const drgb_device drgb_led_v4 = +{ + DRGB_LED_V4_PID, + 8, + 512, + 4 +}; + +static const drgb_device drgb_ultra_v4f = +{ + DRGB_ULTRA_V4F_PID, + 16, + 256, + 4 +}; + +static const drgb_device drgb_core_v4f = +{ + DRGB_CORE_V4F_PID, + 32, + 256, + 4 +}; + +static const drgb_device drgb_sig_v4f = +{ + DRGB_SIG_V4F_PID, + 36, + 256, + 4 +}; + +static const drgb_device drgb_ag_04_v4f = +{ + DRGB_AG_04_V4F_PID, + 4, + 256, + 4 +}; + +static const drgb_device drgb_ag_16_v4f = +{ + DRGB_AG_16_V4F_PID, + 16, + 256, + 4 +}; + +static const drgb_device drgb_ag_08 = +{ + DRGB_AG_08_PID, + 8, + 256, + 4 +}; + +static const drgb_device drgb_ag_08_f08 = +{ + DRGB_AG_08_F08_PID, + 8, + 256, + 4 +}; + +static const drgb_device drgb_ag_16_f12 = +{ + DRGB_AG_16_F12_PID, + 16, + 256, + 4 +}; + +static const drgb_device drgb_l8_v5 = +{ + DRGB_L8_V5_PID, + 8, + 512, + 4 +}; + +static const drgb_device drgb_u16_v5 = +{ + DRGB_U16_V5_PID, + 16, + 256, + 4 +}; + +static const drgb_device drgb_u16_v5f = +{ + DRGB_U16_V5F_PID, + 16, + 256, + 4 +}; + +static const drgb_device drgb_c16_v5 = +{ + DRGB_C16_V5_PID, + 32, + 256, + 4 +}; + +static const drgb_device drgb_c16_v5f = +{ + DRGB_C16_V5F_PID, + 32, + 256, + 4 +}; + +static const drgb_device drgb_s16_v5f = +{ + DRGB_S16_V5F_PID, + 32, + 256, + 4 +}; + +static const drgb_device drgb_led_v3 = +{ + DRGB_LED_V3_PID, + 8, + 256, + 3 +}; + +static const drgb_device drgb_ultra_v3 = +{ + DRGB_ULTRA_V3_PID, + 16, + 256, + 3 +}; + +static const drgb_device drgb_core_v3 = +{ + DRGB_CORE_V3_PID, + 30, + 256, + 3 +}; + +static const drgb_device drgb_e8_f = +{ + DRGB_E8_F_PID, + 8, + 132, + 1 +}; + +static const drgb_device drgb_e8 = +{ + DRGB_E8_PID, + 8, + 132, + 1 +}; + +static const drgb_device drgb_e16 = +{ + DRGB_E16_PID, + 16, + 132, + 1 +}; + +static const drgb_device dm_10 = +{ + DM_10_PID, + 10, + 132, + 1 +}; + +static const drgb_device jpu_12 = +{ + JPU_12_PID, + 12, + 60, + 1 +}; + +static const drgb_device drgb_led = +{ + DRGB_LED_PID, + 8, + 256, + 2 +}; + +static const drgb_device drgb_ultra = +{ + DRGB_ULTRA_PID, + 16, + 256, + 2 +}; + +static const drgb_device drgb_sig_ab = +{ + DRGB_SIG_AB_PID, + 16, + 256, + 2 +}; + +static const drgb_device drgb_sig_cd = +{ + DRGB_SIG_CD_PID, + 6, + 256, + 2 +}; + +static const drgb_device drgb_strimer = +{ + DRGB_STRIMER_PID, + 6, + 256, + 2 +}; + +static const drgb_device yico_8 = +{ + YICO_8_PID, + 8, + 256, + 3 +}; + +static const drgb_device yico_08 = +{ + YICO_08_PID, + 8, + 256, + 3 +}; + +static const drgb_device yico_08_1 = +{ + YICO_08_1_PID, + 8, + 132, + 3 +}; + +static const drgb_device yico_14 = +{ + YICO_14_PID, + 14, + 132, + 1 +}; + +static const drgb_device yico_16 = +{ + YICO_16_PID, + 16, + 256, + 4 +}; + +/*---------------------------------------------------------*\ +| DRGB Device List | +\*---------------------------------------------------------*/ +static const drgb_device* device_list[] = +{ + &drgb_led_v4, + &drgb_ultra_v4f, + &drgb_core_v4f, + &drgb_sig_v4f, + &drgb_ag_04_v4f, + &drgb_ag_16_v4f, + &drgb_ag_08, + &drgb_ag_08_f08, + &drgb_ag_16_f12, + &drgb_l8_v5, + &drgb_u16_v5, + &drgb_u16_v5f, + &drgb_c16_v5, + &drgb_c16_v5f, + &drgb_s16_v5f, + &drgb_led_v3, + &drgb_ultra_v3, + &drgb_core_v3, + &drgb_e8_f, + &drgb_e8, + &drgb_e16, + &dm_10, + &jpu_12, + &drgb_led, + &drgb_ultra, + &drgb_sig_ab, + &drgb_sig_cd, + &drgb_strimer, + &yico_8, + &yico_08, + &yico_08_1, + &yico_14, + &yico_16 +}; + +const unsigned int DRGB_NUM_DEVICES = (sizeof(device_list) / sizeof(device_list[ 0 ])); +const drgb_device** drgb_device_list = device_list; diff --git a/Controllers/DRGBController/DRGBDevices.h b/Controllers/DRGBController/DRGBDevices.h new file mode 100644 index 000000000..1970e8673 --- /dev/null +++ b/Controllers/DRGBController/DRGBDevices.h @@ -0,0 +1,77 @@ +/*---------------------------------------------------------*\ +| DRGBDevices.h | +| | +| Device list for DRGB devices | +| | +| Adam Honse (CalcProgrammer1) 16 Mar 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#pragma once + +#include "DRGBController.h" + +/*---------------------------------------------------------*\ +| DRGB vendor IDs | +\*---------------------------------------------------------*/ +#define DRGBV2_VID 0x2023 +#define DRGBV3_VID 0x2023 +#define DRGBV4_VID 0x2486 +#define YICO_VID 0x1368 + +/*---------------------------------------------------------*\ +| DRGB product IDs | +\*---------------------------------------------------------*/ +#define DRGB_LED_V4_PID 0x3608 +#define DRGB_ULTRA_V4F_PID 0x3616 +#define DRGB_CORE_V4F_PID 0x3628 +#define DRGB_SIG_V4F_PID 0x3636 +#define DRGB_AG_04_V4F_PID 0x3204 +#define DRGB_AG_16_V4F_PID 0x3216 +#define DRGB_AG_08_PID 0x3F08 +#define DRGB_AG_08_F08_PID 0x3F16 +#define DRGB_AG_16_F12_PID 0x3F28 + +#define DRGB_L8_V5_PID 0x3208 +#define DRGB_U16_V5_PID 0x3215 +#define DRGB_U16_V5F_PID 0x3217 +#define DRGB_C16_V5_PID 0x3228 +#define DRGB_C16_V5F_PID 0x3229 +#define DRGB_S16_V5F_PID 0x3232 + +#define DRGB_LED_V3_PID 0x1209 +#define DRGB_ULTRA_V3_PID 0x1221 +#define DRGB_CORE_V3_PID 0x1226 +#define DRGB_E8_F_PID 0x1408 +#define DRGB_E8_PID 0x1407 +#define DRGB_E16_PID 0x1416 +#define DM_10_PID 0x1410 +#define JPU_12_PID 0x1412 + +#define DRGB_LED_PID 0x1208 +#define DRGB_ULTRA_PID 0x1220 +#define DRGB_SIG_AB_PID 0x1210 +#define DRGB_SIG_CD_PID 0x1211 +#define DRGB_STRIMER_PID 0x1215 + +#define YICO_8_PID 0x6077 +#define YICO_08_PID 0x6078 +#define YICO_08_1_PID 0x6079 +#define YICO_14_PID 0x1614 +#define YICO_16_PID 0x1616 + +typedef struct +{ + unsigned short pid; + unsigned char channels; + unsigned short leds_per_channel; + unsigned short version; +} drgb_device; + +/*---------------------------------------------------------*\ +| These constant values are defined in DRGBDevices.cpp | +\*---------------------------------------------------------*/ +extern const unsigned int DRGB_NUM_DEVICES; +extern const drgb_device** drgb_device_list; diff --git a/Controllers/DRGBController/RGBController_DRGB.cpp b/Controllers/DRGBController/RGBController_DRGB.cpp index 440ddafdb..9cc82bc29 100644 --- a/Controllers/DRGBController/RGBController_DRGB.cpp +++ b/Controllers/DRGBController/RGBController_DRGB.cpp @@ -26,21 +26,21 @@ RGBController_DRGB::RGBController_DRGB(DRGBController* controller_ptr) { - controller = controller_ptr; + controller = controller_ptr; - name = controller->GetNameString(); - vendor = "DRGB"; - description = "DRGB Controller Device"; - type = DEVICE_TYPE_LEDSTRIP; - version = controller->GetFirmwareString(); - location = controller->GetLocationString(); - serial = controller->GetSerialString(); + name = controller->GetNameString(); + vendor = "DRGB"; + description = "DRGB Controller Device"; + type = DEVICE_TYPE_LEDSTRIP; + version = controller->GetFirmwareString(); + location = controller->GetLocationString(); + serial = controller->GetSerialString(); mode Direct; - Direct.name = "Direct"; - Direct.value = 0xFFFF; - Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Direct.color_mode = MODE_COLORS_PER_LED; + Direct.name = "Direct"; + Direct.value = 0xFFFF; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; modes.push_back(Direct); SetupZones(); @@ -55,324 +55,84 @@ RGBController_DRGB::~RGBController_DRGB() void RGBController_DRGB::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | 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(); colors.clear(); + zones.resize(controller->GetNumChannels()); - unsigned int NUM_CHANNELS = 0; - unsigned int NUM_Channel_led = 0; - switch(controller->GetDevicePID()) + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) { - case DRGB_LED_V4_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 512; - Version = 4; - break; - case DRGB_ULTRA_V4F_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_CORE_V4F_PID: - NUM_CHANNELS = 32; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_SIG_V4F_PID: - NUM_CHANNELS = 36; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_AG_04_V4F_PID: - NUM_CHANNELS = 4; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_AG_08_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_AG_08_F08_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_AG_16_V4F_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_AG_16_F12_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 256; - Version = 4; - break; - - case DRGB_L8_V5_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 512; - Version = 4; - break; - case DRGB_U16_V5_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_U16_V5F_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_C16_V5_PID: - NUM_CHANNELS = 32; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_C16_V5F_PID: - NUM_CHANNELS = 32; - NUM_Channel_led = 256; - Version = 4; - break; - case DRGB_S16_V5F_PID: - NUM_CHANNELS = 32; - NUM_Channel_led = 256; - Version = 4; - break; - - case DRGB_LED_V3_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 256; - Version = 3; - break; - case DRGB_Ultra_V3_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 256; - Version = 3; - break; - case DRGB_CORE_V3_PID: - NUM_CHANNELS = 30; - NUM_Channel_led = 256; - Version = 3; - break; - case DRGB_E8_F_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 132; - Version = 1; - break; - case DRGB_E8_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 132; - Version = 1; - break; - case DRGB_E16_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 132; - Version = 1; - break; - case DM_10_PID: - NUM_CHANNELS = 10; - NUM_Channel_led = 132; - Version = 1; - break; - case JPU_12_PID: - NUM_CHANNELS = 12; - NUM_Channel_led = 60; - Version = 1; - break; - - case DRGB_LED_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 256; - Version = 2; - break; - case DRGB_ULTRA_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 256; - Version = 2; - break; - case DRGB_SIG_AB_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 256; - Version = 2; - break; - case DRGB_SIG_CD_PID: - NUM_CHANNELS = 6; - NUM_Channel_led = 256; - Version = 2; - break; - case DRGB_Strimer_PID: - NUM_CHANNELS = 6; - NUM_Channel_led = 256; - Version = 2; - break; - - case YICO_8_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 256; - Version = 3; - break; - case YICO_08_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 256; - Version = 3; - break; - case YICO_08_1_PID: - NUM_CHANNELS = 8; - NUM_Channel_led = 132; - Version = 3; - break; - case YICO_14_PID: - NUM_CHANNELS = 14; - NUM_Channel_led = 132; - Version = 1; - break; - case YICO_16_PID: - NUM_CHANNELS = 16; - NUM_Channel_led = 256; - Version = 4; - break; - } - - zones.resize(NUM_CHANNELS); - - for(unsigned int channel_idx = 0; channel_idx < NUM_CHANNELS; channel_idx++) - { - char ch_idx_string[4]; - if(NUM_CHANNELS == 6) - { - if(channel_idx==0) - { - snprintf(ch_idx_string, 2, "%d", channel_idx+1 ); - zones[channel_idx].name = "Strimer ATX"; - } - else if(channel_idx<3) - { - snprintf(ch_idx_string, 2, "%d", channel_idx ); - zones[channel_idx].name = "Channel C"; - } - else if(channel_idx==3) - { - snprintf(ch_idx_string, 2, "%d", channel_idx-2 ); - zones[channel_idx].name = "Strimer GPU"; - } - else if(channel_idx<6) - { - snprintf(ch_idx_string, 2, "%d", channel_idx -3); - zones[channel_idx].name = "Channel D"; - } - } - else if(NUM_CHANNELS == 10 || NUM_CHANNELS == 12) - { - snprintf(ch_idx_string, 4, "%d", channel_idx+1 ); - zones[channel_idx].name = "Channel "; - } - else if(NUM_CHANNELS == 14) - { - if(channel_idx<4) - { - snprintf(ch_idx_string, 3, "%d", channel_idx+1 ); - zones[channel_idx].name = "LCD "; - } - else if(channel_idx<6) - { - snprintf(ch_idx_string, 3, "%d", channel_idx+1 ); - zones[channel_idx].name = "LED "; - } - else if(channel_idx<16) - { - snprintf(ch_idx_string, 3, "%d", channel_idx-5 ); - zones[channel_idx].name = "ARGB "; - } - } - else if(channel_idx<8) - { - snprintf(ch_idx_string, 3, "%d", channel_idx + 1); - zones[channel_idx].name = "Channel A"; - } - else if(channel_idx<16) - { - snprintf(ch_idx_string, 2, "%d", channel_idx -7); - zones[channel_idx].name = "Channel B"; - } - else if(NUM_CHANNELS == 30) - { - if(channel_idx<24) - { - snprintf(ch_idx_string, 2, "%d", channel_idx -15); - zones[channel_idx].name = "Channel C"; - } - else if(channel_idx<30) - { - snprintf(ch_idx_string, 2, "%d", channel_idx -23); - zones[channel_idx].name = "Channel D"; - } - } - else if(channel_idx<22) - { - snprintf(ch_idx_string, 2, "%d", channel_idx -15); - zones[channel_idx].name = "Channel C"; - } - else if(channel_idx<28) - { - snprintf(ch_idx_string, 2, "%d", channel_idx -21); - zones[channel_idx].name = "Channel D"; - } - else if(channel_idx<36) - { - snprintf(ch_idx_string, 2, "%d", channel_idx -27); - zones[channel_idx].name = "Channel E"; - } - zones[channel_idx].name.append(ch_idx_string); - zones[channel_idx].type = ZONE_TYPE_LINEAR; - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = NUM_Channel_led; + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = controller->GetLEDsPerChannel(); if(first_run) { - zones[channel_idx].leds_count = 0; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = controller->GetChannelName((unsigned char)channel_idx); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); } for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { - char led_idx_string[4]; - snprintf(led_idx_string, 4, "%d", led_ch_idx + 1); led new_led; - new_led.name = "LED "; - new_led.name.append(led_idx_string); + new_led.name = zones[channel_idx].name + ", LED " + std::to_string(led_ch_idx); leds.push_back(new_led); leds_channel.push_back(channel_idx); } } SetupColors(); - } -void RGBController_DRGB::DeviceResizeZone(int zone, int new_size) +void RGBController_DRGB::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; SetupZones(); } } void RGBController_DRGB::DeviceUpdateLEDs() { - switch(Version) + switch(controller->GetVersion()) { case 4: { diff --git a/Controllers/DRGBController/RGBController_DRGB.h b/Controllers/DRGBController/RGBController_DRGB.h index c7c9a6630..c22f6b2f2 100644 --- a/Controllers/DRGBController/RGBController_DRGB.h +++ b/Controllers/DRGBController/RGBController_DRGB.h @@ -13,49 +13,6 @@ #include "RGBController.h" #include "DRGBController.h" - -#define DRGBV4_VID 0x2486 -#define DRGB_LED_V4_PID 0x3608 -#define DRGB_ULTRA_V4F_PID 0x3616 -#define DRGB_CORE_V4F_PID 0x3628 -#define DRGB_SIG_V4F_PID 0x3636 -#define DRGB_AG_04_V4F_PID 0x3204 -#define DRGB_AG_16_V4F_PID 0x3216 -#define DRGB_AG_08_PID 0x3F08 -#define DRGB_AG_08_F08_PID 0x3F16 -#define DRGB_AG_16_F12_PID 0x3F28 - -#define DRGB_L8_V5_PID 0x3208 -#define DRGB_U16_V5_PID 0x3215 -#define DRGB_U16_V5F_PID 0x3217 -#define DRGB_C16_V5_PID 0x3228 -#define DRGB_C16_V5F_PID 0x3229 -#define DRGB_S16_V5F_PID 0x3232 - -#define DRGBV3_VID 0x2023 -#define DRGB_LED_V3_PID 0x1209 -#define DRGB_Ultra_V3_PID 0x1221 -#define DRGB_CORE_V3_PID 0x1226 -#define DRGB_E8_F_PID 0x1408 -#define DRGB_E8_PID 0x1407 -#define DRGB_E16_PID 0x1416 -#define DM_10_PID 0x1410 -#define JPU_12_PID 0x1412 - -#define DRGBV2_VID 0x2023 -#define DRGB_LED_PID 0x1208 -#define DRGB_ULTRA_PID 0x1220 -#define DRGB_SIG_AB_PID 0x1210 -#define DRGB_SIG_CD_PID 0x1211 -#define DRGB_Strimer_PID 0x1215 - -#define YICO_VID 0x1368 -#define YICO_8_PID 0x6077 -#define YICO_08_PID 0x6078 -#define YICO_08_1_PID 0x6079 -#define YICO_14_PID 0x1614 -#define YICO_16_PID 0x1616 - class RGBController_DRGB : public RGBController { public: @@ -63,15 +20,17 @@ public: ~RGBController_DRGB(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + + void DeviceConfigureZone(int zone_idx); + void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); void DeviceUpdateSingleLED(int led); + void DeviceUpdateMode(); private: - DRGBController* controller; + DRGBController* controller; std::vector leds_channel; std::vector zones_channel; - unsigned int Version = 4; }; diff --git a/Controllers/DebugController/RGBController_Debug.cpp b/Controllers/DebugController/RGBController_Debug.cpp index 4009e8e48..aeca2b538 100644 --- a/Controllers/DebugController/RGBController_Debug.cpp +++ b/Controllers/DebugController/RGBController_Debug.cpp @@ -46,8 +46,11 @@ static unsigned int debug_keyboard_underglow_map[3][10] = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }, { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 } }; -RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_settings) +RGBController_Debug::RGBController_Debug(bool custom, json settings) { + custom_controller = custom; + debug_settings = settings; + if(custom_controller) { /*-------------------------------------------------*\ @@ -80,19 +83,109 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett location = debug_settings["DeviceLocation"]; version = debug_settings["DeviceVersion"]; serial = debug_settings["DeviceSerial"]; + } + else + { + std::string name_setting = ""; + std::string type_setting = "keyboard"; - /*-------------------------------------------------*\ - | Create the mode | - \*-------------------------------------------------*/ - mode Direct; + if(debug_settings.contains("name")) + { + name_setting = debug_settings["name"]; + } - Direct.name = "Direct"; - Direct.value = 0; - Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Direct.color_mode = MODE_COLORS_PER_LED; + if(debug_settings.contains("type")) + { + type_setting = debug_settings["type"]; + } - modes.push_back(Direct); + if(type_setting == "motherboard") + { + name = "Debug Motherboard"; + type = DEVICE_TYPE_MOTHERBOARD; + } + else if(type_setting == "dram") + { + name = "Debug DRAM"; + type = DEVICE_TYPE_DRAM; + } + else if(type_setting == "gpu") + { + name = "Debug GPU"; + type = DEVICE_TYPE_GPU; + } + else if(type_setting == "keyboard") + { + name = "Debug Keyboard"; + type = DEVICE_TYPE_KEYBOARD; + } + else if(type_setting == "mouse") + { + name = "Debug Mouse"; + type = DEVICE_TYPE_MOUSE; + } + else if(type_setting == "argb") + { + name = "Debug ARGB Controller"; + type = DEVICE_TYPE_LEDSTRIP; + } + /*---------------------------------------------------------*\ + | Fill in debug controller information | + \*---------------------------------------------------------*/ + description = name + " Device"; + vendor = name + " Vendor String"; + location = name + " Location String"; + version = name + " Version String"; + serial = name + " Serial String"; + + if(name_setting != "") + { + name = name_setting; + } + } + + /*-----------------------------------------------------*\ + | Create the mode | + \*-----------------------------------------------------*/ + mode Direct; + + Direct.name = "Direct"; + Direct.value = 0; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; + + modes.push_back(Direct); + + SetupZones(); +} + +RGBController_Debug::~RGBController_Debug() +{ + Shutdown(); +} + +void RGBController_Debug::SetupZones() +{ + /*-------------------------------------------------*\ + | Only set LED count on the first run | + \*-------------------------------------------------*/ + bool first_run = false; + std::size_t zone_idx = 0; + + if(zones.size() == 0) + { + first_run = true; + } + + /*-------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-------------------------------------------------*/ + leds.clear(); + colors.clear(); + + if(custom_controller) + { /*-------------------------------------------------*\ | Fill in zones | \*-------------------------------------------------*/ @@ -237,28 +330,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett zones.push_back(custom_zone); } - - SetupColors(); } else { - bool zone_single = true; - bool zone_linear = true; - bool zone_resizable = false; - bool zone_keyboard = false; - bool zone_underglow = false; - std::string name_setting = ""; - std::string type_setting = "keyboard"; - - if(debug_settings.contains("name")) - { - name_setting = debug_settings["name"]; - } - - if(debug_settings.contains("type")) - { - type_setting = debug_settings["type"]; - } + bool zone_single = true; + bool zone_linear = true; + bool zone_resizable = false; + bool zone_keyboard = false; + bool zone_underglow = false; if(debug_settings.contains("single")) { @@ -285,66 +364,9 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett zone_underglow = debug_settings["underglow"]; } - if(type_setting == "motherboard") - { - name = "Debug Motherboard"; - type = DEVICE_TYPE_MOTHERBOARD; - } - else if(type_setting == "dram") - { - name = "Debug DRAM"; - type = DEVICE_TYPE_DRAM; - } - else if(type_setting == "gpu") - { - name = "Debug GPU"; - type = DEVICE_TYPE_GPU; - } - else if(type_setting == "keyboard") - { - name = "Debug Keyboard"; - type = DEVICE_TYPE_KEYBOARD; - } - else if(type_setting == "mouse") - { - name = "Debug Mouse"; - type = DEVICE_TYPE_MOUSE; - } - else if(type_setting == "argb") - { - name = "Debug ARGB Controller"; - type = DEVICE_TYPE_LEDSTRIP; - } - - /*---------------------------------------------------------*\ - | Fill in debug controller information | - \*---------------------------------------------------------*/ - description = name + " Device"; - vendor = name + " Vendor String"; - location = name + " Location String"; - version = name + " Version String"; - serial = name + " Serial String"; - - if(name_setting != "") - { - name = name_setting; - } - - /*---------------------------------------------------------*\ - | Create a direct mode | - \*---------------------------------------------------------*/ - mode Direct; - - Direct.name = "Direct"; - Direct.value = 0; - Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Direct.color_mode = MODE_COLORS_PER_LED; - - modes.push_back(Direct); - - /*---------------------------------------------------------*\ - | Create a single zone/LED | - \*---------------------------------------------------------*/ + /*-------------------------------------------------*\ + | Create a single zone/LED | + \*-------------------------------------------------*/ if(zone_single) { zone single_zone; @@ -355,7 +377,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett single_zone.leds_max = 1; single_zone.leds_count = 1; - zones.push_back(single_zone); + if(first_run) + { + zones.push_back(single_zone); + } + else + { + zones[zone_idx] = single_zone; + } led single_led; @@ -364,11 +393,13 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett leds.push_back(single_led); led_alt_names.push_back(""); + + zone_idx++; } - /*---------------------------------------------------------*\ - | Create a linear zone | - \*---------------------------------------------------------*/ + /*-------------------------------------------------*\ + | Create a linear zone | + \*-------------------------------------------------*/ if(zone_linear) { zone linear_zone; @@ -379,7 +410,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett linear_zone.leds_max = 10; linear_zone.leds_count = 10; - zones.push_back(linear_zone); + if(first_run) + { + zones.push_back(linear_zone); + } + else + { + zones[zone_idx] = linear_zone; + } for(std::size_t led_idx = 0; led_idx < 10; led_idx++) { @@ -391,10 +429,13 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett led_alt_names.push_back(""); } + + zone_idx++; } - /*---------------------------------------------------------*\ - | Create a keyboard matrix zone | - \*---------------------------------------------------------*/ + + /*-------------------------------------------------*\ + | Create a keyboard matrix zone | + \*-------------------------------------------------*/ if(zone_keyboard) { KEYBOARD_LAYOUT layout = KEYBOARD_LAYOUT::KEYBOARD_LAYOUT_ANSI_QWERTY; @@ -419,9 +460,9 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett description += ", Layout: " + layout_names[layout] + ", Size: " + new_kb.GetName(); - /*-----------------------------------------------------*\ - | Check for custom key inserts and swaps | - \*-----------------------------------------------------*/ + /*---------------------------------------------*\ + | Check for custom key inserts and swaps | + \*---------------------------------------------*/ const char* change_keys = "change_keys"; if(debug_settings.contains(change_keys)) @@ -486,7 +527,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett keyboard_zone.leds_count = new_kb.GetKeyCount(); keyboard_zone.matrix_map = new_kb.GetKeyMap(KEYBOARD_MAP_FILL_TYPE_COUNT); - zones.push_back(keyboard_zone); + if(first_run) + { + zones.push_back(keyboard_zone); + } + else + { + zones[zone_idx] = keyboard_zone; + } for(unsigned int led_idx = 0; led_idx < keyboard_zone.leds_count; led_idx++) { @@ -498,10 +546,13 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett led_alt_names.push_back(new_kb.GetKeyAltNameAt(led_idx)); } + + zone_idx++; } - /*---------------------------------------------------------*\ - | Create an underglow matrix zone | - \*---------------------------------------------------------*/ + + /*-------------------------------------------------*\ + | Create an underglow matrix zone | + \*-------------------------------------------------*/ if(zone_underglow) { zone underglow_zone; @@ -513,7 +564,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett underglow_zone.leds_count = 30; underglow_zone.matrix_map.Set(3, 10, (unsigned int*)&debug_keyboard_underglow_map); - zones.push_back(underglow_zone); + if(first_run) + { + zones.push_back(underglow_zone); + } + else + { + zones[zone_idx] = underglow_zone; + } for(std::size_t led_idx = 0; led_idx < underglow_zone.leds_count; led_idx++) { @@ -525,70 +583,75 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett led_alt_names.push_back(""); } + + zone_idx++; } - /*---------------------------------------------------------*\ - | Create a resizable linear zone | - \*---------------------------------------------------------*/ + + /*-------------------------------------------------*\ + | Create a resizable linear zone | + \*-------------------------------------------------*/ if(zone_resizable) { zone resizable_zone; - resizable_zone.name = "Resizable Zone"; - resizable_zone.type = ZONE_TYPE_LINEAR; resizable_zone.leds_min = 0; resizable_zone.leds_max = 100; - resizable_zone.leds_count = 0; - zones.push_back(resizable_zone); + if(first_run) + { + resizable_zone.flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + zones.push_back(resizable_zone); + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = "Resizable Zone"; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + { + led resizable_led; + + resizable_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx); + + leds.push_back(resizable_led); + + led_alt_names.push_back(""); + } + + zone_idx++; } } SetupColors(); } -RGBController_Debug::~RGBController_Debug() +void RGBController_Debug::DeviceConfigureZone(int zone_idx) { - Shutdown(); -} - -void RGBController_Debug::DeviceResizeZone(int index, int new_size) -{ - //Make sure that it isn't out of bounds (negative numbers) - if(new_size < int(zones[index].leds_min)) + if((size_t)zone_idx < zones.size()) { - new_size = zones[index].leds_min; + SetupZones(); } - - // Same thing as the above line except for over 100 - if(new_size > int(zones[index].leds_max)) - { - new_size = zones[index].leds_max; - } - - // Store the previous amount of LEDs - int old_size = zones[index].leds_count; - - // Set the LED count in the zone to the new ammount - zones[index].leds_count = new_size; - - // Set the new ammount of LEDs for to the new size - size_t old_leds_size = leds.size(); - - // Add the new ammount of LEDs to the old ammount - size_t new_leds_size = leds.size() - old_size + new_size; - - leds.resize(std::max(old_leds_size, new_leds_size)); - - memmove((void *)(&leds[zones[index].start_idx] + old_leds_size), (const void *)(&leds[zones[index].start_idx] + new_leds_size), (old_leds_size - zones[index].start_idx - old_size) * sizeof(led)); - - leds.resize(new_leds_size); - - for(int i = 0; i < new_size; ++i) - { - leds[zones[index].start_idx + i].name = "Linear LED " + std::to_string(i); - } - - SetupColors(); } void RGBController_Debug::DeviceUpdateLEDs() diff --git a/Controllers/DebugController/RGBController_Debug.h b/Controllers/DebugController/RGBController_Debug.h index 48ffa262f..db5a81726 100644 --- a/Controllers/DebugController/RGBController_Debug.h +++ b/Controllers/DebugController/RGBController_Debug.h @@ -20,14 +20,20 @@ using json = nlohmann::json; class RGBController_Debug : public RGBController { public: - RGBController_Debug(bool custom_controller, json debug_settings); + RGBController_Debug(bool custom, json settings); ~RGBController_Debug(); - void DeviceResizeZone(int zone, int new_size); + void SetupZones(); + + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); void DeviceUpdateSingleLED(int led); void DeviceUpdateMode(); + +private: + json debug_settings; + bool custom_controller; }; diff --git a/Controllers/E131Controller/E131ControllerDetect.cpp b/Controllers/E131Controller/E131ControllerDetect.cpp index b4871ba8c..44033f945 100644 --- a/Controllers/E131Controller/E131ControllerDetect.cpp +++ b/Controllers/E131Controller/E131ControllerDetect.cpp @@ -41,12 +41,7 @@ DetectedControllers DetectE131Controllers() \*---------------------------------------------*/ dev.name = ""; dev.ip = ""; - dev.type = ZONE_TYPE_SINGLE; dev.num_leds = 0; - dev.rgb_order = E131_RGB_ORDER_RBG; - dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_LEFT; - dev.matrix_width = 0; - dev.matrix_height = 0; dev.start_channel = 1; dev.start_universe = 1; dev.keepalive_time = 0; @@ -82,128 +77,11 @@ DetectedControllers DetectE131Controllers() dev.keepalive_time = e131_settings["devices"][device_idx]["keepalive_time"]; } - if(e131_settings["devices"][device_idx].contains("matrix_order")) - { - if(e131_settings["devices"][device_idx]["matrix_order"].is_string()) - { - std::string matrix_order_val = e131_settings["devices"][device_idx]["matrix_order"]; - - if(matrix_order_val == "HORIZONTAL_TOP_LEFT") - { - dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_LEFT; - } - else if(matrix_order_val == "HORIZONTAL_TOP_RIGHT") - { - dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_RIGHT; - } - else if(matrix_order_val == "HORIZONTAL_BOTTOM_LEFT") - { - dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_LEFT; - } - else if(matrix_order_val == "HORIZONTAL_BOTTOM_RIGHT") - { - dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_RIGHT; - } - else if(matrix_order_val == "VERTICAL_TOP_LEFT") - { - dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_TOP_LEFT; - } - else if(matrix_order_val == "VERTICAL_TOP_RIGHT") - { - dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_TOP_RIGHT; - } - else if(matrix_order_val == "VERTICAL_BOTTOM_LEFT") - { - dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_BOTTOM_LEFT; - } - else if(matrix_order_val == "VERTICAL_BOTTOM_RIGHT") - { - dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_BOTTOM_RIGHT; - } - } - else - { - dev.matrix_order = e131_settings["devices"][device_idx]["matrix_order"]; - } - } - - if(e131_settings["devices"][device_idx].contains("rgb_order")) - { - if(e131_settings["devices"][device_idx]["rgb_order"].is_string()) - { - std::string rgb_order_val = e131_settings["devices"][device_idx]["rgb_order"]; - - if(rgb_order_val == "RGB") - { - dev.rgb_order = E131_RGB_ORDER_RGB; - } - else if(rgb_order_val == "RBG") - { - dev.rgb_order = E131_RGB_ORDER_RBG; - } - else if(rgb_order_val == "GRB") - { - dev.rgb_order = E131_RGB_ORDER_GRB; - } - else if(rgb_order_val == "GBR") - { - dev.rgb_order = E131_RGB_ORDER_GBR; - } - else if(rgb_order_val == "BRG") - { - dev.rgb_order = E131_RGB_ORDER_BRG; - } - else if(rgb_order_val == "BGR") - { - dev.rgb_order = E131_RGB_ORDER_BGR; - } - } - else - { - dev.rgb_order = e131_settings["devices"][device_idx]["rgb_order"]; - } - } - - if(e131_settings["devices"][device_idx].contains("matrix_width")) - { - dev.matrix_width = e131_settings["devices"][device_idx]["matrix_width"]; - } - - if(e131_settings["devices"][device_idx].contains("matrix_height")) - { - dev.matrix_height = e131_settings["devices"][device_idx]["matrix_height"]; - } - if(e131_settings["devices"][device_idx].contains("universe_size")) { dev.universe_size = e131_settings["devices"][device_idx]["universe_size"]; } - if(e131_settings["devices"][device_idx].contains("type")) - { - if(e131_settings["devices"][device_idx]["type"].is_string()) - { - std::string type_val = e131_settings["devices"][device_idx]["type"]; - - if(type_val == "SINGLE") - { - dev.type = ZONE_TYPE_SINGLE; - } - else if(type_val == "LINEAR") - { - dev.type = ZONE_TYPE_LINEAR; - } - else if(type_val == "MATRIX") - { - dev.type = ZONE_TYPE_MATRIX; - } - } - else - { - dev.type = e131_settings["devices"][device_idx]["type"]; - } - } - /*---------------------------------------------*\ | Determine whether to create a new list or add | | this device to an existing list. A device is | diff --git a/Controllers/E131Controller/RGBController_E131.cpp b/Controllers/E131Controller/RGBController_E131.cpp index 9e7ba6eaf..833b1a4da 100644 --- a/Controllers/E131Controller/RGBController_E131.cpp +++ b/Controllers/E131Controller/RGBController_E131.cpp @@ -28,47 +28,45 @@ using namespace std::chrono_literals; RGBController_E131::RGBController_E131(std::vector device_list) { - bool multicast = false; + bool multicast = false; - devices = device_list; + devices = device_list; - name = "E1.31 Device Group"; - type = DEVICE_TYPE_LEDSTRIP; - description = "E1.31 Streaming ACN Device"; - location = "E1.31: "; + name = "E1.31 Device Group"; + type = DEVICE_TYPE_LEDSTRIP; + description = "E1.31 Streaming ACN Device"; + location = "E1.31: "; - /*-----------------------------------------*\ - | If this controller only represents a | - | single device, use the device name for the| - | controller name | - \*-----------------------------------------*/ + /*-----------------------------------------------------*\ + | If this controller only represents a single device, | + | use the device name for the controller name | + \*-----------------------------------------------------*/ if(devices.size() == 1) { - name = devices[0].name; + name = devices[0].name; } else if(devices[0].ip != "") { - name += " (" + devices[0].ip + ")"; + name += " (" + devices[0].ip + ")"; } - /*-----------------------------------------*\ - | Append the destination address to the | - | location field | - \*-----------------------------------------*/ + /*-----------------------------------------------------*\ + | Append the destination address to the location field | + \*-----------------------------------------------------*/ if(devices[0].ip != "") { - location += "Unicast " + devices[0].ip + ", "; + location += "Unicast " + devices[0].ip + ", "; } else { location += "Multicast, "; - multicast = true; + multicast = true; } - /*-----------------------------------------*\ - | Calculate universe list | - | Use this to fill in the location field | - \*-----------------------------------------*/ + /*-----------------------------------------------------*\ + | Calculate universe list | + | Use this to fill in the location field | + \*-----------------------------------------------------*/ std::vector universe_list; for(unsigned int device_idx = 0; device_idx < devices.size(); device_idx++) @@ -96,58 +94,58 @@ RGBController_E131::RGBController_E131(std::vector device_list) } } - /*-----------------------------------------*\ - | Append "Universe" and make plural if there| - | are multiple universes in use | - \*-----------------------------------------*/ - location += "Universe"; + /*-----------------------------------------------------*\ + | Append "Universe" and make plural if there are | + | multiple universes in use | + \*-----------------------------------------------------*/ + location += "Universe"; if(universe_list.size() > 1) { - location += "s "; + location += "s "; } else { - location += " "; + location += " "; } - /*-----------------------------------------*\ - | Append comma separated list of universes | - \*-----------------------------------------*/ + /*-----------------------------------------------------*\ + | Append comma separated list of universes | + \*-----------------------------------------------------*/ for(unsigned int univ_list_idx = 0; univ_list_idx < universe_list.size(); univ_list_idx++) { location += std::to_string(universe_list[univ_list_idx]); if(univ_list_idx < (universe_list.size() - 1)) { - location += ", "; + location += ", "; } } - /*-----------------------------------------*\ - | Set up modes | - \*-----------------------------------------*/ + /*-----------------------------------------------------*\ + | Set up modes | + \*-----------------------------------------------------*/ mode Direct; - Direct.name = "Direct"; - Direct.value = 0; - Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Direct.color_mode = MODE_COLORS_PER_LED; + Direct.name = "Direct"; + Direct.value = 0; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; modes.push_back(Direct); - /*-----------------------------------------*\ - | Create E1.31 socket | - \*-----------------------------------------*/ - sockfd = e131_socket(); + /*-----------------------------------------------------*\ + | Create E1.31 socket | + \*-----------------------------------------------------*/ + sockfd = e131_socket(); - keepalive_delay = 0ms; + keepalive_delay = 0ms; SetupZones(); - for (std::size_t device_idx = 0; device_idx < devices.size(); device_idx++) + for(std::size_t device_idx = 0; device_idx < devices.size(); device_idx++) { - /*-----------------------------------------*\ - | Update keepalive delay | - \*-----------------------------------------*/ + /*-------------------------------------------------*\ + | Update keepalive delay | + \*-------------------------------------------------*/ if(devices[device_idx].keepalive_time > 0) { if(keepalive_delay.count() == 0 || keepalive_delay.count() > devices[device_idx].keepalive_time) @@ -156,9 +154,9 @@ RGBController_E131::RGBController_E131(std::vector device_list) } } - /*-----------------------------------------*\ - | Add Universes | - \*-----------------------------------------*/ + /*-------------------------------------------------*\ + | Add Universes | + \*-------------------------------------------------*/ float universe_size = (float)devices[device_idx].universe_size; unsigned int total_universes = (unsigned int)ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / universe_size ); @@ -196,104 +194,6 @@ RGBController_E131::RGBController_E131(std::vector device_list) dest_addrs.push_back(dest_addr); } } - - /*-----------------------------------------*\ - | Generate matrix maps | - \*-----------------------------------------*/ - if(devices[device_idx].type == ZONE_TYPE_MATRIX) - { - unsigned int led_idx = 0; - matrix_map_type new_map; - - new_map.width = devices[device_idx].matrix_width; - new_map.height = devices[device_idx].matrix_height; - new_map.map.resize(devices[device_idx].matrix_width * devices[device_idx].matrix_height); - - switch(devices[device_idx].matrix_order) - { - case E131_MATRIX_ORDER_HORIZONTAL_TOP_LEFT: - for(unsigned int y = 0; y < new_map.height; y++) - { - for(unsigned int x = 0; x < new_map.width; x++) - { - new_map.map[(y * new_map.width) + x] = led_idx; - led_idx++; - } - } - break; - case E131_MATRIX_ORDER_HORIZONTAL_TOP_RIGHT: - for(unsigned int y = 0; y < new_map.height; y++) - { - for(int x = new_map.width - 1; x >= 0; x--) - { - new_map.map[(y * new_map.width) + x] = led_idx; - led_idx++; - } - } - break; - case E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_LEFT: - for(int y = new_map.height; y >= 0; y--) - { - for(unsigned int x = 0; x < new_map.width; x++) - { - new_map.map[(y * new_map.width) + x] = led_idx; - led_idx++; - } - } - break; - case E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_RIGHT: - for(int y = new_map.height; y >= 0; y--) - { - for(int x = new_map.width - 1; x >= 0; x--) - { - new_map.map[(y * new_map.width) + x] = led_idx; - led_idx++; - } - } - break; - case E131_MATRIX_ORDER_VERTICAL_TOP_LEFT: - for(unsigned int x = 0; x < new_map.width; x++) - { - for(unsigned int y = 0; y < new_map.height; y++) - { - new_map.map[(y * new_map.width) + x] = led_idx; - led_idx++; - } - } - break; - case E131_MATRIX_ORDER_VERTICAL_TOP_RIGHT: - for(int x = new_map.width - 1; x >= 0; x--) - { - for(unsigned int y = 0; y < new_map.height; y++) - { - new_map.map[(y * new_map.width) + x] = led_idx; - led_idx++; - } - } - break; - case E131_MATRIX_ORDER_VERTICAL_BOTTOM_LEFT: - for(unsigned int x = 0; x < new_map.width; x++) - { - for(int y = new_map.height - 1; y >= 0; y--) - { - new_map.map[(y * new_map.width) + x] = led_idx; - led_idx++; - } - } - break; - case E131_MATRIX_ORDER_VERTICAL_BOTTOM_RIGHT: - for(int x = new_map.width - 1; x >= 0; x--) - { - for(int y = new_map.height - 1; y >= 0; y--) - { - new_map.map[(y * new_map.width) + x] = led_idx; - led_idx++; - } - } - break; - } - zones[device_idx].matrix_map = new_map; - } } if(keepalive_delay.count() > 0) @@ -322,23 +222,28 @@ RGBController_E131::~RGBController_E131() void RGBController_E131::SetupZones() { - /*-----------------------------------------*\ - | Add Zones | - \*-----------------------------------------*/ + /*-----------------------------------------------------*\ + | Add Zones | + \*-----------------------------------------------------*/ for(std::size_t zone_idx = 0; zone_idx < devices.size(); zone_idx++) { zone led_zone; led_zone.name = devices[zone_idx].name; - led_zone.type = devices[zone_idx].type; + led_zone.type = ZONE_TYPE_LINEAR; led_zone.leds_min = devices[zone_idx].num_leds; led_zone.leds_max = devices[zone_idx].num_leds; led_zone.leds_count = devices[zone_idx].num_leds; + led_zone.flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP + | ZONE_FLAG_MANUALLY_CONFIGURABLE_SEGMENTS + | ZONE_FLAG_MANUALLY_CONFIGURABLE_COLOR_ORDER; + zones.push_back(led_zone); } - /*-----------------------------------------*\ - | Add LEDs | - \*-----------------------------------------*/ + /*-----------------------------------------------------*\ + | Add LEDs | + \*-----------------------------------------------------*/ for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) diff --git a/Controllers/E131Controller/RGBController_E131.h b/Controllers/E131Controller/RGBController_E131.h index f84683bac..294428329 100644 --- a/Controllers/E131Controller/RGBController_E131.h +++ b/Controllers/E131Controller/RGBController_E131.h @@ -16,46 +16,15 @@ #include #include "RGBController.h" -typedef unsigned int e131_rgb_order; - -enum -{ - E131_RGB_ORDER_RGB, - E131_RGB_ORDER_RBG, - E131_RGB_ORDER_GRB, - E131_RGB_ORDER_GBR, - E131_RGB_ORDER_BRG, - E131_RGB_ORDER_BGR -}; - -enum -{ - E131_MATRIX_ORDER_HORIZONTAL_TOP_LEFT, - E131_MATRIX_ORDER_HORIZONTAL_TOP_RIGHT, - E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_LEFT, - E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_RIGHT, - E131_MATRIX_ORDER_VERTICAL_TOP_LEFT, - E131_MATRIX_ORDER_VERTICAL_TOP_RIGHT, - E131_MATRIX_ORDER_VERTICAL_BOTTOM_LEFT, - E131_MATRIX_ORDER_VERTICAL_BOTTOM_RIGHT -}; - -typedef unsigned int e131_matrix_order; - struct E131Device { - std::string name; - std::string ip; - unsigned int num_leds; - unsigned int start_universe; - unsigned int start_channel; - unsigned int keepalive_time; - e131_rgb_order rgb_order; - zone_type type; - unsigned int matrix_width; - unsigned int matrix_height; - unsigned int universe_size; - e131_matrix_order matrix_order; + std::string ip; + std::string name; + unsigned int keepalive_time; + unsigned int num_leds; + unsigned int start_channel; + unsigned int start_universe; + unsigned int universe_size; }; class RGBController_E131 : public RGBController diff --git a/Controllers/EVGAAmpereGPUController/RGBController_EVGAGPUv3.cpp b/Controllers/EVGAAmpereGPUController/RGBController_EVGAGPUv3.cpp index dc68392bf..374164e04 100644 --- a/Controllers/EVGAAmpereGPUController/RGBController_EVGAGPUv3.cpp +++ b/Controllers/EVGAAmpereGPUController/RGBController_EVGAGPUv3.cpp @@ -257,9 +257,9 @@ void RGBController_EVGAGPUv3::SetupZones() SetupColors(); } -void RGBController_EVGAGPUv3::DeviceResizeZone(int /*zone*/, int newSize) +void RGBController_EVGAGPUv3::DeviceConfigureZone(int zone_idx) { - controller->ResizeARGB(newSize); + controller->ResizeARGB(zones[zone_idx].leds_count); } void RGBController_EVGAGPUv3::DeviceUpdateLEDs() diff --git a/Controllers/EVGAAmpereGPUController/RGBController_EVGAGPUv3.h b/Controllers/EVGAAmpereGPUController/RGBController_EVGAGPUv3.h index df446b701..6c2cd893c 100644 --- a/Controllers/EVGAAmpereGPUController/RGBController_EVGAGPUv3.h +++ b/Controllers/EVGAAmpereGPUController/RGBController_EVGAGPUv3.h @@ -22,7 +22,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/GaiZongGaiKeyboardController/RGBController_GaiZhongGai.cpp b/Controllers/GaiZongGaiKeyboardController/RGBController_GaiZhongGai.cpp index 089efe7e0..572b9c5fb 100644 --- a/Controllers/GaiZongGaiKeyboardController/RGBController_GaiZhongGai.cpp +++ b/Controllers/GaiZongGaiKeyboardController/RGBController_GaiZhongGai.cpp @@ -458,181 +458,228 @@ RGBController_GaiZhongGaiKeyboard::~RGBController_GaiZhongGaiKeyboard() void RGBController_GaiZhongGaiKeyboard::SetupZones() { - /*---------------------------------------------------------*\ - | Set up zones | - \*---------------------------------------------------------*/ - char str[10]; - unsigned int total_led_count = 0; - unsigned int zone_idx_len = 1; - unsigned int temp; + /*-----------------------------------------------------*\ + | 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(); colors.clear(); - zones.clear(); - - for(unsigned int zone_idx = 0; zone_idx < zone_idx_len; zone_idx++) - { - zone new_zone; - - switch(controller->GetUSBPID()) - { - case GAIZHONGGAI_68_PRO_PID: - { - new_zone.type = ZONE_TYPE_MATRIX; - new_zone.leds_min = 68; - new_zone.leds_max = 68; - new_zone.leds_count = 68; - new_zone.matrix_map.Set(17, 5, (unsigned int *)&matrix_map_68); - new_zone.name = zone_names[zone_idx]; - } - break; - - case GAIZHONGGAI_42_PRO_PID: - { - new_zone.type = ZONE_TYPE_MATRIX; - new_zone.leds_min = 42; - new_zone.leds_max = 42; - new_zone.leds_count = 42; - new_zone.matrix_map.Set(12, 4, (unsigned int *)&matrix_map_42); - new_zone.name = zone_names[zone_idx]; - } - break; - - case GAIZHONGGAI_17_TOUCH_PRO_PID: - { - new_zone.type = ZONE_TYPE_MATRIX; - new_zone.leds_min = 88; - new_zone.leds_max = 88; - new_zone.leds_count = 88; - new_zone.matrix_map.Set(5, 5, (unsigned int *)&matrix_map_PAD_Touch); - new_zone.name = zone_names[zone_idx]; - } - break; - - case GAIZHONGGAI_17_PRO_PID: - { - new_zone.type = ZONE_TYPE_MATRIX; - new_zone.leds_min = 85; - new_zone.leds_max = 85; - new_zone.leds_count = 85; - new_zone.matrix_map.Set(4, 5, (unsigned int *)&matrix_map_17PAD); - new_zone.name = zone_names[zone_idx]; - } - break; - - case GAIZHONGGAI_20_PRO_PID: - { - new_zone.type = ZONE_TYPE_MATRIX; - new_zone.leds_min = 88; - new_zone.leds_max = 88; - new_zone.leds_count = 88; - new_zone.matrix_map.Set(4, 6, (unsigned int *)&matrix_map_20PAD); - new_zone.name = zone_names[zone_idx]; - } - break; - - case GAIZHONGGAI_DIAL_PID: - { - new_zone.type = ZONE_TYPE_MATRIX; - new_zone.leds_min = 89; - new_zone.leds_max = 89; - new_zone.leds_count = 89; - new_zone.matrix_map.Set(2, 2, (unsigned int *)&matrix_map_dial); - new_zone.name = zone_names[zone_idx]; - } - break; - - case GAIZHONGGAI_LIGHT_BOARD_PID: - { - temp = LightBoard_init(controller->GetDataFlash());//get led_len - new_zone.type = ZONE_TYPE_MATRIX; - new_zone.leds_min = temp; - new_zone.leds_max = temp; - new_zone.leds_count = temp; - new_zone.matrix_map.Set(controller->GetDataFlash()[124], controller->GetDataFlash()[125], (unsigned int *)&matrix_map_light_board); - new_zone.name = zone_names[zone_idx + 1]; - } - break; - - case GAIZHONGGAI_RGB_HUB_GREEN_PID: - { - zone_idx_len = 4; - temp = controller->GetChannelLen(zone_idx);//get led_len - new_zone.type = ZONE_TYPE_LINEAR; - new_zone.leds_min = 1; - new_zone.leds_max = 637; - new_zone.leds_count = temp; - new_zone.name = zone_names[zone_idx + 1]; - } - break; - - case GAIZHONGGAI_RGB_HUB_BLUE_PID: - { - zone_idx_len = 8; - temp = controller->GetChannelLen(zone_idx);//get led_len - new_zone.type = ZONE_TYPE_LINEAR; - new_zone.leds_min = 1; - new_zone.leds_max = 633; - new_zone.leds_count = temp; - new_zone.name = zone_names[zone_idx + 1]; - } - break; - } - - zones.push_back(new_zone); - - total_led_count += new_zone.leds_count; - } switch(controller->GetUSBPID()) { - case GAIZHONGGAI_LIGHT_BOARD_PID: - case GAIZHONGGAI_RGB_HUB_GREEN_PID: - case GAIZHONGGAI_RGB_HUB_BLUE_PID: - for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++) - { - led new_led; - snprintf(str, 10, "RGB_%03d", led_idx + 1); - new_led.name = str; - leds.push_back(new_led); - } + default: + zones.resize(1); break; - case GAIZHONGGAI_42_PRO_PID: - for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++) - { + + case GAIZHONGGAI_RGB_HUB_GREEN_PID: + zones.resize(4); + break; + + case GAIZHONGGAI_RGB_HUB_BLUE_PID: + zones.resize(8); + break; + } + + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + unsigned int temp; + + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) + { + switch(controller->GetUSBPID()) + { + case GAIZHONGGAI_68_PRO_PID: + zones[zone_idx].name = zone_names[zone_idx]; + zones[zone_idx].type = ZONE_TYPE_MATRIX; + zones[zone_idx].leds_min = 68; + zones[zone_idx].leds_max = 68; + zones[zone_idx].leds_count = 68; + zones[zone_idx].matrix_map.Set(17, 5, (unsigned int *)&matrix_map_68); + break; + + case GAIZHONGGAI_42_PRO_PID: + zones[zone_idx].name = zone_names[zone_idx]; + zones[zone_idx].type = ZONE_TYPE_MATRIX; + zones[zone_idx].leds_min = 42; + zones[zone_idx].leds_max = 42; + zones[zone_idx].leds_count = 42; + zones[zone_idx].matrix_map.Set(12, 4, (unsigned int *)&matrix_map_42); + break; + + case GAIZHONGGAI_17_TOUCH_PRO_PID: + zones[zone_idx].name = zone_names[zone_idx]; + zones[zone_idx].type = ZONE_TYPE_MATRIX; + zones[zone_idx].leds_min = 88; + zones[zone_idx].leds_max = 88; + zones[zone_idx].leds_count = 88; + zones[zone_idx].matrix_map.Set(5, 5, (unsigned int *)&matrix_map_PAD_Touch); + break; + + case GAIZHONGGAI_17_PRO_PID: + zones[zone_idx].name = zone_names[zone_idx]; + zones[zone_idx].type = ZONE_TYPE_MATRIX; + zones[zone_idx].leds_min = 85; + zones[zone_idx].leds_max = 85; + zones[zone_idx].leds_count = 85; + zones[zone_idx].matrix_map.Set(4, 5, (unsigned int *)&matrix_map_17PAD); + break; + + case GAIZHONGGAI_20_PRO_PID: + zones[zone_idx].name = zone_names[zone_idx]; + zones[zone_idx].type = ZONE_TYPE_MATRIX; + zones[zone_idx].leds_min = 88; + zones[zone_idx].leds_max = 88; + zones[zone_idx].leds_count = 88; + zones[zone_idx].matrix_map.Set(4, 6, (unsigned int *)&matrix_map_20PAD); + break; + + case GAIZHONGGAI_DIAL_PID: + zones[zone_idx].name = zone_names[zone_idx]; + zones[zone_idx].type = ZONE_TYPE_MATRIX; + zones[zone_idx].leds_min = 89; + zones[zone_idx].leds_max = 89; + zones[zone_idx].leds_count = 89; + zones[zone_idx].matrix_map.Set(2, 2, (unsigned int *)&matrix_map_dial); + break; + + case GAIZHONGGAI_LIGHT_BOARD_PID: + temp = LightBoard_init(controller->GetDataFlash());//get led_len + zones[zone_idx].name = zone_names[zone_idx + 1]; + zones[zone_idx].type = ZONE_TYPE_MATRIX; + zones[zone_idx].leds_min = temp; + zones[zone_idx].leds_max = temp; + zones[zone_idx].leds_count = temp; + zones[zone_idx].matrix_map.Set(controller->GetDataFlash()[124], controller->GetDataFlash()[125], (unsigned int *)&matrix_map_light_board); + break; + + case GAIZHONGGAI_RGB_HUB_GREEN_PID: + temp = controller->GetChannelLen(zone_idx);//get led_len + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 637; + + if(first_run) + { + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = zone_names[zone_idx + 1]; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = temp; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + break; + + case GAIZHONGGAI_RGB_HUB_BLUE_PID: + temp = controller->GetChannelLen(zone_idx);//get led_len + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 633; + + if(first_run) + { + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = zone_names[zone_idx + 1]; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = temp; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + break; + } + + switch(controller->GetUSBPID()) + { + case GAIZHONGGAI_LIGHT_BOARD_PID: + case GAIZHONGGAI_RGB_HUB_GREEN_PID: + case GAIZHONGGAI_RGB_HUB_BLUE_PID: + for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + { + led new_led; + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx + 1); + leds.push_back(new_led); + } + break; + + case GAIZHONGGAI_42_PRO_PID: + for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + { led new_led; new_led.name = led_names_42key[led_idx]; leds.push_back(new_led); - } - break; - default: - for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++) - { + } + break; + + default: + for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + { led new_led; new_led.name = led_names_general[led_idx]; leds.push_back(new_led); - } - break; - + } + break; + } } SetupColors(); } -void RGBController_GaiZhongGaiKeyboard::DeviceResizeZone(int zone, int new_size) +void RGBController_GaiZhongGaiKeyboard::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) - { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) + if((size_t)zone_idx < zones.size()) { switch(controller->GetUSBPID()) { case GAIZHONGGAI_RGB_HUB_GREEN_PID: case GAIZHONGGAI_RGB_HUB_BLUE_PID: - controller->SetChannelLen(zone, new_size); + controller->SetChannelLen(zone_idx, zones[zone_idx].leds_count); break; default: return; diff --git a/Controllers/GaiZongGaiKeyboardController/RGBController_GaiZhongGai.h b/Controllers/GaiZongGaiKeyboardController/RGBController_GaiZhongGai.h index 3726211e2..73831d97b 100644 --- a/Controllers/GaiZongGaiKeyboardController/RGBController_GaiZhongGai.h +++ b/Controllers/GaiZongGaiKeyboardController/RGBController_GaiZhongGai.h @@ -20,7 +20,7 @@ public: ~RGBController_GaiZhongGaiKeyboard(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp index da3c04717..efc99c056 100644 --- a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp +++ b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp @@ -328,52 +328,132 @@ void RGBController_RGBFusion2USB::Init_Controller() } } } - - /*---------------------------------------------------------*\ - | Iterate through layout and process each zone | - \*---------------------------------------------------------*/ - for(uint8_t zone_idx = 0; zone_idx < GB_FUSION2_ZONES_MAX; zone_idx++) - { - if(!layout->zones[0][zone_idx]) - { - continue; - } - const gb_fusion2_zone* zone_at_idx = layout->zones[0][zone_idx]; - - zone new_zone; - new_zone.name = zone_at_idx->name; - new_zone.leds_min = zone_at_idx->leds_min; - new_zone.leds_max = zone_at_idx->leds_max; - new_zone.leds_count = new_zone.leds_min; - new_zone.type = (new_zone.leds_min == new_zone.leds_max) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR; - zones.emplace_back(new_zone); - } } void RGBController_RGBFusion2USB::SetupZones() { - /*---------------------------------------------------------*\ - | Clear any existing color/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(); colors.clear(); + /*-----------------------------------------------------*\ + | Count number of zones to resize zones vector | + \*-----------------------------------------------------*/ + unsigned int num_zones; + + for(num_zones = 0; num_zones < GB_FUSION2_ZONES_MAX; num_zones++) + { + if(!gb_fusion2_device_list[device_index]->zones[0][num_zones]) + { + break; + } + } + + zones.resize(num_zones); + unsigned int d1 = 0, d2 = 0, d3 = 0, d4 = 0; - /*---------------------------------------------------------*\ - | Set up zones (Fixed so as to not spam the controller) | - \*---------------------------------------------------------*/ - - for(uint8_t zone_idx = 0; zone_idx < GB_FUSION2_ZONES_MAX; zone_idx++) + /*-----------------------------------------------------*\ + | Set up zones (Fixed so as to not spam the controller) | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { + /*-------------------------------------------------*\ + | Get zone configuration from device data | + \*-------------------------------------------------*/ const gb_fusion2_zone* zone_at_idx = gb_fusion2_device_list[device_index]->zones[0][zone_idx]; + if(!zone_at_idx) { continue; } - bool single_zone = (zone_at_idx->leds_min == zone_at_idx->leds_max); - if(!single_zone) + /*-------------------------------------------------*\ + | Check if this is a fixed-size zone | + \*-------------------------------------------------*/ + bool fixed_zone = (zone_at_idx->leds_min == zone_at_idx->leds_max); + + /*-------------------------------------------------*\ + | (Re-)initialize the zone | + \*-------------------------------------------------*/ + if(fixed_zone) + { + zones[zone_idx].name = zone_at_idx->name; + zones[zone_idx].type = ZONE_TYPE_SINGLE; + zones[zone_idx].leds_min = zone_at_idx->leds_min; + zones[zone_idx].leds_max = zone_at_idx->leds_max; + zones[zone_idx].leds_count = zones[zone_idx].leds_min; + } + else + { + zones[zone_idx].leds_min = zone_at_idx->leds_min; + zones[zone_idx].leds_max = zone_at_idx->leds_max; + + if(first_run) + { + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = zone_at_idx->name; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = zone_at_idx->leds_min; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + } + + /*-------------------------------------------------*\ + | Initialize LEDs | + \*-------------------------------------------------*/ + for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + { + led new_led; + + new_led.name = zone_at_idx->name; + new_led.value = zone_at_idx->idx; + + if(!fixed_zone) + { + new_led.name.append(", LED " + std::to_string(led_idx + 1)); + } + + leds.push_back(new_led); + } + + /*-------------------------------------------------*\ + | If not a fixed-size zone, set up LED sizes | + \*-------------------------------------------------*/ + if(!fixed_zone) { switch(zone_at_idx->idx) { @@ -392,21 +472,6 @@ void RGBController_RGBFusion2USB::SetupZones() break; } } - - for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) - { - led new_led; - - new_led.name = zone_at_idx->name; - new_led.value = zone_at_idx->idx; - - if(!single_zone) - { - new_led.name.append(" LED " + std::to_string(led_idx)); - } - - leds.push_back(new_led); - } } controller->SetLedCount(d1, d2, d3, d4); @@ -414,17 +479,10 @@ void RGBController_RGBFusion2USB::SetupZones() SetupColors(); } -void RGBController_RGBFusion2USB::DeviceResizeZone(int zone, int new_size) +void RGBController_RGBFusion2USB::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.h b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.h index d129a8753..b657ac7cb 100644 --- a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.h +++ b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.h @@ -50,7 +50,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/GoveeController/RGBController_Govee.cpp b/Controllers/GoveeController/RGBController_Govee.cpp index 673a5ad23..8ce792629 100644 --- a/Controllers/GoveeController/RGBController_Govee.cpp +++ b/Controllers/GoveeController/RGBController_Govee.cpp @@ -113,27 +113,20 @@ void RGBController_Govee::SetupZones() SetupColors(); } -void RGBController_Govee::DeviceResizeZone(int zone, int new_size) +void RGBController_Govee::DeviceConfigureZone(int zone_idx) { - if(zone < 0 || zone >= (int)zones.size() || new_size <= 0) + if((size_t)zone_idx < zones.size()) { - return; + leds.clear(); + leds.resize(zones[zone_idx].leds_count); + for(unsigned int i = 0; i < zones[zone_idx].leds_count; i++) + { + leds[i].name = "Govee LED " + std::to_string(i); + } + + SetupColors(); /* re-sync color buffers with LED count */ + DeviceUpdateLEDs(); /* push an updated frame */ } - - new_size = std::max(1, std::min(255, new_size)); - zones[zone].leds_count = new_size; - zones[zone].leds_min = 1; - zones[zone].leds_max = 255; - - leds.clear(); - leds.resize(new_size); - for(int i = 0; i < new_size; ++i) - { - leds[i].name = "Govee LED " + std::to_string(i); - } - - SetupColors(); /* re-sync color buffers with LED count */ - DeviceUpdateLEDs(); /* push an updated frame */ } void RGBController_Govee::DeviceUpdateLEDs() diff --git a/Controllers/GoveeController/RGBController_Govee.h b/Controllers/GoveeController/RGBController_Govee.h index 53517e938..009c95d07 100644 --- a/Controllers/GoveeController/RGBController_Govee.h +++ b/Controllers/GoveeController/RGBController_Govee.h @@ -21,7 +21,7 @@ public: ~RGBController_Govee(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/JGINYUEInternalUSBController/RGBController_JGINYUEInternalUSB.cpp b/Controllers/JGINYUEInternalUSBController/RGBController_JGINYUEInternalUSB.cpp index 20d89d46f..f989a5160 100644 --- a/Controllers/JGINYUEInternalUSBController/RGBController_JGINYUEInternalUSB.cpp +++ b/Controllers/JGINYUEInternalUSBController/RGBController_JGINYUEInternalUSB.cpp @@ -185,9 +185,9 @@ RGBController_JGINYUEInternalUSB::~RGBController_JGINYUEInternalUSB() void RGBController_JGINYUEInternalUSB::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -195,39 +195,57 @@ void RGBController_JGINYUEInternalUSB::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.clear(); colors.clear(); zones.resize(JGINYUE_MAX_ZONES); - /*-------------------------------------------------*\ - | Set zones and leds | - \*-------------------------------------------------*/ - zones[0].name = "ARGB Header 1"; - zones[0].type = ZONE_TYPE_LINEAR; - zones[0].leds_min = 0; - zones[0].leds_max = 100; - - zones[1].name = "ARGB Header 2"; - zones[1].type = ZONE_TYPE_LINEAR; - zones[1].leds_min = 0; - zones[1].leds_max = 100; - - if(first_run) + /*-----------------------------------------------------*\ + | Set zones and leds | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - zones[0].leds_count = 0; - zones[1].leds_count = 0; - } + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 100; + + if(first_run) + { + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = "Addressable RGB Header "; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } - for(unsigned int zone_idx = 0; zone_idx < JGINYUE_MAX_ZONES; zone_idx++) - { for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) { led new_led; - new_led.name = "ARGB Header " + std::to_string(zone_idx + 1) + " LED " + std::to_string(led_idx + 1); - new_led.value = led_idx; + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx + 1); + new_led.value = led_idx; leds.push_back(new_led); } } @@ -235,28 +253,29 @@ void RGBController_JGINYUEInternalUSB::SetupZones() SetupColors(); } -void RGBController_JGINYUEInternalUSB::DeviceResizeZone(int zone, int new_size) +void RGBController_JGINYUEInternalUSB::DeviceConfigureZone(int zone_idx) { - unsigned char area; - - switch(zone) + if((size_t)zone_idx < zones.size()) { - case 0: - area = 0x01; - break; - case 1: - area = 0x02; - break; - default: - area = 0x01; - break; + unsigned char area; + + switch(zone_idx) + { + case 0: + area = 0x01; + break; + case 1: + area = 0x02; + break; + default: + area = 0x01; + break; + } + + controller->Area_resize(zones[zone_idx].leds_count, area); + + SetupZones(); } - - zones[zone].leds_count = new_size; - - SetupZones(); - - controller->Area_resize(new_size, area); } void RGBController_JGINYUEInternalUSB::DeviceUpdateLEDs() diff --git a/Controllers/JGINYUEInternalUSBController/RGBController_JGINYUEInternalUSB.h b/Controllers/JGINYUEInternalUSBController/RGBController_JGINYUEInternalUSB.h index c06148a5d..0679d311e 100644 --- a/Controllers/JGINYUEInternalUSBController/RGBController_JGINYUEInternalUSB.h +++ b/Controllers/JGINYUEInternalUSBController/RGBController_JGINYUEInternalUSB.h @@ -24,7 +24,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/JGINYUEInternalUSBV2Controller/RGBController_JGINYUEInternalUSBV2.cpp b/Controllers/JGINYUEInternalUSBV2Controller/RGBController_JGINYUEInternalUSBV2.cpp index 8f60451fb..5ce0fd9c7 100644 --- a/Controllers/JGINYUEInternalUSBV2Controller/RGBController_JGINYUEInternalUSBV2.cpp +++ b/Controllers/JGINYUEInternalUSBV2Controller/RGBController_JGINYUEInternalUSBV2.cpp @@ -328,7 +328,7 @@ RGBController_JGINYUEInternalUSBV2::RGBController_JGINYUEInternalUSBV2(JGINYUEIn Hourglass.colors.resize(8); //modes.push_back(Hourglass); - InitZones(); + SetupZones(); } RGBController_JGINYUEInternalUSBV2::~RGBController_JGINYUEInternalUSBV2() @@ -340,28 +340,102 @@ RGBController_JGINYUEInternalUSBV2::~RGBController_JGINYUEInternalUSBV2() void RGBController_JGINYUEInternalUSBV2::SetupZones() { - /*-------------------------------------------------*\ - | Clear any existing color/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(); colors.clear(); - /*-------------------------------------------------*\ - | Set zones and leds | - \*-------------------------------------------------*/ unsigned char normal_zone_count = controller->GetZoneCount(); if((controller->support_Global_zone == true) && (normal_zone_count > 1)) { normal_zone_count--; //TODO support_Global_zone } + zones.resize(normal_zone_count); - for(unsigned int zone_idx = 0; zone_idx < normal_zone_count; zone_idx++) + /*-----------------------------------------------------*\ + | Set zones and leds | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { + std::string zone_name; + + switch(controller->device_config[zone_idx].Area_ID) + { + case JGINYUE_USB_V2_ARGB_STRIP_1: + zone_name = "ARGB Strip Header 1"; + break; + case JGINYUE_USB_V2_ARGB_STRIP_2: + zone_name = "ARGB Strip Header 2"; + break; + case JGINYUE_USB_V2_ARGB_FAN_1: + zone_name = "ARGB Fan Header 1"; + break; + case JGINYUE_USB_V2_ARGB_FAN_2: + zone_name = "ARGB Fan Header 2"; + break; + case JGINYUE_USB_V2_ARGB_FAN_3: + zone_name = "ARGB Fan Header 3"; + break; + case JGINYUE_USB_V2_ARGB_FAN_4: + zone_name = "ARGB Fan Header 4"; + break; + case JGINYUE_USB_V2_ARGB_FAN_5: + zone_name = "ARGB Fan Header 5"; + break; + default: + zone_name = "Unknown Device"; + break; + } + + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = controller->device_config[zone_idx].Max_LED_numbers; + + if(first_run) + { + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = zone_name; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) { led new_led; - new_led.name = zones[zone_idx].name + " LED#" + std::to_string(led_idx + 1); + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx + 1); new_led.value = 0; leds.push_back(new_led); } @@ -370,23 +444,24 @@ void RGBController_JGINYUEInternalUSBV2::SetupZones() SetupColors(); } -void RGBController_JGINYUEInternalUSBV2::DeviceResizeZone(int zone, int new_size) +void RGBController_JGINYUEInternalUSBV2::DeviceConfigureZone(int zone_idx) { - unsigned char area; - - area = controller->device_config[zone].Area_ID; - - zones[zone].leds_count = new_size; - - SetupZones(); - - if(modes[active_mode].value == JGINYUE_USB_V2_MODE_DIRECT) + if((size_t)zone_idx < zones.size()) { - controller->DirectLEDControl(zones[zone].colors, new_size, area); - } - else - { - controller->WriteZoneMode(area,modes[active_mode].value, new_size,modes[active_mode].colors, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction); + unsigned char area; + + area = controller->device_config[zone_idx].Area_ID; + + SetupZones(); + + if(modes[active_mode].value == JGINYUE_USB_V2_MODE_DIRECT) + { + controller->DirectLEDControl(zones[zone_idx].colors, zones[zone_idx].leds_count, area); + } + else + { + controller->WriteZoneMode(area, modes[active_mode].value, zones[zone_idx].leds_count, modes[active_mode].colors, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction); + } } } @@ -457,56 +532,3 @@ void RGBController_JGINYUEInternalUSBV2::DeviceUpdateZoneMode(int zone) modes[active_mode].brightness, modes[active_mode].direction); } - -void RGBController_JGINYUEInternalUSBV2::InitZones() -{ - unsigned char normal_zone_count = controller->GetZoneCount(); - zones.clear(); - zones.resize(normal_zone_count); - - if((controller->support_Global_zone == true) && (normal_zone_count > 1)) - { - normal_zone_count--; - //TODO support_Global_zone - } - - for(size_t i = 0; i < normal_zone_count; i++) - { - zone * zone_to_init = &(zones[i]); - AreaConfigurationV2 * cfg = &(controller->device_config[i]); - - zone_to_init->leds_min = 0; - zone_to_init->leds_max = cfg->Max_LED_numbers; - zone_to_init->leds_count = 0; - zone_to_init->type = ZONE_TYPE_LINEAR; - - switch(cfg->Area_ID) - { - case JGINYUE_USB_V2_ARGB_STRIP_1: - zone_to_init->name = "ARGB Strip Header 1"; - break; - case JGINYUE_USB_V2_ARGB_STRIP_2: - zone_to_init->name = "ARGB Strip Header 2"; - break; - case JGINYUE_USB_V2_ARGB_FAN_1: - zone_to_init->name = "ARGB Fan Header 1"; - break; - case JGINYUE_USB_V2_ARGB_FAN_2: - zone_to_init->name = "ARGB Fan Header 2"; - break; - case JGINYUE_USB_V2_ARGB_FAN_3: - zone_to_init->name = "ARGB Fan Header 3"; - break; - case JGINYUE_USB_V2_ARGB_FAN_4: - zone_to_init->name = "ARGB Fan Header 4"; - break; - case JGINYUE_USB_V2_ARGB_FAN_5: - zone_to_init->name = "ARGB Fan Header 5"; - break; - default: - zone_to_init->name = "Unknow Device"; - break; - } - } - SetupZones(); -} diff --git a/Controllers/JGINYUEInternalUSBV2Controller/RGBController_JGINYUEInternalUSBV2.h b/Controllers/JGINYUEInternalUSBV2Controller/RGBController_JGINYUEInternalUSBV2.h index 87ceef6aa..ba5d5b552 100644 --- a/Controllers/JGINYUEInternalUSBV2Controller/RGBController_JGINYUEInternalUSBV2.h +++ b/Controllers/JGINYUEInternalUSBV2Controller/RGBController_JGINYUEInternalUSBV2.h @@ -24,7 +24,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); @@ -35,5 +35,4 @@ public: private: JGINYUEInternalUSBV2Controller* controller; - void InitZones(); }; diff --git a/Controllers/LianLiController/LianLiUniHubALController/RGBController_LianLiUniHubAL.cpp b/Controllers/LianLiController/LianLiUniHubALController/RGBController_LianLiUniHubAL.cpp index f0da9b911..585f38fc7 100644 --- a/Controllers/LianLiController/LianLiUniHubALController/RGBController_LianLiUniHubAL.cpp +++ b/Controllers/LianLiController/LianLiUniHubALController/RGBController_LianLiUniHubAL.cpp @@ -13,20 +13,6 @@ #include #include "RGBController_LianLiUniHubAL.h" -//0xFFFFFFFF indicates an unused entry in matrix -#define NA 0xFFFFFFFF - -static unsigned int matrix_map[8][35] = - { { NA, NA, 10, NA, NA, 11, NA, NA, NA, NA, NA, 30, NA, NA, 31, NA, NA, NA, NA, NA, 50, NA, NA, 51, NA, NA, NA, NA, NA, 70, NA, NA, 71, NA, NA}, - { NA, 9, NA, NA, NA, NA, 12, NA, NA, NA, 29, NA, NA, NA, NA, 32, NA, NA, NA, 49, NA, NA, NA, NA, 52, NA, NA, NA, 69, NA, NA, NA, NA, 72, NA}, - { 8, NA, NA, 1, 2, NA, NA, 13, NA, 28, NA, NA, 21, 22, NA, NA, 33, NA, 48, NA, NA, 41, 42, NA, NA, 53, NA, 68, NA, NA, 61, 62, NA, NA, 73}, - { NA, NA, 0, NA, NA, 3, NA, NA, NA, NA, NA, 20, NA, NA, 23, NA, NA, NA, NA, NA, 40, NA, NA, 43, NA, NA, NA, NA, NA, 60, NA, NA, 63, NA, NA}, - { NA, NA, 7, NA, NA, 4, NA, NA, NA, NA, NA, 27, NA, NA, 24, NA, NA, NA, NA, NA, 47, NA, NA, 44, NA, NA, NA, NA, NA, 67, NA, NA, 64, NA, NA}, - { 19, NA, NA, 6, 5, NA, NA, 14, NA, 39, NA, NA, 26, 25, NA, NA, 34, NA, 59, NA, NA, 46, 45, NA, NA, 54, NA, 79, NA, NA, 66, 65, NA, NA, 74}, - { NA, 18, NA, NA, NA, NA, 15, NA, NA, NA, 38, NA, NA, NA, NA, 35, NA, NA, NA, 58, NA, NA, NA, NA, 55, NA, NA, NA, 78, NA, NA, NA, NA, 75, NA}, - { NA, NA, 17, NA, NA, 16, NA, NA, NA, NA, NA, 37, NA, NA, 36, NA, NA, NA, NA, NA, 57, NA, NA, 56, NA, NA, NA, NA, NA, 77, NA, NA, 76, NA, NA} - }; - /**------------------------------------------------------------------*\ @name Lian Li Uni Hub AL @type USB @@ -49,7 +35,6 @@ RGBController_LianLiUniHubAL::RGBController_LianLiUniHubAL(LianLiUniHubALControl location = controller->GetDeviceLocation(); serial = controller->GetSerialString(); - initializedMode = false; mode Custom; @@ -350,7 +335,7 @@ RGBController_LianLiUniHubAL::RGBController_LianLiUniHubAL(LianLiUniHubALControl Contest.colors.resize(3); modes.push_back(Contest); - RGBController_LianLiUniHubAL::SetupZones(); + SetupZones(); } RGBController_LianLiUniHubAL::~RGBController_LianLiUniHubAL() @@ -370,7 +355,6 @@ void RGBController_LianLiUniHubAL::SetupZones() if(zones.size() == 0) { first_run = true; - zones.resize(UNIHUB_AL_CHANNEL_COUNT); } /*-------------------------------------------------*\ @@ -378,70 +362,70 @@ void RGBController_LianLiUniHubAL::SetupZones() \*-------------------------------------------------*/ leds.clear(); colors.clear(); + zones.resize(UNIHUB_AL_CHANNEL_COUNT); /*-------------------------------------------------*\ | Set zones and leds | \*-------------------------------------------------*/ - for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++) + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) { - zones[channel_idx].name = "Channel "; - zones[channel_idx].name.append(std::to_string(channel_idx + 1)); - - // Note: Matrix types won't get loaded from the sizes.ors as the default zone type in this RGBController is ZONE_TYPE_LINEAR - // This will require augmentation on the ProfileManager.cpp to be able to override zone types but this is probably not wanted in general - if (zones[channel_idx].leds_count == 60 || zones[channel_idx].leds_count == 40 || zones[channel_idx].leds_count == 20 || zones[channel_idx].leds_count == 80) // Assume they're AL120 Fans - { - zones[channel_idx].type = ZONE_TYPE_MATRIX; - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = UNIHUB_AL_CHAN_LED_COUNT; - zones[channel_idx].matrix_map.Set(8, 35, (unsigned int *)&matrix_map); - } - else // Treat as regular LED strip - { - zones[channel_idx].type = ZONE_TYPE_LINEAR; - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = UNIHUB_AL_CHAN_LED_COUNT; - } + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = UNIHUB_AL_CHAN_LED_COUNT; if(first_run) { - zones[channel_idx].leds_count = zones[channel_idx].leds_min; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = "Channel "; + zones[channel_idx].name.append(std::to_string(channel_idx + 1)); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); } for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { led new_led; - new_led.name = zones[channel_idx].name; - new_led.name.append(", LED "); - new_led.name.append(std::to_string(led_ch_idx + 1)); - new_led.value = channel_idx; + new_led.name = zones[channel_idx].name + ", LED " + std::to_string(led_ch_idx + 1); + new_led.value = channel_idx; leds.push_back(new_led); } - } SetupColors(); } -void RGBController_LianLiUniHubAL::DeviceResizeZone(int zone, int new_size) +void RGBController_LianLiUniHubAL::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } void RGBController_LianLiUniHubAL::DeviceUpdateLEDs() { - if(!initializedMode) { DeviceUpdateMode(); @@ -470,7 +454,6 @@ void RGBController_LianLiUniHubAL::DeviceUpdateZoneLEDs(int zone) void RGBController_LianLiUniHubAL::DeviceUpdateSingleLED(int /* led */) { DeviceUpdateMode(); - } void RGBController_LianLiUniHubAL::DeviceUpdateMode() @@ -488,7 +471,6 @@ void RGBController_LianLiUniHubAL::DeviceUpdateMode() /*-----------------------------------------------------*\ | Check modes that requires updating both arrays | \*-----------------------------------------------------*/ - switch(modes[active_mode].value) { case UNIHUB_AL_LED_MODE_STATIC_COLOR: diff --git a/Controllers/LianLiController/LianLiUniHubALController/RGBController_LianLiUniHubAL.h b/Controllers/LianLiController/LianLiUniHubALController/RGBController_LianLiUniHubAL.h index f5b56f7a0..aa8aec8b7 100644 --- a/Controllers/LianLiController/LianLiUniHubALController/RGBController_LianLiUniHubAL.h +++ b/Controllers/LianLiController/LianLiUniHubALController/RGBController_LianLiUniHubAL.h @@ -25,7 +25,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/LianLiController/LianLiUniHubController/RGBController_LianLiUniHub.cpp b/Controllers/LianLiController/LianLiUniHubController/RGBController_LianLiUniHub.cpp index 9c82e4c96..d3390ba3a 100644 --- a/Controllers/LianLiController/LianLiUniHubController/RGBController_LianLiUniHub.cpp +++ b/Controllers/LianLiController/LianLiUniHubController/RGBController_LianLiUniHub.cpp @@ -212,7 +212,7 @@ RGBController_LianLiUniHub::RGBController_LianLiUniHub(LianLiUniHubController* c Rgbh.color_mode = MODE_COLORS_NONE; modes.push_back(Rgbh); - RGBController_LianLiUniHub::SetupZones(); + SetupZones(); } RGBController_LianLiUniHub::~RGBController_LianLiUniHub() @@ -244,31 +244,47 @@ void RGBController_LianLiUniHub::SetupZones() /*-------------------------------------------------*\ | Set zones and leds | \*-------------------------------------------------*/ - int addressableCounter = 1; - for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++) + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) { - zones[channel_idx].name = "Channel "; - zones[channel_idx].name.append(std::to_string(addressableCounter)); - - addressableCounter++; - - zones[channel_idx].type = ZONE_TYPE_LINEAR; - - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = UNIHUB_CHANLED_COUNT; + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = UNIHUB_CHANLED_COUNT; if(first_run) { - zones[channel_idx].leds_count = zones[channel_idx].leds_min; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = "Channel "; + zones[channel_idx].name.append(std::to_string(channel_idx + 1)); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); } for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { led new_led; - new_led.name = zones[channel_idx].name; - new_led.name.append(", LED "); - new_led.name.append(std::to_string(led_ch_idx + 1)); - new_led.value = channel_idx; + new_led.name = zones[channel_idx].name + ", LED " + std::to_string(led_ch_idx + 1); + new_led.value = channel_idx; leds.push_back(new_led); } @@ -277,17 +293,10 @@ void RGBController_LianLiUniHub::SetupZones() SetupColors(); } -void RGBController_LianLiUniHub::DeviceResizeZone(int zone, int new_size) +void RGBController_LianLiUniHub::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/LianLiController/LianLiUniHubController/RGBController_LianLiUniHub.h b/Controllers/LianLiController/LianLiUniHubController/RGBController_LianLiUniHub.h index bbd22141a..c659550f0 100644 --- a/Controllers/LianLiController/LianLiUniHubController/RGBController_LianLiUniHub.h +++ b/Controllers/LianLiController/LianLiUniHubController/RGBController_LianLiUniHub.h @@ -23,7 +23,7 @@ public: ~RGBController_LianLiUniHub(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.cpp b/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.cpp index 42da91319..d9d7eed0b 100644 --- a/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.cpp +++ b/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.cpp @@ -281,7 +281,7 @@ RGBController_LianLiUniHubSL::RGBController_LianLiUniHubSL(LianLiUniHubSLControl } } - RGBController_LianLiUniHubSL::SetupZones(); + SetupZones(); } RGBController_LianLiUniHubSL::~RGBController_LianLiUniHubSL() @@ -293,36 +293,67 @@ RGBController_LianLiUniHubSL::~RGBController_LianLiUniHubSL() void RGBController_LianLiUniHubSL::SetupZones() { - bool first_run = zones.size() == 0; + /*-------------------------------------------------*\ + | Only set LED count on the first run | + \*-------------------------------------------------*/ + bool first_run = false; - leds.clear(); - colors.clear(); - if(first_run) + if(zones.size() == 0) { - zones.resize(UNIHUB_SL_MAX_CHANNEL); + first_run = true; } - for(size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) - { - zones[zone_idx].name = "Channel "; - zones[zone_idx].name.append(std::to_string(zone_idx + 1)); - zones[zone_idx].type = ZONE_TYPE_LINEAR; + /*-------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-------------------------------------------------*/ + leds.clear(); + colors.clear(); + zones.resize(UNIHUB_SL_MAX_CHANNEL); - zones[zone_idx].leds_min = 0; - zones[zone_idx].leds_max = UNIHUB_SL_MAX_FAN_PER_CHANNEL; + /*-------------------------------------------------*\ + | Set zones and leds | + \*-------------------------------------------------*/ + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) + { + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = UNIHUB_SL_MAX_FAN_PER_CHANNEL; if(first_run) { - zones[zone_idx].leds_count = zones[zone_idx].leds_min; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = "Channel "; + zones[channel_idx].name.append(std::to_string(channel_idx + 1)); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); + } + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { led new_led; - new_led.name = zones[zone_idx].name; - new_led.name.append(", Fan "); - new_led.name.append(std::to_string(led_idx + 1)); - new_led.value = (unsigned int)zone_idx; + new_led.name = zones[channel_idx].name + ", LED " + std::to_string(led_ch_idx + 1); + new_led.value = channel_idx; leds.push_back(new_led); } @@ -331,17 +362,10 @@ void RGBController_LianLiUniHubSL::SetupZones() SetupColors(); } -void RGBController_LianLiUniHubSL::DeviceResizeZone(int zone, int new_size) +void RGBController_LianLiUniHubSL::DeviceConfigureZone(int zone_idx) { - if((size_t)zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.h b/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.h index 8afddd8a0..9b5319333 100644 --- a/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.h +++ b/Controllers/LianLiController/LianLiUniHubSLController/RGBController_LianLiUniHubSL.h @@ -23,7 +23,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/LianLiController/LianLiUniHubSLInfinityController/RGBController_LianLiUniHubSLInfinity.cpp b/Controllers/LianLiController/LianLiUniHubSLInfinityController/RGBController_LianLiUniHubSLInfinity.cpp index 2b20103cd..eff6d8fe5 100644 --- a/Controllers/LianLiController/LianLiUniHubSLInfinityController/RGBController_LianLiUniHubSLInfinity.cpp +++ b/Controllers/LianLiController/LianLiUniHubSLInfinityController/RGBController_LianLiUniHubSLInfinity.cpp @@ -309,7 +309,7 @@ RGBController_LianLiUniHubSLInfinity::RGBController_LianLiUniHubSLInfinity(LianL Tunnel.colors.resize(4); modes.push_back(Tunnel); - RGBController_LianLiUniHubSLInfinity::SetupZones(); + SetupZones(); } RGBController_LianLiUniHubSLInfinity::~RGBController_LianLiUniHubSLInfinity() @@ -329,7 +329,6 @@ void RGBController_LianLiUniHubSLInfinity::SetupZones() if(zones.size() == 0) { first_run = true; - zones.resize(UNIHUB_SLINF_CHANNEL_COUNT); } /*-------------------------------------------------*\ @@ -337,51 +336,64 @@ void RGBController_LianLiUniHubSLInfinity::SetupZones() \*-------------------------------------------------*/ leds.clear(); colors.clear(); + zones.resize(UNIHUB_SLINF_CHANNEL_COUNT); /*-------------------------------------------------*\ | Set zones and leds | \*-------------------------------------------------*/ - for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++) + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) { - zones[channel_idx].name = "Channel "; - zones[channel_idx].name.append(std::to_string(channel_idx + 1)); - - zones[channel_idx].type = ZONE_TYPE_LINEAR; - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = UNIHUB_SLINF_CHAN_LED_COUNT; + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = UNIHUB_SLINF_CHAN_LED_COUNT; if(first_run) { - zones[channel_idx].leds_count = zones[channel_idx].leds_min; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = "Channel "; + zones[channel_idx].name.append(std::to_string(channel_idx + 1)); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); } for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { led new_led; - new_led.name = zones[channel_idx].name; - new_led.name.append(", LED "); - new_led.name.append(std::to_string(led_ch_idx + 1)); - new_led.value = channel_idx; + new_led.name = zones[channel_idx].name + ", LED " + std::to_string(led_ch_idx + 1); + new_led.value = channel_idx; leds.push_back(new_led); } - } SetupColors(); } -void RGBController_LianLiUniHubSLInfinity::DeviceResizeZone(int zone, int new_size) +void RGBController_LianLiUniHubSLInfinity::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } @@ -417,7 +429,6 @@ void RGBController_LianLiUniHubSLInfinity::DeviceUpdateZoneLEDs(int zone) void RGBController_LianLiUniHubSLInfinity::DeviceUpdateSingleLED(int /* led */) { DeviceUpdateMode(); - } void RGBController_LianLiUniHubSLInfinity::DeviceUpdateMode() @@ -442,6 +453,5 @@ void RGBController_LianLiUniHubSLInfinity::DeviceUpdateMode() controller->SetChannelMode((unsigned char)zone_idx, modes[active_mode], fan_idx); - } } diff --git a/Controllers/LianLiController/LianLiUniHubSLInfinityController/RGBController_LianLiUniHubSLInfinity.h b/Controllers/LianLiController/LianLiUniHubSLInfinityController/RGBController_LianLiUniHubSLInfinity.h index 4f418f16c..bcbc7bbaf 100644 --- a/Controllers/LianLiController/LianLiUniHubSLInfinityController/RGBController_LianLiUniHubSLInfinity.h +++ b/Controllers/LianLiController/LianLiUniHubSLInfinityController/RGBController_LianLiUniHubSLInfinity.h @@ -27,7 +27,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/LianLiController/LianLiUniHubSLV2Controller/RGBController_LianLiUniHubSLV2.cpp b/Controllers/LianLiController/LianLiUniHubSLV2Controller/RGBController_LianLiUniHubSLV2.cpp index b99548e8e..bfc8bcf7a 100644 --- a/Controllers/LianLiController/LianLiUniHubSLV2Controller/RGBController_LianLiUniHubSLV2.cpp +++ b/Controllers/LianLiController/LianLiUniHubSLV2Controller/RGBController_LianLiUniHubSLV2.cpp @@ -308,7 +308,7 @@ RGBController_LianLiUniHubSLV2::RGBController_LianLiUniHubSLV2(LianLiUniHubSLV2C Tunnel.colors.resize(4); modes.push_back(Tunnel); - RGBController_LianLiUniHubSLV2::SetupZones(); + SetupZones(); } RGBController_LianLiUniHubSLV2::~RGBController_LianLiUniHubSLV2() @@ -328,7 +328,6 @@ void RGBController_LianLiUniHubSLV2::SetupZones() if(zones.size() == 0) { first_run = true; - zones.resize(UNIHUB_SLV2_CHANNEL_COUNT); } /*-------------------------------------------------*\ @@ -336,58 +335,70 @@ void RGBController_LianLiUniHubSLV2::SetupZones() \*-------------------------------------------------*/ leds.clear(); colors.clear(); + zones.resize(UNIHUB_SLV2_CHANNEL_COUNT); /*-------------------------------------------------*\ | Set zones and leds | \*-------------------------------------------------*/ - for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++) + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) { - zones[channel_idx].name = "Channel "; - zones[channel_idx].name.append(std::to_string(channel_idx + 1)); - - zones[channel_idx].type = ZONE_TYPE_LINEAR; - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = UNIHUB_SLV2_CHAN_LED_COUNT; + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = UNIHUB_SLV2_CHAN_LED_COUNT; if(first_run) { - zones[channel_idx].leds_count = zones[channel_idx].leds_min; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = "Channel "; + zones[channel_idx].name.append(std::to_string(channel_idx + 1)); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); } for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { led new_led; - new_led.name = zones[channel_idx].name; - new_led.name.append(", LED "); - new_led.name.append(std::to_string(led_ch_idx + 1)); - new_led.value = channel_idx; + new_led.name = zones[channel_idx].name + ", LED " + std::to_string(led_ch_idx + 1); + new_led.value = channel_idx; leds.push_back(new_led); } - } SetupColors(); } -void RGBController_LianLiUniHubSLV2::DeviceResizeZone(int zone, int new_size) +void RGBController_LianLiUniHubSLV2::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } void RGBController_LianLiUniHubSLV2::DeviceUpdateLEDs() { - if(!initializedMode) { DeviceUpdateMode(); @@ -441,6 +452,5 @@ void RGBController_LianLiUniHubSLV2::DeviceUpdateMode() controller->SetChannelMode((unsigned char)zone_idx, modes[active_mode], fan_idx); - } } diff --git a/Controllers/LianLiController/LianLiUniHubSLV2Controller/RGBController_LianLiUniHubSLV2.h b/Controllers/LianLiController/LianLiUniHubSLV2Controller/RGBController_LianLiUniHubSLV2.h index 4e8667b46..36b12edb9 100644 --- a/Controllers/LianLiController/LianLiUniHubSLV2Controller/RGBController_LianLiUniHubSLV2.h +++ b/Controllers/LianLiController/LianLiUniHubSLV2Controller/RGBController_LianLiUniHubSLV2.h @@ -26,7 +26,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/LianLiController/LianLiUniHub_AL10Controller/RGBController_LianLiUniHub_AL10.cpp b/Controllers/LianLiController/LianLiUniHub_AL10Controller/RGBController_LianLiUniHub_AL10.cpp index 3b5bc349d..e77a0fe2a 100644 --- a/Controllers/LianLiController/LianLiUniHub_AL10Controller/RGBController_LianLiUniHub_AL10.cpp +++ b/Controllers/LianLiController/LianLiUniHub_AL10Controller/RGBController_LianLiUniHub_AL10.cpp @@ -350,7 +350,7 @@ RGBController_LianLiUniHub_AL10::RGBController_LianLiUniHub_AL10(LianLiUniHub_AL modes.push_back(Rgbh); */ - RGBController_LianLiUniHub_AL10::SetupZones(); + SetupZones(); } RGBController_LianLiUniHub_AL10::~RGBController_LianLiUniHub_AL10() @@ -382,31 +382,47 @@ void RGBController_LianLiUniHub_AL10::SetupZones() /*-------------------------------------------------*\ | Set zones and leds | \*-------------------------------------------------*/ - int addressableCounter = 1; - for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++) + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) { - zones[channel_idx].name = "Channel "; - zones[channel_idx].name.append(std::to_string(addressableCounter)); - - addressableCounter++; - - zones[channel_idx].type = ZONE_TYPE_LINEAR; - - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = UNIHUB_AL10_CHANLED_COUNT; + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = UNIHUB_AL10_CHANLED_COUNT; if(first_run) { - zones[channel_idx].leds_count = zones[channel_idx].leds_min; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = "Channel "; + zones[channel_idx].name.append(std::to_string(channel_idx + 1)); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); } for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { led new_led; - new_led.name = zones[channel_idx].name; - new_led.name.append(", LED "); - new_led.name.append(std::to_string(led_ch_idx + 1)); - new_led.value = channel_idx; + new_led.name = zones[channel_idx].name + ", LED " + std::to_string(led_ch_idx + 1); + new_led.value = channel_idx; leds.push_back(new_led); } @@ -415,17 +431,10 @@ void RGBController_LianLiUniHub_AL10::SetupZones() SetupColors(); } -void RGBController_LianLiUniHub_AL10::DeviceResizeZone(int zone, int new_size) +void RGBController_LianLiUniHub_AL10::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/LianLiController/LianLiUniHub_AL10Controller/RGBController_LianLiUniHub_AL10.h b/Controllers/LianLiController/LianLiUniHub_AL10Controller/RGBController_LianLiUniHub_AL10.h index e7adb1ede..2e291351b 100644 --- a/Controllers/LianLiController/LianLiUniHub_AL10Controller/RGBController_LianLiUniHub_AL10.h +++ b/Controllers/LianLiController/LianLiUniHub_AL10Controller/RGBController_LianLiUniHub_AL10.h @@ -25,7 +25,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.cpp b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.cpp index a799d5fda..10f4a5aea 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.cpp @@ -124,12 +124,9 @@ int RGBController_MSIMysticLight185::GetDeviceMode() void RGBController_MSIMysticLight185::SetupZones() { - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ - leds.clear(); - colors.clear(); - + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -137,106 +134,109 @@ void RGBController_MSIMysticLight185::SetupZones() first_run = true; } - if(first_run) + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ + leds.clear(); + colors.clear(); + zones.resize(zone_description.size()); + + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - /*---------------------------------------------------------*\ - | Set up zones | - \*---------------------------------------------------------*/ - for(std::size_t zone_idx = 0; zone_idx < zone_description.size(); ++zone_idx) + const ZoneDescription* zd = zone_description[zone_idx]; + unsigned int maxLeds = (unsigned int)controller->GetMaxDirectLeds(zd->zone_type); + + /*-------------------------------------------------*\ + | This is a fixed size zone | + \*-------------------------------------------------*/ + if(((zd->zone_type != MSI_ZONE_J_RAINBOW_1) + && (zd->zone_type != MSI_ZONE_J_RAINBOW_2) + && (zd->zone_type != MSI_ZONE_J_RAINBOW_3) + && (zd->zone_type != MSI_ZONE_J_CORSAIR))) { - const ZoneDescription* zd = zone_description[zone_idx]; - - zone new_zone; - - new_zone.name = zd->name; - new_zone.flags = 0; - - int maxLeds = (int)controller->GetMaxDirectLeds(zd->zone_type); - - /*-------------------------------------------------*\ - | This is a fixed size zone | - \*-------------------------------------------------*/ - if(((zd->zone_type != MSI_ZONE_J_RAINBOW_1) - && (zd->zone_type != MSI_ZONE_J_RAINBOW_2) - && (zd->zone_type != MSI_ZONE_J_RAINBOW_3) - && (zd->zone_type != MSI_ZONE_J_CORSAIR))) - { - new_zone.leds_min = maxLeds; - new_zone.leds_max = maxLeds; - new_zone.leds_count = maxLeds; - } - /*--------------------------------------------------\ - | This is a resizable zone on a board that does not | - | support per-LED direct mode | - \*-------------------------------------------------*/ - else if(controller->GetSupportedDirectMode() == MSIMysticLight185Controller::DIRECT_MODE_ZONE_BASED) - { - new_zone.leds_min = 0; - new_zone.leds_max = 30;//maxLeds; - new_zone.leds_count = 0; - last_resizable_zone = zd->zone_type; - new_zone.flags |= ZONE_FLAG_RESIZE_EFFECTS_ONLY; - } - /*--------------------------------------------------\ - | This is a resizable zone on a board that does | - | support per-LED direct mode | - \*-------------------------------------------------*/ - else - { - new_zone.leds_min = 0; - new_zone.leds_max = maxLeds; - new_zone.leds_count = 0; - last_resizable_zone = zd->zone_type; - } - - /*-------------------------------------------------*\ - | Determine zone type based on max number of LEDs | - \*-------------------------------------------------*/ - if((new_zone.leds_max == 1) || (new_zone.flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY)) - { - new_zone.type = ZONE_TYPE_SINGLE; - } - else - { - new_zone.type = ZONE_TYPE_LINEAR; - } - - zones.push_back(new_zone); + zones[zone_idx].name = zd->name; + zones[zone_idx].type = ZONE_TYPE_SINGLE; + zones[zone_idx].flags = 0; + zones[zone_idx].leds_min = maxLeds; + zones[zone_idx].leds_max = maxLeds; + zones[zone_idx].leds_count = maxLeds; } - } + /*--------------------------------------------------\ + | This is a resizable zone on a board that does not | + | support per-LED direct mode | + \*-------------------------------------------------*/ + else if(controller->GetSupportedDirectMode() == MSIMysticLight185Controller::DIRECT_MODE_ZONE_BASED) + { + zones[zone_idx].name = zd->name; + zones[zone_idx].type = ZONE_TYPE_SINGLE; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 30;//maxLeds; + zones[zone_idx].leds_count = 0; + last_resizable_zone = zd->zone_type; + } + /*--------------------------------------------------\ + | This is a resizable zone on a board that does | + | support per-LED direct mode | + \*-------------------------------------------------*/ + else + { + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = maxLeds; + if(first_run) + { + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = zd->name; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + last_resizable_zone = zd->zone_type; + } - /*---------------------------------------------------------*\ - | Set up LEDs | - \*---------------------------------------------------------*/ - for(std::size_t zone_idx = 0; zone_idx < zone_description.size(); ++zone_idx) - { controller->SetCycleCount(zone_description[zone_idx]->zone_type, zones[zone_idx].leds_count); - if((zones[zone_idx].flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY) == 0) + if((zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY) == 0) { - for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; ++led_idx) + for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) { led new_led; - - new_led.name = zones[zone_idx].name; - - if(zones[zone_idx].leds_count > 1) - { - new_led.name.append(" LED " + std::to_string(led_idx + 1)); - } - - new_led.value = zone_description[zone_idx]->zone_type; + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx + 1); + new_led.value = zone_description[zone_idx]->zone_type; leds.push_back(new_led); } } else if(zones[zone_idx].leds_count > 0) { led new_led; - - new_led.name = zones[zone_idx].name; - - new_led.value = zone_description[zone_idx]->zone_type; + new_led.name = zones[zone_idx].name; + new_led.value = zone_description[zone_idx]->zone_type; leds.push_back(new_led); } } @@ -244,23 +244,13 @@ void RGBController_MSIMysticLight185::SetupZones() SetupColors(); } -void RGBController_MSIMysticLight185::DeviceResizeZone - ( - int zone, - int new_size - ) +void RGBController_MSIMysticLight185::DeviceConfigureZone(int zone_idx) { - if((size_t)zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; SetupZones(); - if(zone_description[zone]->zone_type == last_resizable_zone) + if(zone_description[zone_idx]->zone_type == last_resizable_zone) { GetDeviceConfig(); last_resizable_zone = MSI_ZONE_NONE; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.h b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.h index 1090e505f..d5f38c51d 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.h +++ b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.h @@ -23,7 +23,7 @@ public: ~RGBController_MSIMysticLight185(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.cpp b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.cpp index 638ff933c..aea0e5c07 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.cpp @@ -104,12 +104,9 @@ int RGBController_MSIMysticLight761::GetDeviceMode() void RGBController_MSIMysticLight761::SetupZones() { - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ - leds.clear(); - colors.clear(); - + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -117,109 +114,109 @@ void RGBController_MSIMysticLight761::SetupZones() first_run = true; } - if(first_run) + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ + leds.clear(); + colors.clear(); + zones.resize(zone_description.size()); + + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - /*---------------------------------------------------------*\ - | Set up zones | - \*---------------------------------------------------------*/ - for(std::size_t zone_idx = 0; zone_idx < zone_description.size(); ++zone_idx) + const ZoneDescription* zd = zone_description[zone_idx]; + unsigned int maxLeds = (unsigned int)controller->GetMaxDirectLeds(zd->zone_type); + + /*-------------------------------------------------*\ + | This is a fixed size zone | + \*-------------------------------------------------*/ + if(((zd->zone_type != MSI_ZONE_J_RAINBOW_1) + && (zd->zone_type != MSI_ZONE_J_RAINBOW_2) + && (zd->zone_type != MSI_ZONE_J_RAINBOW_3) + && (zd->zone_type != MSI_ZONE_J_CORSAIR))) { - const ZoneDescription* zd = zone_description[zone_idx]; - - zone new_zone; - - new_zone.name = zd->name; - new_zone.flags = 0; - - int maxLeds = (int)controller->GetMaxDirectLeds(zd->zone_type); - - /*-------------------------------------------------*\ - | This is a fixed size zone | - \*-------------------------------------------------*/ - if(((zd->zone_type != MSI_ZONE_J_RAINBOW_1) - && (zd->zone_type != MSI_ZONE_J_RAINBOW_2) - && (zd->zone_type != MSI_ZONE_J_RAINBOW_3) - && (zd->zone_type != MSI_ZONE_JAF) - && (zd->zone_type != MSI_ZONE_JARGB_1) - && (zd->zone_type != MSI_ZONE_JARGB_2) - && (zd->zone_type != MSI_ZONE_JARGB_3) - && (zd->zone_type != MSI_ZONE_J_CORSAIR))) - { - new_zone.leds_min = maxLeds; - new_zone.leds_max = maxLeds; - new_zone.leds_count = maxLeds; - } - /*--------------------------------------------------*\ - | This is a resizable zone on a board that does not | - | support per-LED direct mode | - \*--------------------------------------------------*/ - else if(controller->GetSupportedDirectMode() == MSIMysticLight761Controller::DIRECT_MODE_ZONE_BASED) - { - new_zone.leds_min = 0; - new_zone.leds_max = 30;//maxLeds; - new_zone.leds_count = 0; - last_resizable_zone = zd->zone_type; - new_zone.flags |= ZONE_FLAG_RESIZE_EFFECTS_ONLY; - } - /*--------------------------------------------------*\ - | This is a resizable zone on a board that does | - | support per-LED direct mode | - \*--------------------------------------------------*/ - else - { - new_zone.leds_min = 0; - new_zone.leds_max = maxLeds; - new_zone.leds_count = 0; - last_resizable_zone = zd->zone_type; - } - - /*-------------------------------------------------*\ - | Determine zone type based on max number of LEDs | - \*-------------------------------------------------*/ - if((new_zone.leds_max == 1) || (new_zone.flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY)) - { - new_zone.type = ZONE_TYPE_SINGLE; - } - else - { - new_zone.type = ZONE_TYPE_LINEAR; - } - - zones.push_back(new_zone); + zones[zone_idx].name = zd->name; + zones[zone_idx].type = ZONE_TYPE_SINGLE; + zones[zone_idx].flags = 0; + zones[zone_idx].leds_min = maxLeds; + zones[zone_idx].leds_max = maxLeds; + zones[zone_idx].leds_count = maxLeds; + } + /*--------------------------------------------------\ + | This is a resizable zone on a board that does not | + | support per-LED direct mode | + \*-------------------------------------------------*/ + else if(controller->GetSupportedDirectMode() == MSIMysticLight761Controller::DIRECT_MODE_ZONE_BASED) + { + zones[zone_idx].name = zd->name; + zones[zone_idx].type = ZONE_TYPE_SINGLE; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 30;//maxLeds; + zones[zone_idx].leds_count = 0; + last_resizable_zone = zd->zone_type; + } + /*--------------------------------------------------\ + | This is a resizable zone on a board that does | + | support per-LED direct mode | + \*-------------------------------------------------*/ + else + { + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = maxLeds; + + if(first_run) + { + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = zd->name; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + last_resizable_zone = zd->zone_type; } - } - /*---------------------------------------------------------*\ - | Set up LEDs | - \*---------------------------------------------------------*/ - for(std::size_t zone_idx = 0; zone_idx < zone_description.size(); ++zone_idx) - { controller->SetCycleCount(zone_description[zone_idx]->zone_type, zones[zone_idx].leds_count); - if((zones[zone_idx].flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY) == 0) + if((zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY) == 0) { - for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; ++led_idx) + for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) { led new_led; - - new_led.name = zones[zone_idx].name; - - if(zones[zone_idx].leds_count > 1) - { - new_led.name.append(" LED " + std::to_string(led_idx + 1)); - } - - new_led.value = zone_description[zone_idx]->zone_type; + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx + 1); + new_led.value = zone_description[zone_idx]->zone_type; leds.push_back(new_led); } } else if(zones[zone_idx].leds_count > 0) { led new_led; - - new_led.name = zones[zone_idx].name; - - new_led.value = zone_description[zone_idx]->zone_type; + new_led.name = zones[zone_idx].name; + new_led.value = zone_description[zone_idx]->zone_type; leds.push_back(new_led); } } @@ -228,23 +225,13 @@ void RGBController_MSIMysticLight761::SetupZones() } -void RGBController_MSIMysticLight761::DeviceResizeZone - ( - int zone, - int new_size - ) +void RGBController_MSIMysticLight761::DeviceConfigureZone(int zone_idx) { - if((std::size_t)zone >= zones.size()) + if((std::size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; SetupZones(); - if(zone_description[zone]->zone_type == last_resizable_zone) + if(zone_description[zone_idx]->zone_type == last_resizable_zone) { GetDeviceConfig(); last_resizable_zone = MSI_ZONE_NONE; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.h b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.h index 8aa841f21..bbd50985f 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.h +++ b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.h @@ -22,7 +22,7 @@ public: ~RGBController_MSIMysticLight761(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/NZXTHue2Controller/RGBController_NZXTHue2.cpp b/Controllers/NZXTHue2Controller/RGBController_NZXTHue2.cpp index 2bb441cc5..136e831d6 100644 --- a/Controllers/NZXTHue2Controller/RGBController_NZXTHue2.cpp +++ b/Controllers/NZXTHue2Controller/RGBController_NZXTHue2.cpp @@ -427,17 +427,10 @@ void RGBController_NZXTHue2::SetupZones() SetupColors(); } -void RGBController_NZXTHue2::DeviceResizeZone(int zone, int new_size) +void RGBController_NZXTHue2::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } diff --git a/Controllers/NZXTHue2Controller/RGBController_NZXTHue2.h b/Controllers/NZXTHue2Controller/RGBController_NZXTHue2.h index 19411119d..edf07de56 100644 --- a/Controllers/NZXTHue2Controller/RGBController_NZXTHue2.h +++ b/Controllers/NZXTHue2Controller/RGBController_NZXTHue2.h @@ -23,7 +23,7 @@ public: void SetupModes(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/NZXTHuePlusController/RGBController_NZXTHuePlus.cpp b/Controllers/NZXTHuePlusController/RGBController_NZXTHuePlus.cpp index ee96cb4f5..b558eaf75 100644 --- a/Controllers/NZXTHuePlusController/RGBController_NZXTHuePlus.cpp +++ b/Controllers/NZXTHuePlusController/RGBController_NZXTHuePlus.cpp @@ -231,9 +231,9 @@ void RGBController_HuePlus::SetupModes() void RGBController_HuePlus::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -241,62 +241,69 @@ void RGBController_HuePlus::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.clear(); colors.clear(); zones.resize(HUE_PLUS_NUM_CHANNELS); - /*-------------------------------------------------*\ - | Set up zones | - \*-------------------------------------------------*/ - for(unsigned int zone_idx = 0; zone_idx < HUE_PLUS_NUM_CHANNELS; zone_idx++) + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - zones[zone_idx].name = "Hue+ Channel "; - zones[zone_idx].name.append(std::to_string(zone_idx + 1)); - zones[zone_idx].type = ZONE_TYPE_LINEAR; - zones[zone_idx].leds_min = 0; - zones[zone_idx].leds_max = 40; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 40; if(first_run) { - zones[zone_idx].leds_count = controller->channel_leds[zone_idx]; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - } - /*-------------------------------------------------*\ - | Set up LEDs | - \*-------------------------------------------------*/ - for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++) - { - for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = "NZXT Hue+ RGB Header "; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = controller->channel_leds[zone_idx]; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[zone_idx].leds_count; led_ch_idx++) { led new_led; - new_led.name = "Hue+ Channel "; - new_led.name.append(std::to_string(zone_idx + 1)); - new_led.name.append(", LED "); - new_led.name.append(std::to_string(led_idx + 1)); - new_led.value = zone_idx; + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1); leds.push_back(new_led); + leds_channel.push_back(zone_idx); } } SetupColors(); } -void RGBController_HuePlus::DeviceResizeZone(int zone, int new_size) +void RGBController_HuePlus::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/NZXTHuePlusController/RGBController_NZXTHuePlus.h b/Controllers/NZXTHuePlusController/RGBController_NZXTHuePlus.h index 43902a006..81904e8d6 100644 --- a/Controllers/NZXTHuePlusController/RGBController_NZXTHuePlus.h +++ b/Controllers/NZXTHuePlusController/RGBController_NZXTHuePlus.h @@ -24,7 +24,7 @@ public: void SetupModes(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/NollieController/NollieController.cpp b/Controllers/NollieController/NollieController.cpp index 0c22ed5c1..f06d8a29b 100644 --- a/Controllers/NollieController/NollieController.cpp +++ b/Controllers/NollieController/NollieController.cpp @@ -22,6 +22,21 @@ NollieController::NollieController(hid_device* dev_handle, const char* path, uns name = dev_name; usb_vid = vid; usb_pid = pid; + + /*-----------------------------------------------------*\ + | Loop through all known devices to look for a PID | + | match | + \*-----------------------------------------------------*/ + for(unsigned int i = 0; i < NOLLIE_NUM_DEVICES; i++) + { + if((nollie_device_list[i]->vid == vid) && (nollie_device_list[i]->pid == pid)) + { + /*---------------------------------------------*\ + | Set device index | + \*---------------------------------------------*/ + device_index = i; + } + } } std::string NollieController::GetLocationString() @@ -57,7 +72,46 @@ unsigned short NollieController::GetUSBVID() return(usb_vid); } -void NollieController::InitChLEDs(int *led_num_list,int ch_num) +unsigned short NollieController::GetNumChannels() +{ + return(nollie_device_list[device_index]->channels); +} + +unsigned short NollieController::GetLEDsPerChannel() +{ + return(nollie_device_list[device_index]->leds_per_channel); +} + +const int* NollieController::GetChannelIndex() +{ + return(nollie_device_list[device_index]->channel_index); +} + +std::string NollieController::GetChannelName(unsigned short channel) +{ + std::string channel_name; + + if(channel > 27 ) + { + channel_name = "Channel EXT " + std::to_string(channel + 1 - 28); + } + else if(channel > 21 ) + { + channel_name = "Channel GPU " + std::to_string(channel + 1 - 22); + } + else if(channel > 15 ) + { + channel_name = "Channel ATX " + std::to_string(channel + 1 - 16); + } + else + { + channel_name = "Channel " + std::to_string(channel + 1); + } + + return(channel_name); +} + +void NollieController::InitChLEDs(unsigned int *led_num_list,int ch_num) { unsigned char usb_buf[65]; memset(usb_buf, 0x00, sizeof(usb_buf)); diff --git a/Controllers/NollieController/NollieController.h b/Controllers/NollieController/NollieController.h index bf9a7f2a3..1c454d8fb 100644 --- a/Controllers/NollieController/NollieController.h +++ b/Controllers/NollieController/NollieController.h @@ -14,38 +14,9 @@ #include #include #include +#include "NollieDevices.h" #include "RGBController.h" -#define NOLLIE_12_CH_LED_NUM 42 -#define NOLLIE_8_CH_LED_NUM 126 -#define NOLLIE_1_CH_LED_NUM 630 -#define NOLLIE_HS_CH_LED_NUM 256 -#define NOLLIE_FS_CH_LED_NUM 525 - -#define NOLLIERGBOS_2_VID 0x16D5 - -#define NOLLIE32_CHANNELS_NUM 32 -#define NOLLIE32_PID 0x4714 -#define NOLLIE32_VID 0x3061 - -#define NOLLIE16_CHANNELS_NUM 16 -#define NOLLIE16_PID 0x4716 -#define NOLLIE16_VID 0x3061 - -#define NOLLIE8_CHANNELS_NUM 8 -#define NOLLIE8_PID 0x1F01 -#define NOLLIE8_VID 0x16D2 - -#define NOLLIE1_CHANNELS_NUM 1 -#define NOLLIE1_PID 0x1F11 -#define NOLLIE1_VID 0x16D2 - -#define NOLLIE28_12_CHANNELS_NUM 12 -#define NOLLIE28_12_VID 0x16D2 -#define NOLLIE28_12_PID 0x1616 -#define NOLLIE28_L1_PID 0x1617 -#define NOLLIE28_L2_PID 0x1618 - #define NOLLIE32_MOS_TRIGGER_CH 26 #define NOLLIE32_MOS_TRIGGER_LED 20 #define NOLLIE32_FLAG1_CHANNEL 15 @@ -59,11 +30,17 @@ public: std::string GetLocationString(); std::string GetNameString(); std::string GetSerialString(); + unsigned short GetUSBVID(); unsigned short GetUSBPID(); + unsigned short GetNumChannels(); + unsigned short GetLEDsPerChannel(); + + const int* GetChannelIndex(); + std::string GetChannelName(unsigned short channel); void SetMos(bool mos); - void InitChLEDs(int *led_num_list,int ch_num); + void InitChLEDs(unsigned int *led_num_list,int ch_num); void SendUpdate(); void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors); @@ -73,6 +50,7 @@ private: std::string name; unsigned short usb_vid; unsigned short usb_pid; + unsigned int device_index; void SendPacket(unsigned char channel,RGBColor * colors,unsigned int num_colors); void SendPacketFS(unsigned char channel,unsigned char packet_id,RGBColor * colors,unsigned int num_colors); diff --git a/Controllers/NollieController/NollieControllerDetect.cpp b/Controllers/NollieController/NollieControllerDetect.cpp index 8cb3d4386..424368c6a 100644 --- a/Controllers/NollieController/NollieControllerDetect.cpp +++ b/Controllers/NollieController/NollieControllerDetect.cpp @@ -23,11 +23,6 @@ DetectedControllers DetectNollieControllers(hid_device_info* info, const std::st if(dev) { - wchar_t product[128]; - hid_get_product_string(dev, product, 128); - - std::wstring product_str(product); - NollieController* controller = new NollieController(dev, info->path, info->vendor_id, info->product_id, name); RGBController_Nollie* rgb_controller = new RGBController_Nollie(controller); diff --git a/Controllers/NollieController/NollieDevices.cpp b/Controllers/NollieController/NollieDevices.cpp new file mode 100644 index 000000000..dd6b7b3c9 --- /dev/null +++ b/Controllers/NollieController/NollieDevices.cpp @@ -0,0 +1,143 @@ +/*---------------------------------------------------------*\ +| NollieDevices.cpp | +| | +| Device list for Nollie devices | +| | +| Adam Honse (CalcProgrammer1) 20 Mar 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include "NollieDevices.h" + +/*---------------------------------------------------------*\ +| Channel Index Maps | +\*---------------------------------------------------------*/ +static const int dflt[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; +static const int ch32[32] = {5, 4, 3, 2, 1, 0, 15, 14, 26, 27, 28, 29, 30, 31, 8, 9, 19, 18, 17, 16, 7, 6, 25, 24, 23, 22, 21, 20, 13, 12, 11, 10}; +static const int ch16[32] = {19, 18, 17, 16, 24, 25, 26, 27, 20, 21, 22, 23, 31, 30, 29, 28, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; +static const int n16[16] = {3, 2, 1, 0, 8, 9, 10, 11, 4, 5, 6, 7, 15, 14, 13, 12}; + +/*---------------------------------------------------------*\ +| Nollie Devices | +\*---------------------------------------------------------*/ +static const nollie_device nollie32 = +{ + NOLLIE32_VID, + NOLLIE32_PID, + 32, + NOLLIE_HS_CH_LED_NUM, + ch32 +}; + +static const nollie_device nollie16 = +{ + NOLLIE16_VID, + NOLLIE16_PID, + 16, + NOLLIE_HS_CH_LED_NUM, + ch16 +}; + +static const nollie_device nollie8 = +{ + NOLLIE8_VID, + NOLLIE8_PID, + 8, + 126, + dflt +}; + +static const nollie_device nollie1 = +{ + NOLLIE1_VID, + NOLLIE1_PID, + 1, + 630, + dflt +}; + +static const nollie_device nollie28_12 = +{ + NOLLIE28_12_VID, + NOLLIE28_12_PID, + 1, + 42, + dflt +}; + +static const nollie_device nollie28_l1 = +{ + NOLLIE28_12_VID, + NOLLIE28_L1_PID, + 8, + NOLLIE_FS_CH_LED_NUM, + dflt +}; + +static const nollie_device nollie28_l2 = +{ + NOLLIE28_12_VID, + NOLLIE28_L2_PID, + 8, + NOLLIE_FS_CH_LED_NUM, + dflt +}; + +static const nollie_device nollie32_os2 = +{ + NOLLIERGBOS_2_VID, + NOLLIE32_PID, + 32, + NOLLIE_HS_CH_LED_NUM, + ch32 +}; + +static const nollie_device nollie16_os2 = +{ + NOLLIERGBOS_2_VID, + NOLLIE16_PID, + 16, + NOLLIE_HS_CH_LED_NUM, + n16 +}; + +static const nollie_device nollie8_os2 = +{ + NOLLIERGBOS_2_VID, + NOLLIE8_PID, + 8, + 126, + dflt +}; + +static const nollie_device nollie1_os2 = +{ + NOLLIERGBOS_2_VID, + NOLLIE1_PID, + 1, + 630, + dflt +}; + +/*---------------------------------------------------------*\ +| Nollie Device List | +\*---------------------------------------------------------*/ +static const nollie_device* device_list[] = +{ + &nollie32, + &nollie16, + &nollie8, + &nollie1, + &nollie28_12, + &nollie28_l1, + &nollie28_l2, + &nollie32_os2, + &nollie16_os2, + &nollie8_os2, + &nollie1_os2, +}; + +const unsigned int NOLLIE_NUM_DEVICES = (sizeof(device_list) / sizeof(device_list[ 0 ])); +const nollie_device** nollie_device_list = device_list; diff --git a/Controllers/NollieController/NollieDevices.h b/Controllers/NollieController/NollieDevices.h new file mode 100644 index 000000000..0a572cfe6 --- /dev/null +++ b/Controllers/NollieController/NollieDevices.h @@ -0,0 +1,56 @@ +/*---------------------------------------------------------*\ +| NollieDevices.h | +| | +| Device list for Nollie devices | +| | +| Adam Honse (CalcProgrammer1) 20 Mar 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#pragma once + +#include "NollieController.h" + +/*---------------------------------------------------------*\ +| Nollie vendor IDs | +\*---------------------------------------------------------*/ +#define NOLLIERGBOS_2_VID 0x16D5 +#define NOLLIE32_VID 0x3061 +#define NOLLIE16_VID 0x3061 +#define NOLLIE8_VID 0x16D2 +#define NOLLIE1_VID 0x16D2 +#define NOLLIE28_12_VID 0x16D2 + +/*---------------------------------------------------------*\ +| Nollie product IDs | +\*---------------------------------------------------------*/ +#define NOLLIE32_PID 0x4714 +#define NOLLIE16_PID 0x4716 +#define NOLLIE8_PID 0x1F01 +#define NOLLIE1_PID 0x1F11 +#define NOLLIE28_12_PID 0x1616 +#define NOLLIE28_L1_PID 0x1617 +#define NOLLIE28_L2_PID 0x1618 + +/*---------------------------------------------------------*\ +| Common Nollie LED counts | +\*---------------------------------------------------------*/ +#define NOLLIE_HS_CH_LED_NUM 256 +#define NOLLIE_FS_CH_LED_NUM 525 + +typedef struct +{ + unsigned short vid; + unsigned short pid; + unsigned short channels; + unsigned short leds_per_channel; + const int* channel_index; +} nollie_device; + +/*---------------------------------------------------------*\ +| These constant values are defined in NollieDevices.cpp | +\*---------------------------------------------------------*/ +extern const unsigned int NOLLIE_NUM_DEVICES; +extern const nollie_device** nollie_device_list; diff --git a/Controllers/NollieController/RGBController_Nollie.cpp b/Controllers/NollieController/RGBController_Nollie.cpp index d7b8417df..b19c29ca7 100644 --- a/Controllers/NollieController/RGBController_Nollie.cpp +++ b/Controllers/NollieController/RGBController_Nollie.cpp @@ -54,95 +54,65 @@ RGBController_Nollie::~RGBController_Nollie() void RGBController_Nollie::SetupZones() { + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; - unsigned int channels_num = 0; - unsigned int ch_led_num = 0; + if(zones.size() == 0) { first_run = true; } + + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.clear(); colors.clear(); - switch(controller->GetUSBPID()) + zones.resize(controller->GetNumChannels()); + + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++) { - case NOLLIE32_PID: - channels_num = NOLLIE32_CHANNELS_NUM; - ch_led_num = NOLLIE_HS_CH_LED_NUM; - channel_index = ch32; - break; - case NOLLIE16_PID: - channels_num = NOLLIE16_CHANNELS_NUM; - ch_led_num = NOLLIE_HS_CH_LED_NUM; - channel_index = ch16; - if (controller->GetUSBVID() == NOLLIERGBOS_2_VID) - channel_index = n16; - break; - case NOLLIE28_12_PID: - channels_num = NOLLIE28_12_CHANNELS_NUM; - ch_led_num = NOLLIE_12_CH_LED_NUM; - break; - case NOLLIE8_PID: - channels_num = NOLLIE8_CHANNELS_NUM; - ch_led_num = NOLLIE_8_CH_LED_NUM; - break; - case NOLLIE1_PID: - channels_num = NOLLIE1_CHANNELS_NUM; - ch_led_num = NOLLIE_1_CH_LED_NUM; - break; - default: - channels_num = NOLLIE8_CHANNELS_NUM; - ch_led_num = NOLLIE_FS_CH_LED_NUM; - break; - } - zones.resize(channels_num); - for(unsigned int channel_idx = 0; channel_idx < channels_num; channel_idx++) - { - if(channel_idx > 27 ) - { - char ch_idx_string[4]; - snprintf(ch_idx_string, 4, "%d", channel_idx + 1 - 28); - zones[channel_idx].name = "Channel EXT "; - zones[channel_idx].name.append(ch_idx_string); - } - else if(channel_idx > 21 ) - { - char ch_idx_string[4]; - snprintf(ch_idx_string, 4, "%d", channel_idx + 1 - 22); - zones[channel_idx].name = "Channel GPU "; - zones[channel_idx].name.append(ch_idx_string); - } - else if(channel_idx > 15 ) - { - char ch_idx_string[4]; - snprintf(ch_idx_string, 4, "%d", channel_idx + 1 - 16); - zones[channel_idx].name = "Channel ATX "; - zones[channel_idx].name.append(ch_idx_string); - } - else - { - char ch_idx_string[4]; - snprintf(ch_idx_string, 4, "%d", channel_idx + 1); - zones[channel_idx].name = "Channel "; - zones[channel_idx].name.append(ch_idx_string); - } - zones[channel_idx].type = ZONE_TYPE_LINEAR; - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = ch_led_num; + zones[channel_idx].leds_min = 0; + zones[channel_idx].leds_max = controller->GetLEDsPerChannel(); if(first_run) { - zones[channel_idx].leds_count = 0; + zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[channel_idx].name = controller->GetChannelName((unsigned char)channel_idx); + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[channel_idx].leds_count = 0; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[channel_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[channel_idx].matrix_map.width = 0; + zones[channel_idx].matrix_map.height = 0; + zones[channel_idx].matrix_map.map.resize(0); } for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { - char led_idx_string[4]; - snprintf(led_idx_string, 4, "%d", led_ch_idx + 1); - led new_led; - new_led.name = "LED "; - new_led.name.append(led_idx_string); - + new_led.name = zones[channel_idx].name + ", LED " + std::to_string(led_ch_idx); leds.push_back(new_led); leds_channel.push_back(channel_idx); } @@ -151,39 +121,32 @@ void RGBController_Nollie::SetupZones() SetupColors(); } -void RGBController_Nollie::DeviceResizeZone(int zone, int new_size) +void RGBController_Nollie::DeviceConfigureZone(int zone_idx) { - /*-----------------------------------------------------*\ - | Set whether MOS is enabled or not | - \*-----------------------------------------------------*/ - if(controller->GetUSBVID() == NOLLIE32_VID && NOLLIE32_PID == controller->GetUSBPID()) + if((size_t)zone_idx < zones.size()) { - if(zone == NOLLIE32_MOS_TRIGGER_CH && new_size > NOLLIE32_MOS_TRIGGER_LED) + /*-------------------------------------------------*\ + | Set whether MOS is enabled or not | + \*-------------------------------------------------*/ + if(controller->GetUSBVID() == NOLLIE32_VID && NOLLIE32_PID == controller->GetUSBPID()) { - controller->SetMos(false); + if(zone_idx == NOLLIE32_MOS_TRIGGER_CH && zones[zone_idx].leds_count > NOLLIE32_MOS_TRIGGER_LED) + { + controller->SetMos(false); + } + else if(zone_idx == NOLLIE32_MOS_TRIGGER_CH) + { + controller->SetMos(true); + } } - else if(zone == NOLLIE32_MOS_TRIGGER_CH) + + /*-------------------------------------------------*\ + | Nollie1 needs to report the number of LEDs | + \*-------------------------------------------------*/ + if(controller->GetUSBVID() == NOLLIE1_VID && controller->GetUSBPID() == NOLLIE1_PID) { - controller->SetMos(true); + controller->InitChLEDs(&zones[zone_idx].leds_count, controller->GetNumChannels()); } - } - - /*-----------------------------------------------------*\ - | Nollie1 needs to report the number of LEDs | - \*-----------------------------------------------------*/ - if(controller->GetUSBVID() == NOLLIE1_VID && controller->GetUSBPID() == NOLLIE1_PID) - { - controller->InitChLEDs(&new_size,NOLLIE1_CHANNELS_NUM); - } - - if((size_t) zone >= zones.size()) - { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; SetupZones(); } @@ -194,6 +157,7 @@ void RGBController_Nollie::DeviceUpdateLEDs() unsigned int DevPid = controller->GetUSBPID(); if(DevPid == NOLLIE32_PID || DevPid == NOLLIE16_PID) { + const int* channel_index = controller->GetChannelIndex(); std::vector ChSort; for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { @@ -210,7 +174,7 @@ void RGBController_Nollie::DeviceUpdateLEDs() std::sort(ChSort.begin(), ChSort.end()); for(std::size_t i = 0; i < ChSort.size(); i++) { - int* ptr = std::find(channel_index, channel_index + 32, ChSort[i]); + const int* ptr = std::find(channel_index, channel_index + 32, ChSort[i]); int zone_idx = (int)(ptr - channel_index); controller->SetChannelLEDs(ChSort[i], zones[zone_idx].colors, zones[zone_idx].leds_count); } @@ -231,13 +195,13 @@ void RGBController_Nollie::DeviceUpdateLEDs() void RGBController_Nollie::DeviceUpdateZoneLEDs(int zone) { - controller->SetChannelLEDs(channel_index[zone], zones[zone].colors, zones[zone].leds_count); + controller->SetChannelLEDs(controller->GetChannelIndex()[zone], zones[zone].colors, zones[zone].leds_count); } void RGBController_Nollie::DeviceUpdateSingleLED(int led) { unsigned int channel = leds_channel[led]; - controller->SetChannelLEDs(channel_index[channel], zones[channel].colors, zones[channel].leds_count); + controller->SetChannelLEDs(controller->GetChannelIndex()[channel], zones[channel].colors, zones[channel].leds_count); } void RGBController_Nollie::DeviceUpdateMode() diff --git a/Controllers/NollieController/RGBController_Nollie.h b/Controllers/NollieController/RGBController_Nollie.h index 630907b7d..6895aa9fa 100644 --- a/Controllers/NollieController/RGBController_Nollie.h +++ b/Controllers/NollieController/RGBController_Nollie.h @@ -21,7 +21,7 @@ public: ~RGBController_Nollie(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); @@ -32,11 +32,4 @@ public: private: NollieController* controller; std::vector leds_channel; - std::vector zones_channel; - - int* channel_index; - - int ch32[32] = {5, 4, 3, 2, 1, 0, 15, 14, 26, 27, 28, 29, 30, 31, 8, 9, 19, 18, 17, 16, 7, 6, 25, 24, 23, 22, 21, 20, 13, 12, 11, 10}; - int ch16[32] = {19, 18, 17, 16, 24, 25, 26, 27, 20, 21, 22, 23, 31, 30, 29, 28, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; - int n16[16] = {3, 2, 1, 0, 8, 9, 10, 11, 4, 5, 6, 7, 15, 14, 13, 12}; }; diff --git a/Controllers/RazerController/RazerController/RGBController_RazerAddressable.cpp b/Controllers/RazerController/RazerController/RGBController_RazerAddressable.cpp index b8ed9ef41..28493e123 100644 --- a/Controllers/RazerController/RazerController/RGBController_RazerAddressable.cpp +++ b/Controllers/RazerController/RazerController/RGBController_RazerAddressable.cpp @@ -132,11 +132,10 @@ RGBController_RazerAddressable::~RGBController_RazerAddressable() void RGBController_RazerAddressable::SetupZones() { unsigned int device_index = controller->GetDeviceIndex(); - unsigned int zone_count = 0; - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -144,69 +143,86 @@ void RGBController_RazerAddressable::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Count the number of zones for this device | - \*-------------------------------------------------*/ - for(unsigned int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++) + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ + leds.clear(); + colors.clear(); + + /*-----------------------------------------------------*\ + | Count number of zones to resize zones vector | + \*-----------------------------------------------------*/ + unsigned int num_zones; + + for(num_zones = 0; num_zones < RAZER_MAX_ZONES; num_zones++) { - if(device_list[device_index]->zones[zone_id] != NULL) + if(!device_list[device_index]->zones[num_zones]) { - zone_count++; + break; } } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ - leds.clear(); - colors.clear(); - zones.resize(zone_count); + zones.resize(num_zones); - /*---------------------------------------------------------*\ - | Fill in zone information based on device table | - \*---------------------------------------------------------*/ - zone_count = 0; - - for(unsigned int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++) + /*-----------------------------------------------------*\ + | Set up zones | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - if(device_list[device_index]->zones[zone_id] != NULL) + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = device_list[device_index]->zones[zone_idx]->rows * device_list[device_index]->zones[zone_idx]->cols;; + + if(first_run) { - zones[zone_count].name = device_list[device_index]->zones[zone_id]->name; - zones[zone_count].type = device_list[device_index]->zones[zone_id]->type; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; + } - zones[zone_count].leds_min = 0; - zones[zone_count].leds_max = device_list[device_index]->zones[zone_id]->rows * device_list[device_index]->zones[zone_id]->cols; + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + zones[zone_idx].name = device_list[device_index]->zones[zone_idx]->name;; + } - if(first_run) + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = device_list[device_index]->zones[zone_idx]->type; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + if(device_list[device_index]->zones[zone_idx]->type == ZONE_TYPE_MATRIX) { - zones[zone_count].leds_count = 0; - } + zones[zone_idx].matrix_map.height = device_list[device_index]->zones[zone_idx]->rows; + zones[zone_idx].matrix_map.width = device_list[device_index]->zones[zone_idx]->cols; + zones[zone_idx].matrix_map.map.resize(zones[zone_idx].matrix_map.height * zones[zone_idx].matrix_map.width); - if(zones[zone_count].type == ZONE_TYPE_MATRIX) - { - zones[zone_count].matrix_map.height = device_list[device_index]->zones[zone_id]->rows; - zones[zone_count].matrix_map.width = device_list[device_index]->zones[zone_id]->cols; - zones[zone_count].matrix_map.map.resize(zones[zone_count].matrix_map.height * zones[zone_count].matrix_map.width); - - for(unsigned int y = 0; y < zones[zone_count].matrix_map.height; y++) + for(unsigned int y = 0; y < zones[zone_idx].matrix_map.height; y++) { - for(unsigned int x = 0; x < zones[zone_count].matrix_map.width; x++) + for(unsigned int x = 0; x < zones[zone_idx].matrix_map.width; x++) { - zones[zone_count].matrix_map.map[(y * zones[zone_count].matrix_map.width) + x] = (y * zones[zone_count].matrix_map.width) + x; + zones[zone_idx].matrix_map.map[(y * zones[zone_idx].matrix_map.width) + x] = (y * zones[zone_idx].matrix_map.width) + x; } } } - - zone_count++; + else + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } } - } - for(unsigned int zone_id = 0; zone_id < zones.size(); zone_id++) - { - for(unsigned int led_id = 0; led_id < zones[zone_id].leds_count; led_id++) + for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) { led new_led; - new_led.name = "Channel " + std::to_string(zone_id + 1) + ", LED " + std::to_string(led_id + 1); + new_led.name = zones[zone_idx].name + + ", LED " + std::to_string(led_idx + 1); leds.push_back(new_led); } @@ -215,21 +231,10 @@ void RGBController_RazerAddressable::SetupZones() SetupColors(); } -void RGBController_RazerAddressable::DeviceResizeZone(int zone, int new_size) +void RGBController_RazerAddressable::DeviceConfigureZone(int zone_idx) { - /*---------------------------------------------------------*\ - | Only the Razer Chroma Addressable RGB Controller supports | - | zone resizing | - \*---------------------------------------------------------*/ - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - controller->SetAddressableZoneSizes(zones[0].leds_count, zones[1].leds_count, zones[2].leds_count, @@ -243,10 +248,6 @@ void RGBController_RazerAddressable::DeviceResizeZone(int zone, int new_size) void RGBController_RazerAddressable::DeviceUpdateLEDs() { - /*---------------------------------------------------------*\ - | Only the Razer Chroma Addressable RGB Controller supports | - | zone resizing | - \*---------------------------------------------------------*/ RGBColor colors_buf[80 * 6]; for(unsigned int zone_id = 0; zone_id < zones.size(); zone_id++) diff --git a/Controllers/RazerController/RazerController/RGBController_RazerAddressable.h b/Controllers/RazerController/RazerController/RGBController_RazerAddressable.h index 37de640be..91f437bb0 100644 --- a/Controllers/RazerController/RazerController/RGBController_RazerAddressable.h +++ b/Controllers/RazerController/RazerController/RGBController_RazerAddressable.h @@ -33,7 +33,7 @@ public: void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/SRGBmodsController/SRGBmodsLEDControllerV1/RGBController_SRGBmodsLEDControllerV1.cpp b/Controllers/SRGBmodsController/SRGBmodsLEDControllerV1/RGBController_SRGBmodsLEDControllerV1.cpp index 7457af157..52bc77611 100644 --- a/Controllers/SRGBmodsController/SRGBmodsLEDControllerV1/RGBController_SRGBmodsLEDControllerV1.cpp +++ b/Controllers/SRGBmodsController/SRGBmodsLEDControllerV1/RGBController_SRGBmodsLEDControllerV1.cpp @@ -94,9 +94,9 @@ RGBController_SRGBmodsLEDControllerV1::~RGBController_SRGBmodsLEDControllerV1() void RGBController_SRGBmodsLEDControllerV1::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -104,65 +104,73 @@ void RGBController_SRGBmodsLEDControllerV1::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.clear(); colors.clear(); zones.resize(SRGBMODS_LED_CONTROLLER_V1_NUM_CHANNELS); - /*-------------------------------------------------*\ - | Set zones and leds | - \*-------------------------------------------------*/ - for(unsigned int channel_idx = 0; channel_idx < SRGBMODS_LED_CONTROLLER_V1_NUM_CHANNELS; channel_idx++) + /*-----------------------------------------------------*\ + | Set zones and leds | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - char ch_idx_string[2]; - snprintf(ch_idx_string, 2, "%d", channel_idx + 1); - - zones[channel_idx].name = "Channel "; - zones[channel_idx].name.append(ch_idx_string); - zones[channel_idx].type = ZONE_TYPE_LINEAR; - /*-------------------------------------------------*\ | The maximum number of LEDs per channel is 800 | | according to https://srgbmods.net/lcv1/ | \*-------------------------------------------------*/ - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = 800; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 800; if(first_run) { - zones[channel_idx].leds_count = 0; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) { - char led_idx_string[4]; - snprintf(led_idx_string, 4, "%d", led_ch_idx + 1); + zones[zone_idx].name = "Addressable RGB Header "; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[zone_idx].leds_count; led_ch_idx++) + { led new_led; - new_led.name = "LED "; - new_led.name.append(led_idx_string); + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1); leds.push_back(new_led); - leds_channel.push_back(channel_idx); + leds_channel.push_back(zone_idx); } } SetupColors(); } -void RGBController_SRGBmodsLEDControllerV1::DeviceResizeZone(int zone, int new_size) +void RGBController_SRGBmodsLEDControllerV1::DeviceConfigureZone(int zone_idx) { - if((size_t)zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/SRGBmodsController/SRGBmodsLEDControllerV1/RGBController_SRGBmodsLEDControllerV1.h b/Controllers/SRGBmodsController/SRGBmodsLEDControllerV1/RGBController_SRGBmodsLEDControllerV1.h index 53dc4b1b3..22746937f 100644 --- a/Controllers/SRGBmodsController/SRGBmodsLEDControllerV1/RGBController_SRGBmodsLEDControllerV1.h +++ b/Controllers/SRGBmodsController/SRGBmodsLEDControllerV1/RGBController_SRGBmodsLEDControllerV1.h @@ -23,7 +23,7 @@ public: ~RGBController_SRGBmodsLEDControllerV1(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/SRGBmodsController/SRGBmodsPicoController/RGBController_SRGBmodsPico.cpp b/Controllers/SRGBmodsController/SRGBmodsPicoController/RGBController_SRGBmodsPico.cpp index 2f0b17f00..cef62667b 100644 --- a/Controllers/SRGBmodsController/SRGBmodsPicoController/RGBController_SRGBmodsPico.cpp +++ b/Controllers/SRGBmodsController/SRGBmodsPicoController/RGBController_SRGBmodsPico.cpp @@ -53,9 +53,9 @@ RGBController_SRGBmodsPico::~RGBController_SRGBmodsPico() void RGBController_SRGBmodsPico::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -63,65 +63,73 @@ void RGBController_SRGBmodsPico::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.clear(); colors.clear(); zones.resize(SRGBMODS_PICO_NUM_CHANNELS); - /*-------------------------------------------------*\ - | Set zones and leds | - \*-------------------------------------------------*/ - for(unsigned int channel_idx = 0; channel_idx < SRGBMODS_PICO_NUM_CHANNELS; channel_idx++) + /*-----------------------------------------------------*\ + | Set zones and leds | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - char ch_idx_string[2]; - snprintf(ch_idx_string, 2, "%d", channel_idx + 1); - - zones[channel_idx].name = "Channel "; - zones[channel_idx].name.append(ch_idx_string); - zones[channel_idx].type = ZONE_TYPE_LINEAR; - /*-------------------------------------------------*\ | The maximum number of LEDs per channel is 512 | | according to https://srgbmods.net/picoled/ | \*-------------------------------------------------*/ - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = 512; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 512; if(first_run) { - zones[channel_idx].leds_count = 0; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) { - char led_idx_string[4]; - snprintf(led_idx_string, 4, "%d", led_ch_idx + 1); + zones[zone_idx].name = "Addressable RGB Header "; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[zone_idx].leds_count; led_ch_idx++) + { led new_led; - new_led.name = "LED "; - new_led.name.append(led_idx_string); + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1); leds.push_back(new_led); - leds_channel.push_back(channel_idx); + leds_channel.push_back(zone_idx); } } SetupColors(); } -void RGBController_SRGBmodsPico::DeviceResizeZone(int zone, int new_size) +void RGBController_SRGBmodsPico::DeviceConfigureZone(int zone_idx) { - if((size_t)zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/SRGBmodsController/SRGBmodsPicoController/RGBController_SRGBmodsPico.h b/Controllers/SRGBmodsController/SRGBmodsPicoController/RGBController_SRGBmodsPico.h index 9aeef0f43..ea707c7e9 100644 --- a/Controllers/SRGBmodsController/SRGBmodsPicoController/RGBController_SRGBmodsPico.h +++ b/Controllers/SRGBmodsController/SRGBmodsPicoController/RGBController_SRGBmodsPico.h @@ -24,7 +24,7 @@ public: ~RGBController_SRGBmodsPico(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController/RGBController_ThermaltakeRiing.cpp b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController/RGBController_ThermaltakeRiing.cpp index 8b4949b99..996dffc33 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController/RGBController_ThermaltakeRiing.cpp +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController/RGBController_ThermaltakeRiing.cpp @@ -129,9 +129,9 @@ RGBController_ThermaltakeRiing::~RGBController_ThermaltakeRiing() void RGBController_ThermaltakeRiing::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -139,67 +139,73 @@ void RGBController_ThermaltakeRiing::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.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++) + /*-----------------------------------------------------*\ + | Set zones and leds | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - char ch_idx_string[2]; - snprintf(ch_idx_string, 2, "%d", channel_idx + 1); - - zones[channel_idx].name = "Riing Channel "; - zones[channel_idx].name.append(ch_idx_string); - zones[channel_idx].type = ZONE_TYPE_LINEAR; - /*-------------------------------------------------*\ | 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; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 20; if(first_run) { - zones[channel_idx].leds_count = 0; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) { - char led_idx_string[3]; - snprintf(led_idx_string, 3, "%d", led_ch_idx + 1); + zones[zone_idx].name = "Thermaltake Fan Header "; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[zone_idx].leds_count; led_ch_idx++) + { led new_led; - new_led.name = "Riing Channel "; - new_led.name.append(ch_idx_string); - new_led.name.append(", LED "); - new_led.name.append(led_idx_string); + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1); leds.push_back(new_led); - leds_channel.push_back(channel_idx); + leds_channel.push_back(zone_idx); } } SetupColors(); } -void RGBController_ThermaltakeRiing::DeviceResizeZone(int zone, int new_size) +void RGBController_ThermaltakeRiing::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController/RGBController_ThermaltakeRiing.h b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController/RGBController_ThermaltakeRiing.h index 7018dcd91..d1bd049bd 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingController/RGBController_ThermaltakeRiing.h +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingController/RGBController_ThermaltakeRiing.h @@ -21,7 +21,7 @@ public: ~RGBController_ThermaltakeRiing(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController/RGBController_ThermaltakeRiingQuad.cpp b/Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController/RGBController_ThermaltakeRiingQuad.cpp index f0c53876e..173e39608 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController/RGBController_ThermaltakeRiingQuad.cpp +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController/RGBController_ThermaltakeRiingQuad.cpp @@ -55,9 +55,9 @@ RGBController_ThermaltakeRiingQuad::~RGBController_ThermaltakeRiingQuad() void RGBController_ThermaltakeRiingQuad::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -65,67 +65,73 @@ void RGBController_ThermaltakeRiingQuad::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.clear(); colors.clear(); zones.resize(THERMALTAKE_QUAD_NUM_CHANNELS); - /*-------------------------------------------------*\ - | Set zones and leds | - \*-------------------------------------------------*/ - for (unsigned int channel_idx = 0; channel_idx < THERMALTAKE_QUAD_NUM_CHANNELS; channel_idx++) + /*-----------------------------------------------------*\ + | Set zones and leds | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - char ch_idx_string[2]; - snprintf(ch_idx_string, 2, "%d", channel_idx + 1); - - zones[channel_idx].name = "Riing Channel "; - zones[channel_idx].name.append(ch_idx_string); - zones[channel_idx].type = ZONE_TYPE_LINEAR; - /*-------------------------------------------------*\ | The maximum number of colors that would fit in the| | Riing Quad protocol is 54 | \*-------------------------------------------------*/ - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = 60; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 60; if(first_run) { - zones[channel_idx].leds_count = 0; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) { - char led_idx_string[3]; - snprintf(led_idx_string, 3, "%d", led_ch_idx + 1); + zones[zone_idx].name = "Thermaltake Fan Header "; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[zone_idx].leds_count; led_ch_idx++) + { led new_led; - new_led.name = "Riing Channel "; - new_led.name.append(ch_idx_string); - new_led.name.append(", LED "); - new_led.name.append(led_idx_string); + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1); leds.push_back(new_led); - leds_channel.push_back(channel_idx); + leds_channel.push_back(zone_idx); } } SetupColors(); } -void RGBController_ThermaltakeRiingQuad::DeviceResizeZone(int zone, int new_size) +void RGBController_ThermaltakeRiingQuad::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController/RGBController_ThermaltakeRiingQuad.h b/Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController/RGBController_ThermaltakeRiingQuad.h index cf406da88..e27b3a138 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController/RGBController_ThermaltakeRiingQuad.h +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController/RGBController_ThermaltakeRiingQuad.h @@ -21,7 +21,7 @@ public: ~RGBController_ThermaltakeRiingQuad(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingTrioController/RGBController_ThermaltakeRiingTrio.cpp b/Controllers/ThermaltakeRiingController/ThermaltakeRiingTrioController/RGBController_ThermaltakeRiingTrio.cpp index 7058c152b..d51f7b02f 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingTrioController/RGBController_ThermaltakeRiingTrio.cpp +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingTrioController/RGBController_ThermaltakeRiingTrio.cpp @@ -55,9 +55,9 @@ RGBController_ThermaltakeRiingTrio::~RGBController_ThermaltakeRiingTrio() void RGBController_ThermaltakeRiingTrio::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -65,67 +65,73 @@ void RGBController_ThermaltakeRiingTrio::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.clear(); colors.clear(); zones.resize(THERMALTAKE_TRIO_NUM_CHANNELS); - /*-------------------------------------------------*\ - | Set zones and leds | - \*-------------------------------------------------*/ - for (unsigned int channel_idx = 0; channel_idx < THERMALTAKE_TRIO_NUM_CHANNELS; channel_idx++) + /*-----------------------------------------------------*\ + | Set zones and leds | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - char ch_idx_string[2]; - snprintf(ch_idx_string, 2, "%d", channel_idx + 1); - - zones[channel_idx].name = "Riing Channel "; - zones[channel_idx].name.append(ch_idx_string); - zones[channel_idx].type = ZONE_TYPE_LINEAR; - /*-------------------------------------------------*\ | The maximum number of colors that would fit in the| | Riing Trio protocol is 54 | \*-------------------------------------------------*/ - zones[channel_idx].leds_min = 0; - zones[channel_idx].leds_max = 54; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 54; if(first_run) { - zones[channel_idx].leds_count = 0; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) { - char led_idx_string[3]; - snprintf(led_idx_string, 3, "%d", led_ch_idx + 1); + zones[zone_idx].name = "Thermaltake Fan Header "; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[zone_idx].leds_count; led_ch_idx++) + { led new_led; - new_led.name = "Riing Channel "; - new_led.name.append(ch_idx_string); - new_led.name.append(", LED "); - new_led.name.append(led_idx_string); + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1); leds.push_back(new_led); - leds_channel.push_back(channel_idx); + leds_channel.push_back(zone_idx); } } SetupColors(); } -void RGBController_ThermaltakeRiingTrio::DeviceResizeZone(int zone, int new_size) +void RGBController_ThermaltakeRiingTrio::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingTrioController/RGBController_ThermaltakeRiingTrio.h b/Controllers/ThermaltakeRiingController/ThermaltakeRiingTrioController/RGBController_ThermaltakeRiingTrio.h index 27201fc69..fcb84a1d4 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingTrioController/RGBController_ThermaltakeRiingTrio.h +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingTrioController/RGBController_ThermaltakeRiingTrio.h @@ -21,7 +21,7 @@ public: ~RGBController_ThermaltakeRiingTrio(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Controllers/ZalmanZSyncController/RGBController_ZalmanZSync.cpp b/Controllers/ZalmanZSyncController/RGBController_ZalmanZSync.cpp index 0f7cfcca9..0562d7ccc 100644 --- a/Controllers/ZalmanZSyncController/RGBController_ZalmanZSync.cpp +++ b/Controllers/ZalmanZSyncController/RGBController_ZalmanZSync.cpp @@ -236,9 +236,9 @@ void RGBController_ZalmanZSync::SetupModes() void RGBController_ZalmanZSync::SetupZones() { - /*-------------------------------------------------*\ - | Only set LED count on the first run | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only set LED count on the first run | + \*-----------------------------------------------------*/ bool first_run = false; if(zones.size() == 0) @@ -246,66 +246,69 @@ void RGBController_ZalmanZSync::SetupZones() first_run = true; } - /*-------------------------------------------------*\ - | Clear any existing color/LED configuration | - \*-------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Clear any existing color/LED configuration | + \*-----------------------------------------------------*/ leds.clear(); colors.clear(); zones.resize(ZALMAN_Z_SYNC_NUM_CHANNELS); - /*-------------------------------------------------*\ - | Set zones and leds | - \*-------------------------------------------------*/ - for (unsigned int channel_idx = 0; channel_idx < ZALMAN_Z_SYNC_NUM_CHANNELS; channel_idx++) + /*-----------------------------------------------------*\ + | Set zones and leds | + \*-----------------------------------------------------*/ + for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - char ch_idx_string[2]; - snprintf(ch_idx_string, 2, "%d", channel_idx + 1); - - zones[channel_idx].name = "Channel "; - zones[channel_idx].name.append(ch_idx_string); - zones[channel_idx].type = ZONE_TYPE_LINEAR; - - /*-------------------------------------------------*\ - | 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 = 40; + zones[zone_idx].leds_min = 0; + zones[zone_idx].leds_max = 40; if(first_run) { - zones[channel_idx].leds_count = 0; + zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME + | ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE + | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP; } - for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) { - char led_idx_string[4]; - snprintf(led_idx_string, 4, "%d", led_ch_idx + 1); + zones[zone_idx].name = "Addressable RGB Header "; + zones[zone_idx].name.append(std::to_string(zone_idx + 1)); + } + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE)) + { + zones[zone_idx].leds_count = 0; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + zones[zone_idx].type = ZONE_TYPE_LINEAR; + } + + if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP)) + { + zones[zone_idx].matrix_map.width = 0; + zones[zone_idx].matrix_map.height = 0; + zones[zone_idx].matrix_map.map.resize(0); + } + + for(unsigned int led_ch_idx = 0; led_ch_idx < zones[zone_idx].leds_count; led_ch_idx++) + { led new_led; - new_led.name = "LED "; - new_led.name.append(led_idx_string); + new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1); leds.push_back(new_led); - leds_channel.push_back(channel_idx); + leds_channel.push_back(zone_idx); } } SetupColors(); } -void RGBController_ZalmanZSync::DeviceResizeZone(int zone, int new_size) +void RGBController_ZalmanZSync::DeviceConfigureZone(int zone_idx) { - if((size_t) zone >= zones.size()) + if((size_t)zone_idx < zones.size()) { - return; - } - - if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max)) - { - zones[zone].leds_count = new_size; - SetupZones(); } } diff --git a/Controllers/ZalmanZSyncController/RGBController_ZalmanZSync.h b/Controllers/ZalmanZSyncController/RGBController_ZalmanZSync.h index 4b1bf53a2..00f52a051 100644 --- a/Controllers/ZalmanZSyncController/RGBController_ZalmanZSync.h +++ b/Controllers/ZalmanZSyncController/RGBController_ZalmanZSync.h @@ -23,7 +23,7 @@ public: void SetupModes(); void SetupZones(); - void DeviceResizeZone(int zone, int new_size); + void DeviceConfigureZone(int zone_idx); void DeviceUpdateLEDs(); void DeviceUpdateZoneLEDs(int zone); diff --git a/Documentation/OpenRGBSDK.md b/Documentation/OpenRGBSDK.md index 5727e7c58..b1e073416 100644 --- a/Documentation/OpenRGBSDK.md +++ b/Documentation/OpenRGBSDK.md @@ -72,6 +72,7 @@ The following IDs represent different SDK commands. Each ID packet has a certai | 1000 | [NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE](#net_packet_id_rgbcontroller_resizezone) | RGBController::ResizeZone() | 0 | | 1001 | [NET_PACKET_ID_RGBCONTROLLER_CLEARSEGMENTS](#net_packet_id_rgbcontroller_clearsegments) | RGBController::ClearSegments() | 5 | | 1002 | [NET_PACKET_ID_RGBCONTROLLER_ADDSEGMENT](#net_packet_id_rgbcontroller_addsegment) | RGBController::AddSegment() | 5 | +| 1003 | [NET_PACKET_ID_RGBCONTROLLER_CONFIGUREZONE](#net_packet_id_rgbcontroller_configurezone) | RGBController::ConfigureZone() | 6 | | 1050 | [NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS](#net_packet_id_rgbcontroller_updateleds) | RGBController::UpdateLEDs() | 0 | | 1051 | [NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS](#net_packet_id_rgbcontroller_updatezoneleds) | RGBController::UpdateZoneLEDs() | 0 | | 1052 | [NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED](#net_packet_id_rgbcontroller_updatesingleled) | RGBController::UpdateSingleLED() | 0 | @@ -436,6 +437,16 @@ The client uses this ID to call the AddSegment() function of an RGBController de | 4 | unsigned int | zone_idx | Zone index to add segment to | | Variable | Segment Data | segment | See [Segment Data](#segment-data) block format table. | +## NET_PACKET_ID_RGBCONTROLLER_CONFIGUREZONE + +The client uses this ID to call the ConfigureZone() function of an RGBController device. The packet contains a data block. The format of the block is shown below. The `pkt_dev_id` of this request's header indicates which controller you are calling ConfigureZone() on. See the [Device IDs](#device-ids) section for more information. + +| Size | Format | Name | Description | +| ---------------- | ---------------------- | ---------------- | --------------------------------------------------------- | +| 4 | unsigned int | data_size | Size of all data in packet | +| 4 | unsigned int | zone_idx | Zone index to configure | +| Variable | Zone Data | zone | See [Zone Data](#zone-data) block format table. | + ## NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS ### Client Only [Size: Variable] diff --git a/NetworkClient.cpp b/NetworkClient.cpp index 13c879a15..b1ff1746d 100644 --- a/NetworkClient.cpp +++ b/NetworkClient.cpp @@ -562,6 +562,23 @@ void NetworkClient::SendRequest_RGBController_AddSegment(unsigned int dev_idx, u send_in_progress.unlock(); } +void NetworkClient::SendRequest_RGBController_ConfigureZone(unsigned int dev_idx, unsigned char * data, unsigned int size) +{ + if(change_in_progress) + { + return; + } + + NetPacketHeader request_hdr; + + InitNetPacketHeader(&request_hdr, dev_idx, NET_PACKET_ID_RGBCONTROLLER_CONFIGUREZONE, size); + + send_in_progress.lock(); + send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL); + send(client_sock, (char *)data, size, 0); + send_in_progress.unlock(); +} + void NetworkClient::SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size) { if(change_in_progress) diff --git a/NetworkClient.h b/NetworkClient.h index 3c9a3fc37..9552e57d3 100644 --- a/NetworkClient.h +++ b/NetworkClient.h @@ -119,6 +119,7 @@ public: void SendRequest_RGBController_ClearSegments(unsigned int dev_idx, int zone); void SendRequest_RGBController_AddSegment(unsigned int dev_idx, unsigned char * data, unsigned int size); + void SendRequest_RGBController_ConfigureZone(unsigned int dev_idx, unsigned char * data, unsigned int size); void SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size); void SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size); diff --git a/NetworkProtocol.h b/NetworkProtocol.h index 1561d78b1..5af9542d5 100644 --- a/NetworkProtocol.h +++ b/NetworkProtocol.h @@ -136,6 +136,7 @@ enum NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE = 1000, /* RGBController::ResizeZone() */ NET_PACKET_ID_RGBCONTROLLER_CLEARSEGMENTS = 1001, /* RGBController::ClearSegments() */ NET_PACKET_ID_RGBCONTROLLER_ADDSEGMENT = 1002, /* RGBController::AddSegment() */ + NET_PACKET_ID_RGBCONTROLLER_CONFIGUREZONE = 1003, /* RGBController::ConfigureZone() */ NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS = 1050, /* RGBController::UpdateLEDs() */ NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS = 1051, /* RGBController::UpdateZoneLEDs() */ diff --git a/NetworkServer.cpp b/NetworkServer.cpp index 84892b794..e83f426a0 100644 --- a/NetworkServer.cpp +++ b/NetworkServer.cpp @@ -1412,6 +1412,25 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info) goto listen_done; } break; + + case NET_PACKET_ID_RGBCONTROLLER_CONFIGUREZONE: + /*-----------------------------------------*\ + | Verify the packet size in the packet data | + | (first 4 bytes of data) matches the | + | packet size in the header | + \*-----------------------------------------*/ + if((data != NULL) + && (header.pkt_size >= sizeof(unsigned int)) + && (header.pkt_size == *((unsigned int*)data))) + { + ProcessRequest_RGBController_ConfigureZone(header.pkt_dev_id, (unsigned char *)data, client_info->client_protocol_version); + } + else + { + LOG_ERROR("[%s] ConfigureZone packet has invalid size. Packet size: %d", header.pkt_size, NETWORKSERVER); + goto listen_done; + } + break; } if(delete_data) @@ -1727,6 +1746,49 @@ void NetworkServer::ProcessRequest_RGBController_ClearSegments(unsigned int cont profile_manager->SaveSizes(); } +void NetworkServer::ProcessRequest_RGBController_ConfigureZone(unsigned int controller_id, unsigned char * data_ptr, unsigned int protocol_version) +{ + /*-----------------------------------------------------*\ + | Convert ID to index | + \*-----------------------------------------------------*/ + bool idx_valid; + unsigned int controller_idx = index_from_id(controller_id, protocol_version, &idx_valid); + int zone_idx; + + /*-----------------------------------------------------*\ + | If controller ID is invalid, return | + \*-----------------------------------------------------*/ + if(!idx_valid) + { + return; + } + + /*-----------------------------------------------------*\ + | Skip data size | + \*-----------------------------------------------------*/ + data_ptr += sizeof(unsigned int); + + /*-----------------------------------------------------*\ + | Copy in zone index | + \*-----------------------------------------------------*/ + memcpy(&zone_idx, data_ptr, sizeof(zone_idx)); + data_ptr += sizeof(zone_idx); + + /*-----------------------------------------------------*\ + | Configure zone | + \*-----------------------------------------------------*/ + zone new_zone; + + data_ptr = controllers[controller_idx]->SetZoneDescription(data_ptr, &new_zone, protocol_version); + + controllers[controller_idx]->ConfigureZone(zone_idx, new_zone); + + /*-----------------------------------------------------*\ + | Save sizes | + \*-----------------------------------------------------*/ + profile_manager->SaveSizes(); +} + void NetworkServer::ProcessRequest_RGBController_ResizeZone(unsigned int controller_id, unsigned char * data_ptr, unsigned int protocol_version) { /*-----------------------------------------------------*\ diff --git a/NetworkServer.h b/NetworkServer.h index 6bee8c399..fd2e07619 100644 --- a/NetworkServer.h +++ b/NetworkServer.h @@ -239,6 +239,7 @@ private: void ProcessRequest_RGBController_AddSegment(unsigned int controller_id, unsigned char * data_ptr, unsigned int protocol_version); void ProcessRequest_RGBController_ClearSegments(unsigned int controller_id, unsigned char * data_ptr, unsigned int protocol_version); + void ProcessRequest_RGBController_ConfigureZone(unsigned int controller_id, unsigned char * data_ptr, unsigned int protocol_version); void ProcessRequest_RGBController_ResizeZone(unsigned int controller_id, unsigned char * data_ptr, unsigned int protocol_version); void ProcessRequest_RGBController_SetCustomMode(unsigned int controller_id, unsigned int protocol_version); void ProcessRequest_RGBController_UpdateLEDs(unsigned int controller_id, unsigned char * data_ptr, unsigned int protocol_version); diff --git a/ProfileManager.cpp b/ProfileManager.cpp index d1abacd7b..81a65ec0e 100644 --- a/ProfileManager.cpp +++ b/ProfileManager.cpp @@ -213,11 +213,32 @@ bool ProfileManager::CompareControllers(RGBController* controller_1, RGBControll { for(std::size_t zone_index = 0; zone_index < controller_1->zones.size(); zone_index++) { - if((controller_1->GetZoneName(zone_index) != controller_2->GetZoneName(zone_index) ) - || (controller_1->GetZoneType(zone_index) != controller_2->GetZoneType(zone_index) ) - || (controller_1->GetZoneLEDsMin(zone_index) != controller_2->GetZoneLEDsMin(zone_index) ) - || (controller_1->GetZoneLEDsMax(zone_index) != controller_2->GetZoneLEDsMax(zone_index) ) - || (controller_1->GetZoneModeCount(zone_index) != controller_2->GetZoneModeCount(zone_index))) + bool check_zone_name = true; + bool check_zone_type = true; + + /*---------------------------------------------*\ + | Do not check zone name if manually configured | + \*---------------------------------------------*/ + if((controller_1->GetZoneFlags(zone_index) & ZONE_FLAG_MANUALLY_CONFIGURED_NAME) + || (controller_2->GetZoneFlags(zone_index) & ZONE_FLAG_MANUALLY_CONFIGURED_NAME)) + { + check_zone_name = false; + } + + /*---------------------------------------------*\ + | Do not check zone type if manually configured | + \*---------------------------------------------*/ + if((controller_1->GetZoneFlags(zone_index) & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE) + || (controller_2->GetZoneFlags(zone_index) & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE)) + { + check_zone_type = false; + } + + if((check_zone_name && (controller_1->GetZoneName(zone_index) != controller_2->GetZoneName(zone_index) )) + || (check_zone_type && (controller_1->GetZoneType(zone_index) != controller_2->GetZoneType(zone_index) )) + || (controller_1->GetZoneLEDsMin(zone_index) != controller_2->GetZoneLEDsMin(zone_index) ) + || (controller_1->GetZoneLEDsMax(zone_index) != controller_2->GetZoneLEDsMax(zone_index) ) + || (controller_1->GetZoneModeCount(zone_index) != controller_2->GetZoneModeCount(zone_index))) { return(false); } @@ -828,7 +849,7 @@ bool ProfileManager::SaveSizes() for(std::size_t zone_index = 0; zone_index < controllers[controller_index]->GetZoneCount(); zone_index++) { - if(controllers[controller_index]->GetZoneFlags(zone_index) & ZONE_FLAG_MANUALLY_CONFIGURED) + if(controllers[controller_index]->GetZoneFlags(zone_index) & ZONE_FLAGS_MANUALLY_CONFIGURED) { /*---------------------------------------------*\ | Read the controller data for this controller | @@ -1100,17 +1121,37 @@ bool ProfileManager::LoadControllerFromListWithOptions { for(std::size_t zone_idx = 0; zone_idx < profile_controller->zones.size(); zone_idx++) { - if((profile_controller->GetZoneName(zone_idx) == load_controller->GetZoneName(zone_idx) ) - &&(profile_controller->GetZoneType(zone_idx) == load_controller->GetZoneType(zone_idx) ) - &&(profile_controller->GetZoneLEDsMin(zone_idx) == load_controller->GetZoneLEDsMin(zone_idx) ) - &&(profile_controller->GetZoneLEDsMax(zone_idx) == load_controller->GetZoneLEDsMax(zone_idx) )) - { - if(profile_controller->GetZoneLEDsCount(zone_idx) != load_controller->GetZoneLEDsCount(zone_idx)) - { - load_controller->ResizeZone((int)zone_idx, profile_controller->zones[zone_idx].leds_count); - } + bool check_zone_name = true; + bool check_zone_type = true; - if(profile_controller->zones[zone_idx].segments.size() != load_controller->zones[zone_idx].segments.size()) + /*---------------------------------*\ + | Do not check zone name if | + | manually configured | + \*---------------------------------*/ + if((profile_controller->GetZoneFlags(zone_idx) & ZONE_FLAG_MANUALLY_CONFIGURED_NAME) + || (load_controller->GetZoneFlags(zone_idx) & ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME)) + { + check_zone_name = false; + } + + /*---------------------------------*\ + | Do not check zone type if | + | manually configured | + \*---------------------------------*/ + if((profile_controller->GetZoneFlags(zone_idx) & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE) + || (load_controller->GetZoneFlags(zone_idx) & ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE)) + { + check_zone_type = false; + } + + if((!check_zone_name || (profile_controller->GetZoneName(zone_idx) == load_controller->GetZoneName(zone_idx) )) + && (!check_zone_type || (profile_controller->GetZoneType(zone_idx) == load_controller->GetZoneType(zone_idx) )) + && (profile_controller->GetZoneLEDsMin(zone_idx) == load_controller->GetZoneLEDsMin(zone_idx) ) + && (profile_controller->GetZoneLEDsMax(zone_idx) == load_controller->GetZoneLEDsMax(zone_idx) )) + { + load_controller->ConfigureZone(zone_idx, profile_controller->zones[zone_idx]); + + if(profile_controller->GetZoneFlags(zone_idx) & ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS) { load_controller->zones[zone_idx].segments.clear(); diff --git a/RGBController/RGBController.cpp b/RGBController/RGBController.cpp index ea68fdbb8..f026085ec 100644 --- a/RGBController/RGBController.cpp +++ b/RGBController/RGBController.cpp @@ -87,6 +87,7 @@ segment::segment() type = 0; start_idx = 0; leds_count = 0; + flags = 0; } segment::~segment() @@ -229,6 +230,20 @@ void RGBController::SetHidden(bool hidden) /*---------------------------------------------------------*\ | Zone Functions | \*---------------------------------------------------------*/ +zone RGBController::GetZone(unsigned int zone_idx) +{ + zone zone_copy; + + AccessMutex.lock_shared(); + if(zone_idx < zones.size()) + { + zone_copy = zones[zone_idx]; + } + AccessMutex.unlock_shared(); + + return(zone_copy); +} + int RGBController::GetZoneActiveMode(unsigned int zone) { int active_mode; @@ -1797,7 +1812,7 @@ void RGBController::ClearSegments(int zone) zones[zone].segments.clear(); AccessMutex.unlock(); - zones[zone].flags |= ZONE_FLAG_MANUALLY_CONFIGURED; + zones[zone].flags &= ~ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS; SignalUpdate(RGBCONTROLLER_UPDATE_REASON_CLEARSEGMENTS); } @@ -1808,18 +1823,83 @@ void RGBController::AddSegment(int zone, segment new_segment) zones[zone].segments.push_back(new_segment); AccessMutex.unlock(); - zones[zone].flags |= ZONE_FLAG_MANUALLY_CONFIGURED; + zones[zone].flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS; SignalUpdate(RGBCONTROLLER_UPDATE_REASON_ADDSEGMENT); } -void RGBController::ResizeZone(int zone, int new_size) +void RGBController::ConfigureZone(int zone_idx, zone new_zone) { AccessMutex.lock(); - DeviceResizeZone(zone, new_size); + + if(new_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE) + { + zones[zone_idx].flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SIZE; + zones[zone_idx].leds_count = new_zone.leds_count; + } + else + { + zones[zone_idx].flags &= ~ZONE_FLAG_MANUALLY_CONFIGURED_SIZE; + new_zone.leds_count = 0; + } + + if(new_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME) + { + zones[zone_idx].flags |= ZONE_FLAG_MANUALLY_CONFIGURED_NAME; + zones[zone_idx].name = new_zone.name; + } + else + { + zones[zone_idx].flags &= ~ZONE_FLAG_MANUALLY_CONFIGURED_NAME; + } + + if(new_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE) + { + zones[zone_idx].flags |= ZONE_FLAG_MANUALLY_CONFIGURED_TYPE; + zones[zone_idx].type = new_zone.type; + } + else + { + zones[zone_idx].flags &= ~ZONE_FLAG_MANUALLY_CONFIGURED_TYPE; + } + + if(new_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP) + { + zones[zone_idx].flags |= ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP; + zones[zone_idx].matrix_map = new_zone.matrix_map; + } + else + { + zones[zone_idx].flags &= ~ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP; + } + + if(new_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_COLOR_ORDER) + { + zones[zone_idx].flags |= ZONE_FLAG_MANUALLY_CONFIGURED_COLOR_ORDER; + zones[zone_idx].color_order = new_zone.color_order; + } + else + { + zones[zone_idx].flags &= ~ZONE_FLAG_MANUALLY_CONFIGURED_COLOR_ORDER; + } + + DeviceConfigureZone(zone_idx); + AccessMutex.unlock(); - zones[zone].flags |= ZONE_FLAG_MANUALLY_CONFIGURED; + SignalUpdate(RGBCONTROLLER_UPDATE_REASON_RESIZEZONE); +} + +void RGBController::ResizeZone(int zone_idx, int new_size) +{ + zone new_zone = zones[zone_idx]; + + new_zone.leds_count = new_size; + new_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SIZE; + + AccessMutex.lock(); + ConfigureZone(zone_idx, new_zone); + AccessMutex.unlock(); SignalUpdate(RGBCONTROLLER_UPDATE_REASON_RESIZEZONE); } @@ -1833,7 +1913,7 @@ unsigned int RGBController::LEDsInZone(unsigned int zone) leds_count = zones[zone].leds_count; - if(zones[zone].flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY) + if(zones[zone].flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY) { if(leds_count > 1) { @@ -1905,7 +1985,7 @@ void RGBController::UpdateLEDsInternal() /*---------------------------------------------------------*\ | Functions to be implemented in device implementation | \*---------------------------------------------------------*/ -void RGBController::DeviceResizeZone(int /*zone*/, int /*new_size*/) +void RGBController::DeviceConfigureZone(int /*zone_idx*/) { /*-----------------------------------------------------*\ | If not implemented by controller, does nothing | @@ -2535,7 +2615,7 @@ unsigned char * RGBController::GetSegmentDescriptionData(unsigned char* data_ptr data_ptr += sizeof(segment.leds_count); /*-----------------------------------------------------*\ - | Segment matrix map data | + | Segment matrix map data and segment flags | \*-----------------------------------------------------*/ if(protocol_version >= 6) { @@ -2545,6 +2625,9 @@ unsigned char * RGBController::GetSegmentDescriptionData(unsigned char* data_ptr data_ptr += sizeof(matrix_map_size); data_ptr = GetMatrixMapDescriptionData(data_ptr, segment.matrix_map, protocol_version); + + memcpy(data_ptr, &segment.flags, sizeof(segment.flags)); + data_ptr += sizeof(segment.flags); } return(data_ptr); @@ -2568,12 +2651,13 @@ unsigned int RGBController::GetSegmentDescriptionSize(segment segment, unsigned data_size += sizeof(segment.leds_count); /*-----------------------------------------------------*\ - | Matrix map size | + | Matrix map size and segment flags size | \*-----------------------------------------------------*/ if(protocol_version >= 6) { data_size += sizeof(unsigned short); data_size += GetMatrixMapDescriptionSize(segment.matrix_map, protocol_version); + data_size += sizeof(segment.flags); } return(data_size); @@ -2607,7 +2691,7 @@ unsigned char * RGBController::GetZoneDescriptionData(unsigned char* data_ptr, z | overwrite the leds_min/max/count parameters to 1 so | | that the zone appears a fixed size to older clients. | \*-----------------------------------------------------*/ - if((zone.flags & ZONE_FLAG_RESIZE_EFFECTS_ONLY) && (protocol_version < 5)) + if((zone.flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY) && (protocol_version < 5)) { /*-------------------------------------------------*\ | Create a temporary variable to hold the fixed | @@ -2718,6 +2802,12 @@ unsigned char * RGBController::GetZoneDescriptionData(unsigned char* data_ptr, z { data_ptr = GetModeDescriptionData(data_ptr, zone.modes[mode_index], protocol_version); } + + /*-------------------------------------------------*\ + | Copy in color order | + \*-------------------------------------------------*/ + memcpy(data_ptr, &zone.color_order, sizeof(zone.color_order)); + data_ptr += sizeof(zone.color_order); } return(data_ptr); @@ -2782,6 +2872,8 @@ unsigned int RGBController::GetZoneDescriptionSize(zone zone, unsigned int proto { data_size += GetModeDescriptionSize(zone.modes[mode_index], protocol_version); } + + data_size += sizeof(zone.color_order); } return(data_size); @@ -3200,6 +3292,12 @@ unsigned char* RGBController::SetSegmentDescription(unsigned char* data_ptr, seg { data_ptr = SetMatrixMapDescription(data_ptr, &segment->matrix_map, protocol_version); } + + /*-------------------------------------------------*\ + | Copy in segment flags | + \*-------------------------------------------------*/ + memcpy(&segment->flags, data_ptr, sizeof(segment->flags)); + data_ptr += sizeof(segment->flags); } return(data_ptr); @@ -3497,6 +3595,7 @@ nlohmann::json RGBController::GetSegmentDescriptionJSON(segment segment) segment_json["start_idx"] = segment.start_idx; segment_json["leds_count"] = segment.leds_count; segment_json["matrix_map"] = GetMatrixMapDescriptionJSON(segment.matrix_map); + segment_json["flags"] = segment.flags; return(segment_json); } @@ -3532,6 +3631,8 @@ nlohmann::json RGBController::GetZoneDescriptionJSON(zone zone) zone_json["active_mode"] = zone.active_mode; } + zone_json["color_order"] = zone.color_order; + return(zone_json); } @@ -3831,6 +3932,11 @@ segment RGBController::SetSegmentDescriptionJSON(nlohmann::json segment_json) new_segment.matrix_map = SetMatrixMapDescriptionJSON(segment_json["matrix_map"]); } + if(segment_json.contains("flags")) + { + new_segment.flags = segment_json["flags"]; + } + return(new_segment); } @@ -3901,6 +4007,11 @@ zone RGBController::SetZoneDescriptionJSON(nlohmann::json zone_json) new_zone.active_mode = zone_json["active_mode"]; } + if(zone_json.contains("color_order")) + { + new_zone.color_order = zone_json["color_order"]; + } + return(new_zone); } diff --git a/RGBController/RGBController.h b/RGBController/RGBController.h index 09de0949e..d627ed2e5 100644 --- a/RGBController/RGBController.h +++ b/RGBController/RGBController.h @@ -128,17 +128,52 @@ typedef struct /*---------------------------------------------------------*\ | Zone Flags | \*---------------------------------------------------------*/ +typedef unsigned int zone_flags; + +#define ZONE_FLAGS_MANUALLY_CONFIGURABLE (ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY | \ + ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE | \ + ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME | \ + ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE | \ + ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP | \ + ZONE_FLAG_MANUALLY_CONFIGURABLE_SEGMENTS | \ + ZONE_FLAG_MANUALLY_CONFIGURABLE_COLOR_ORDER) + +#define ZONE_FLAGS_MANUALLY_CONFIGURED (ZONE_FLAG_MANUALLY_CONFIGURED_SIZE | \ + ZONE_FLAG_MANUALLY_CONFIGURED_NAME | \ + ZONE_FLAG_MANUALLY_CONFIGURED_TYPE | \ + ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP | \ + ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS | \ + ZONE_FLAG_MANUALLY_CONFIGURED_COLOR_ORDER) enum { - ZONE_FLAG_RESIZE_EFFECTS_ONLY = (1 << 0), /* Zone is resizable, but only for */ - /* effects - treat as single LED */ - ZONE_FLAG_MANUALLY_CONFIGURED = (1 << 15),/* Zone has been manually configured*/ + ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY = (1 << 0), /* Zone size is manually configurable, but only */ + /* for hardware effects, treated as single LED */ + /* for per-LED modes */ + ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE = (1 << 1), /* Zone size is manually configurable */ + ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME = (1 << 2), /* Zone name is manually configurable */ + ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE = (1 << 3), /* Zone type is manually configurable */ + ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP = (1 << 4), /* Zone matrix map is manually configurable */ + ZONE_FLAG_MANUALLY_CONFIGURABLE_SEGMENTS = (1 << 5), /* Zone segments are manually configurable */ + ZONE_FLAG_MANUALLY_CONFIGURABLE_COLOR_ORDER = (1 << 6), /* Zone color order is manually configurable */ + ZONE_FLAG_MANUALLY_CONFIGURED_SIZE = (1 << 12),/* Zone size has been manually configured */ + ZONE_FLAG_MANUALLY_CONFIGURED_NAME = (1 << 13),/* Zone name has been manually configured */ + ZONE_FLAG_MANUALLY_CONFIGURED_TYPE = (1 << 14),/* Zone type has been manually configured */ + ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP = (1 << 15),/* Zone matrix map has been manually configured */ + ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS = (1 << 16),/* Zone segments have been manually configured */ + ZONE_FLAG_MANUALLY_CONFIGURED_COLOR_ORDER = (1 << 17),/* Zone color order has been manually configured*/ + ZONE_FLAG_SUPPORTS_COLOR_ORDER_DEFAULT = (1 << 24),/* Zone supports default color order */ + ZONE_FLAG_SUPPORTS_COLOR_ORDER_RGB = (1 << 25),/* Zone supports RGB color order */ + ZONE_FLAG_SUPPORTS_COLOR_ORDER_RBG = (1 << 26),/* Zone supports RBG color order */ + ZONE_FLAG_SUPPORTS_COLOR_ORDER_GRB = (1 << 27),/* Zone supports GRB color order */ + ZONE_FLAG_SUPPORTS_COLOR_ORDER_GBR = (1 << 28),/* Zone supports GBR color order */ + ZONE_FLAG_SUPPORTS_COLOR_ORDER_BRG = (1 << 29),/* Zone supports BRG color order */ + ZONE_FLAG_SUPPORTS_COLOR_ORDER_BGR = (1 << 30),/* Zone supports BGR color order */ }; /*---------------------------------------------------------*\ | Zone Types | \*---------------------------------------------------------*/ -typedef int zone_type; +typedef unsigned int zone_type; enum { @@ -151,6 +186,22 @@ enum ZONE_TYPE_SEGMENTED }; +/*---------------------------------------------------------*\ +| Zone Color Order | +\*---------------------------------------------------------*/ +typedef unsigned int zone_color_order; + +enum +{ + ZONE_COLOR_ORDER_DEFAULT, /* Device default color order */ + ZONE_COLOR_ORDER_RGB, /* RGB color order */ + ZONE_COLOR_ORDER_RBG, /* RBG color order */ + ZONE_COLOR_ORDER_GRB, /* GRB color order */ + ZONE_COLOR_ORDER_GBR, /* GBR color order */ + ZONE_COLOR_ORDER_BRG, /* BRG color order */ + ZONE_COLOR_ORDER_BGR /* BGR color order */ +}; + /*---------------------------------------------------------*\ | Matrix Map Struct | \*---------------------------------------------------------*/ @@ -169,6 +220,15 @@ public: void Set(unsigned int height, unsigned int width, unsigned int * map); }; +/*---------------------------------------------------------*\ +| Segment Flags | +\*---------------------------------------------------------*/ +enum +{ + SEGMENT_FLAG_GROUP_START = (1 << 0), /* Start of segment group */ + SEGMENT_FLAG_GROUP_MEMBER = (1 << 1), /* Segment is in group */ +}; + /*---------------------------------------------------------*\ | Segment Class | \*---------------------------------------------------------*/ @@ -180,6 +240,7 @@ public: unsigned int start_idx; /* Start index within zone */ unsigned int leds_count; /* Number of LEDs in segment*/ matrix_map_type matrix_map; /* Matrix map */ + unsigned int flags; /* Segment flags */ /*-----------------------------------------------------*\ | Zone Constructor / Destructor | @@ -203,10 +264,11 @@ public: unsigned int leds_min; /* Minimum number of LEDs */ unsigned int leds_max; /* Maximum number of LEDs */ matrix_map_type matrix_map; /* Matrix map */ - std::vector segments; /* Segments in zone */ - unsigned int flags; /* Zone flags bitfield */ + std::vector segments; /* Segments in zone */ + zone_flags flags; /* Zone flags bitfield */ std::vector modes; /* Zone-specific modes */ int active_mode; /* Active zone-specific mode*/ + zone_color_order color_order; /* Zone color order */ /*-----------------------------------------------------*\ | Zone Constructor / Destructor | @@ -311,6 +373,7 @@ public: /*-----------------------------------------------------*\ | Zone Functions | \*-----------------------------------------------------*/ + virtual zone GetZone(unsigned int zone_idx) = 0; virtual int GetZoneActiveMode(unsigned int zone) = 0; virtual RGBColor GetZoneColor(unsigned int zone, unsigned int color_index) = 0; virtual RGBColor* GetZoneColorsPointer(unsigned int zone) = 0; @@ -437,6 +500,7 @@ public: virtual void ClearSegments(int zone) = 0; virtual void AddSegment(int zone, segment new_segment) = 0; + virtual void ConfigureZone(int zone_idx, zone new_zone) = 0; virtual void ResizeZone(int zone, int new_size) = 0; }; @@ -471,6 +535,7 @@ public: /*-----------------------------------------------------*\ | Zone Functions | \*-----------------------------------------------------*/ + zone GetZone(unsigned int zone_idx); int GetZoneActiveMode(unsigned int zone); RGBColor GetZoneColor(unsigned int zone, unsigned int color_index); RGBColor* GetZoneColorsPointer(unsigned int zone); @@ -600,12 +665,13 @@ public: void ClearSegments(int zone); void AddSegment(int zone, segment new_segment); + void ConfigureZone(int zone_idx, zone new_zone); void ResizeZone(int zone, int new_size); /*-----------------------------------------------------*\ | Functions to be implemented in device implementation | \*-----------------------------------------------------*/ - virtual void DeviceResizeZone(int zone, int new_size); + virtual void DeviceConfigureZone(int zone_idx); virtual void DeviceUpdateLEDs(); virtual void DeviceUpdateZoneLEDs(int zone); diff --git a/RGBController/RGBController_Network.cpp b/RGBController/RGBController_Network.cpp index ff753b5aa..31fd8e05a 100644 --- a/RGBController/RGBController_Network.cpp +++ b/RGBController/RGBController_Network.cpp @@ -93,6 +93,92 @@ void RGBController_Network::AddSegment(int zone, segment new_segment) client->WaitOnControllerData(); } +void RGBController_Network::ConfigureZone(int zone_idx, zone new_zone) +{ + /*-----------------------------------------------------*\ + | ConfigureZone was introduced in protocol version 6 | + | For previous protocols, call ResizeZone and | + | ClearSegments/AddSegments. | + \*-----------------------------------------------------*/ + if(client->GetProtocolVersion() < 6) + { + /*-------------------------------------------------*\ + | Resize zone if size is manually configured | + \*-------------------------------------------------*/ + if(new_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE) + { + ResizeZone(zone_idx, new_zone.leds_count); + } + + /*-------------------------------------------------*\ + | Update segments if segments manually configured | + \*-------------------------------------------------*/ + if(new_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS) + { + ClearSegments(zone_idx); + + for(std::size_t segment_idx = 0; segment_idx < new_zone.segments.size(); segment_idx++) + { + AddSegment(zone_idx, new_zone.segments[segment_idx]); + } + } + + return; + } + + /*-----------------------------------------------------*\ + | Lock access mutex | + \*-----------------------------------------------------*/ + AccessMutex.lock_shared(); + + /*-----------------------------------------------------*\ + | Initialize variables | + \*-----------------------------------------------------*/ + unsigned int data_size = 0; + + /*-----------------------------------------------------*\ + | Calculate data size | + \*-----------------------------------------------------*/ + data_size += sizeof(data_size); + data_size += sizeof(zone); + data_size += GetZoneDescriptionSize(new_zone, client->GetProtocolVersion()); + + /*-----------------------------------------------------*\ + | Create data buffer | + \*-----------------------------------------------------*/ + unsigned char * data_buf = new unsigned char[data_size]; + unsigned char * data_ptr = data_buf; + + /*-----------------------------------------------------*\ + | Copy in data size | + \*-----------------------------------------------------*/ + memcpy(data_ptr, &data_size, sizeof(data_size)); + data_ptr += sizeof(data_size); + + /*-----------------------------------------------------*\ + | Copy in zone index | + \*-----------------------------------------------------*/ + memcpy(data_ptr, &zone_idx, sizeof(zone_idx)); + data_ptr += sizeof(zone_idx); + + /*-----------------------------------------------------*\ + | Copy in segment description | + \*-----------------------------------------------------*/ + data_ptr = GetZoneDescriptionData(data_ptr, new_zone, client->GetProtocolVersion()); + + /*-----------------------------------------------------*\ + | Unlock access mutex | + \*-----------------------------------------------------*/ + AccessMutex.unlock_shared(); + + client->SendRequest_RGBController_ConfigureZone(dev_id, data_buf, data_size); + + delete[] data_buf; + + client->SendRequest_ControllerData(dev_id); + client->WaitOnControllerData(); +} + void RGBController_Network::ResizeZone(int zone, int new_size) { client->SendRequest_RGBController_ResizeZone(dev_id, zone, new_size); diff --git a/RGBController/RGBController_Network.h b/RGBController/RGBController_Network.h index a66505485..7d8acff9e 100644 --- a/RGBController/RGBController_Network.h +++ b/RGBController/RGBController_Network.h @@ -25,6 +25,8 @@ public: void ClearSegments(int zone); void AddSegment(int zone, segment new_segment); + + void ConfigureZone(int zone_idx, zone new_zone); void ResizeZone(int zone, int new_size); void DeviceUpdateLEDs(); diff --git a/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.cpp b/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.cpp index 09e155565..97e9403be 100644 --- a/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.cpp +++ b/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.cpp @@ -15,28 +15,6 @@ E131SettingsEntry::E131SettingsEntry(QWidget *parent) : ui(new Ui::E131SettingsEntry) { ui->setupUi(this); - - ui->TypeComboBox->addItem(tr("Single")); - ui->TypeComboBox->addItem(tr("Linear")); - ui->TypeComboBox->addItem(tr("Matrix")); - - ui->MatrixOrderComboBox->addItem(tr("Horizontal Top Left")); - ui->MatrixOrderComboBox->addItem(tr("Horizontal Top Right")); - ui->MatrixOrderComboBox->addItem(tr("Horizontal Bottom Left")); - ui->MatrixOrderComboBox->addItem(tr("Horizontal Bottom Right")); - ui->MatrixOrderComboBox->addItem(tr("Vertical Top Left")); - ui->MatrixOrderComboBox->addItem(tr("Vertical Top Right")); - ui->MatrixOrderComboBox->addItem(tr("Vertical Bottom Left")); - ui->MatrixOrderComboBox->addItem(tr("Vertical Bottom Right")); - - ui->RGBOrderComboBox->addItem("RGB"); - ui->RGBOrderComboBox->addItem("RBG"); - ui->RGBOrderComboBox->addItem("GRB"); - ui->RGBOrderComboBox->addItem("GBR"); - ui->RGBOrderComboBox->addItem("BRG"); - ui->RGBOrderComboBox->addItem("BGR"); - - HideMatrixSettings(); } E131SettingsEntry::~E131SettingsEntry() @@ -52,42 +30,6 @@ void E131SettingsEntry::changeEvent(QEvent *event) } } -void E131SettingsEntry::HideMatrixSettings() -{ - ui->MatrixWidthLabel->setDisabled(true); - ui->MatrixWidthEdit->setDisabled(true); - - ui->MatrixHeightLabel->setDisabled(true); - ui->MatrixHeightEdit->setDisabled(true); - - ui->MatrixOrderLabel->setDisabled(true); - ui->MatrixOrderComboBox->setDisabled(true); -} - -void E131SettingsEntry::ShowMatrixSettings() -{ - ui->MatrixWidthLabel->setDisabled(false); - ui->MatrixWidthEdit->setDisabled(false); - - ui->MatrixHeightLabel->setDisabled(false); - ui->MatrixHeightEdit->setDisabled(false); - - ui->MatrixOrderLabel->setDisabled(false); - ui->MatrixOrderComboBox->setDisabled(false); -} - -void E131SettingsEntry::on_TypeComboBox_currentIndexChanged(int index) -{ - if(index == 2) - { - ShowMatrixSettings(); - } - else - { - HideMatrixSettings(); - } -} - void E131SettingsEntry::loadFromSettings(const json& data) { if(data.contains("name")) @@ -115,123 +57,6 @@ void E131SettingsEntry::loadFromSettings(const json& data) ui->NumLEDsEdit->setText(QString::number((int)data["num_leds"])); } - if(data.contains("type")) - { - if(data["type"].is_string()) - { - std::string type_val = data["type"]; - - if(type_val == "SINGLE") - { - ui->TypeComboBox->setCurrentIndex(0); - } - else if(type_val == "LINEAR") - { - ui->TypeComboBox->setCurrentIndex(1); - } - else if(type_val == "MATRIX") - { - ui->TypeComboBox->setCurrentIndex(2); - } - } - else - { - ui->TypeComboBox->setCurrentIndex(data["type"]); - } - } - - if(data.contains("rgb_order")) - { - if(data["rgb_order"].is_string()) - { - std::string rgb_order_val = data["rgb_order"]; - - if(rgb_order_val == "RGB") - { - ui->RGBOrderComboBox->setCurrentIndex(0); - } - else if(rgb_order_val == "RBG") - { - ui->RGBOrderComboBox->setCurrentIndex(1); - } - else if(rgb_order_val == "GRB") - { - ui->RGBOrderComboBox->setCurrentIndex(2); - } - else if(rgb_order_val == "GBR") - { - ui->RGBOrderComboBox->setCurrentIndex(3); - } - else if(rgb_order_val == "BRG") - { - ui->RGBOrderComboBox->setCurrentIndex(4); - } - else if(rgb_order_val == "BGR") - { - ui->RGBOrderComboBox->setCurrentIndex(5); - } - } - else - { - ui->RGBOrderComboBox->setCurrentIndex(data["rgb_order"]); - } - } - - if(data.contains("matrix_width")) - { - ui->MatrixWidthEdit->setText(QString::number((int)data["matrix_width"])); - } - - if(data.contains("matrix_height")) - { - ui->MatrixHeightEdit->setText(QString::number((int)data["matrix_height"])); - } - - if(data.contains("matrix_order")) - { - if(data["matrix_order"].is_string()) - { - std::string matrix_order_val = data["matrix_order"]; - - if(matrix_order_val == "HORIZONTAL_TOP_LEFT") - { - ui->MatrixOrderComboBox->setCurrentIndex(0); - } - else if(matrix_order_val == "HORIZONTAL_TOP_RIGHT") - { - ui->MatrixOrderComboBox->setCurrentIndex(1); - } - else if(matrix_order_val == "HORIZONTAL_BOTTOM_LEFT") - { - ui->MatrixOrderComboBox->setCurrentIndex(2); - } - else if(matrix_order_val == "HORIZONTAL_BOTTOM_RIGHT") - { - ui->MatrixOrderComboBox->setCurrentIndex(3); - } - else if(matrix_order_val == "VERTICAL_TOP_LEFT") - { - ui->MatrixOrderComboBox->setCurrentIndex(4); - } - else if(matrix_order_val == "VERTICAL_TOP_RIGHT") - { - ui->MatrixOrderComboBox->setCurrentIndex(5); - } - else if(matrix_order_val == "VERTICAL_BOTTOM_LEFT") - { - ui->MatrixOrderComboBox->setCurrentIndex(6); - } - else if(matrix_order_val == "VERTICAL_BOTTOM_RIGHT") - { - ui->MatrixOrderComboBox->setCurrentIndex(7); - } - } - else - { - ui->MatrixOrderComboBox->setCurrentIndex(data["matrix_order"]); - } - } - if(data.contains("universe_size")) { ui->UniverseSizeEdit->setText(QString::number((int)data["universe_size"])); @@ -253,8 +78,6 @@ json E131SettingsEntry::saveSettings() result["start_universe"] = ui->StartUniverseEdit->text().toUInt(); result["start_channel"] = ui->StartChannelEdit->text().toUInt(); result["num_leds"] = ui->NumLEDsEdit->text().toUInt(); - result["type"] = ui->TypeComboBox->currentIndex(); - result["rgb_order"] = ui->RGBOrderComboBox->currentIndex(); /*-------------------------------------------------*\ | Optional parameters | @@ -264,13 +87,6 @@ json E131SettingsEntry::saveSettings() result["ip"] = ui->IPEdit->text().toStdString(); } - if(result["type"] == 2) - { - result["matrix_width"] = ui->MatrixWidthEdit->text().toUInt(); - result["matrix_height"] = ui->MatrixHeightEdit->text().toUInt(); - result["matrix_order"] = ui->MatrixOrderComboBox->currentIndex(); - } - if(ui->UniverseSizeEdit->text() != "") { result["universe_size"] = ui->UniverseSizeEdit->text().toUInt(); @@ -297,6 +113,6 @@ static BaseManualDeviceEntry* SpawnE131Entry(const json& data) return entry; } -static const char* E131DeviceName = QT_TRANSLATE_NOOP("ManualDevice", "E1.31 (including WLED)"); +static const char* E131DeviceName = QT_TRANSLATE_NOOP("ManualDevice", "E1.31"); REGISTER_MANUAL_DEVICE_TYPE(E131DeviceName, "E131Devices", SpawnE131Entry); diff --git a/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.h b/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.h index 7ff16d86c..265a3a4f4 100644 --- a/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.h +++ b/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.h @@ -30,11 +30,6 @@ public: private: Ui::E131SettingsEntry *ui; -private: - void HideMatrixSettings(); - void ShowMatrixSettings(); - private slots: void changeEvent(QEvent *event) override; - void on_TypeComboBox_currentIndexChanged(int index); }; diff --git a/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.ui b/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.ui index 9932b9229..0c88b7144 100644 --- a/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.ui +++ b/qt/ManualDevicesSettingsPage/E131SettingsEntry/E131SettingsEntry.ui @@ -7,7 +7,7 @@ 0 0 531 - 256 + 185 @@ -26,14 +26,28 @@ E1.31 Device - - + + + + Keepalive Time: + + - - + + + + Name: + + - + + + + + + + @@ -42,6 +56,23 @@ + + + + + + + IP (Unicast): + + + + + + + Universe Size: + + + @@ -49,14 +80,11 @@ - - + + - - - - - + + @@ -65,86 +93,8 @@ - - - - - - - Name: - - - - - - - Matrix Order: - - - - - - - - - - - - - Matrix Height: - - - - - - - Matrix Width: - - - - - - - Type: - - - - - - - IP (Unicast): - - - - - - - Universe Size: - - - - - - - - - - Keepalive Time: - - - - - - - - - - RGB Order: - - - - - + + @@ -157,10 +107,6 @@ StartUniverseEdit StartChannelEdit NumLEDsEdit - TypeComboBox - MatrixWidthEdit - MatrixHeightEdit - MatrixOrderComboBox UniverseSizeEdit KeepaliveTimeEdit diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp index 58fc36ec7..0385c3608 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp @@ -570,17 +570,14 @@ void OpenRGBDevicePage::UpdateLEDList() | Enable editing if: | | Zone has variable size | | OR | - | Zone is LINEAR and device type is | - | LEDSTRIP | + | Zone has any MANUALLY_CONFIGURABLE flag | \*-----------------------------------------*/ bool zone_is_editable = false; - if(device->GetZoneLEDsMin(selected_zone) != device->GetZoneLEDsMax(selected_zone)) - { - zone_is_editable = true; - } + zone_flags flags = device->GetZoneFlags(selected_zone); - if((device->GetZoneType(selected_zone) == ZONE_TYPE_LINEAR) && (device->GetDeviceType() == DEVICE_TYPE_LEDSTRIP)) + if((device->GetZoneLEDsMin(selected_zone) != device->GetZoneLEDsMax(selected_zone)) + || ((flags & ZONE_FLAGS_MANUALLY_CONFIGURABLE) > 0)) { zone_is_editable = true; } @@ -1916,11 +1913,6 @@ void OpenRGBDevicePage::GetSelectedZone(bool * selected_all_zones, int * selecte break; } } - - if((*selected_segment == -1) && (device->GetZoneCount() <= 1)) - { - *selected_all_zones = true; - } } } @@ -2161,35 +2153,17 @@ void OpenRGBDevicePage::on_EditZoneButton_clicked() return; } + OpenRGBZoneEditorDialog dlg(device, selected_zone); + + dlg.show(); + /*-----------------------------------------*\ - | Only allow resizing linear zones or | - | effects-only resizable zones | + | Update Zone list and then reset the | + | current index | \*-----------------------------------------*/ - if((device->GetZoneType(selected_zone) == ZONE_TYPE_LINEAR) || (device->GetZoneFlags(selected_zone) & ZONE_FLAG_RESIZE_EFFECTS_ONLY)) - { - OpenRGBZoneEditorDialog dlg(device, selected_zone); - - int new_size = dlg.show(); - - if(new_size >= 0) - { - /*---------------------------------*\ - | Update Zone box | - \*---------------------------------*/ - on_ZoneBox_currentIndexChanged(selected_zone); - - /*---------------------------------*\ - | Update color picker with color of | - | first LED | - \*---------------------------------*/ - on_LEDBox_currentIndexChanged(0); - - /*---------------------------------*\ - | Save the size profile | - \*---------------------------------*/ - SaveSizeProfile(); - } - } + selected_zone = ui->ZoneBox->currentIndex(); + UpdateZoneList(); + ui->ZoneBox->setCurrentIndex(selected_zone); } break; } diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.h b/qt/OpenRGBDevicePage/OpenRGBDevicePage.h index 770d1937a..fcf14ecf2 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.h +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.h @@ -128,5 +128,4 @@ private slots: signals: void RefreshList(); void SetAllDevices(unsigned char red, unsigned char green, unsigned char blue); - void SaveSizeProfile(); }; diff --git a/qt/OpenRGBDialog/OpenRGBDialog.cpp b/qt/OpenRGBDialog/OpenRGBDialog.cpp index 170cc73c2..7e9907d57 100644 --- a/qt/OpenRGBDialog/OpenRGBDialog.cpp +++ b/qt/OpenRGBDialog/OpenRGBDialog.cpp @@ -1030,15 +1030,6 @@ void OpenRGBDialog::UpdateDevicesList() this, SLOT(on_SetAllDevices(unsigned char, unsigned char, unsigned char))); - /*---------------------------------------------*\ - | Connect the page's Resize signal to the Save | - | Size slot | - \*---------------------------------------------*/ - connect(NewPage, - SIGNAL(SaveSizeProfile()), - this, - SLOT(on_SaveSizeProfile())); - /*---------------------------------------------*\ | Connect the page's Refresh List signal to the | | Refresh List slot | @@ -1396,19 +1387,6 @@ void OpenRGBDialog::on_SetAllDevices(unsigned char red, unsigned char green, uns } } -void OpenRGBDialog::on_SaveSizeProfile() -{ - ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); - - if(profile_manager != NULL) - { - /*-------------------------------------------------*\ - | Save the profile | - \*-------------------------------------------------*/ - profile_manager->SaveSizes(); - } -} - void OpenRGBDialog::on_ShowHide() { if(isHidden()) diff --git a/qt/OpenRGBDialog/OpenRGBDialog.h b/qt/OpenRGBDialog/OpenRGBDialog.h index 2d6b2ae07..2e6cfe876 100644 --- a/qt/OpenRGBDialog/OpenRGBDialog.h +++ b/qt/OpenRGBDialog/OpenRGBDialog.h @@ -31,7 +31,6 @@ #include "i2c_smbus.h" #include "LogManager.h" #include "RGBController.h" -#include "ProfileManager.h" #include "NetworkClient.h" #include "NetworkServer.h" @@ -158,7 +157,6 @@ private slots: void onDetectionStarted(); void onDetectionEnded(); void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue); - void on_SaveSizeProfile(); void on_ShowHide(); void onShowDialogMessage(); void on_ReShow(QSystemTrayIcon::ActivationReason reason); diff --git a/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.cpp b/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.cpp index bc115181d..daee4b44a 100644 --- a/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.cpp +++ b/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.cpp @@ -15,6 +15,8 @@ #include "OpenRGBMatrixMapEditorDialog.h" #include "OpenRGBSegmentExportDialog.h" #include "OpenRGBZoneEditorDialog.h" +#include "ProfileManager.h" +#include "ResourceManager.h" #include "ui_OpenRGBZoneEditorDialog.h" OpenRGBZoneEditorDialog::OpenRGBZoneEditorDialog(RGBController* edit_dev_ptr, unsigned int edit_zone_idx_val, QWidget *parent) : @@ -27,8 +29,9 @@ OpenRGBZoneEditorDialog::OpenRGBZoneEditorDialog(RGBController* edit_dev_ptr, un /*-----------------------------------------------------*\ | Save device and zone | \*-----------------------------------------------------*/ - edit_dev = edit_dev_ptr; - edit_zone_idx = edit_zone_idx_val; + edit_dev = edit_dev_ptr; + edit_zone_idx = edit_zone_idx_val; + edit_zone = edit_dev->GetZone(edit_zone_idx); /*-----------------------------------------------------*\ | Append zone name to window title | @@ -40,11 +43,117 @@ OpenRGBZoneEditorDialog::OpenRGBZoneEditorDialog(RGBController* edit_dev_ptr, un setWindowTitle(newTitle); /*-----------------------------------------------------*\ - | Set up zone size range | + | Read the zone flags | \*-----------------------------------------------------*/ - unsigned int size_min = edit_dev->GetZoneLEDsMin(edit_zone_idx); - unsigned int size_max = edit_dev->GetZoneLEDsMax(edit_zone_idx); - unsigned int size_current = edit_dev->GetZoneLEDsCount(edit_zone_idx); + if(edit_zone.leds_min != edit_zone.leds_max) + { + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY) == 0) + { + edit_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE | ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP | ZONE_FLAG_MANUALLY_CONFIGURABLE_SEGMENTS; + } + + edit_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE; + } + + /*-----------------------------------------------------*\ + | Initialize zone name | + \*-----------------------------------------------------*/ + ui->LineEditZoneName->blockSignals(true); + ui->LineEditZoneName->setText(QString::fromStdString(edit_zone.name)); + ui->LineEditZoneName->blockSignals(false); + + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME) == 0) + { + ui->LineEditZoneName->setEnabled(false); + } + else if(edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME) + { + ui->LabelZoneName->setText("Zone Name (*):"); + } + + /*-----------------------------------------------------*\ + | Initialize zone size | + \*-----------------------------------------------------*/ + ui->SliderZoneSize->blockSignals(true); + ui->SliderZoneSize->setRange(edit_zone.leds_min, edit_zone.leds_max); + ui->SliderZoneSize->setValue(edit_zone.leds_count); + ui->SliderZoneSize->blockSignals(false); + + ui->SpinBoxZoneSize->blockSignals(true); + ui->SpinBoxZoneSize->setRange(edit_zone.leds_min, edit_zone.leds_max); + ui->SpinBoxZoneSize->setValue(edit_zone.leds_count); + ui->SpinBoxZoneSize->blockSignals(false); + + if((edit_zone.flags & (ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE | ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY)) == 0) + { + ui->SliderZoneSize->setEnabled(false); + ui->SpinBoxZoneSize->setEnabled(false); + } + else if(edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE) + { + ui->LabelZoneSize->setText("Zone Size (*):"); + } + + /*-----------------------------------------------------*\ + | Initialize zone type | + \*-----------------------------------------------------*/ + ui->ComboBoxZoneType->blockSignals(true); + ui->ComboBoxZoneType->addItem("Single"); + ui->ComboBoxZoneType->addItem("Linear"); + ui->ComboBoxZoneType->addItem("Matrix"); + ui->ComboBoxZoneType->addItem("Linear Loop"); + ui->ComboBoxZoneType->addItem("Matrix Loop X"); + ui->ComboBoxZoneType->addItem("Matrix Loop Y"); + ui->ComboBoxZoneType->addItem("Segmented"); + + ui->ComboBoxZoneType->setCurrentIndex(edit_dev->GetZoneType(edit_zone_idx)); + ui->ComboBoxZoneType->blockSignals(false); + + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE) == 0) + { + ui->ComboBoxZoneType->setEnabled(false); + } + else if(edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE) + { + ui->LabelZoneType->setText("Zone Type (*):"); + } + + /*-----------------------------------------------------*\ + | Initialize zone matrix map | + \*-----------------------------------------------------*/ + ui->ButtonZoneMatrixMap->setText(QString::number(edit_zone.matrix_map.height) + "x" + QString::number(edit_zone.matrix_map.width)); + + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP) == 0) + { + ui->ButtonZoneMatrixMap->setEnabled(false); + } + else if(edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP) + { + ui->LabelZoneMatrixMap->setText("Zone Matrix Map (*):"); + } + + /*-----------------------------------------------------*\ + | Initialize zone color order | + \*-----------------------------------------------------*/ + ui->ComboBoxZoneColorOrder->blockSignals(true); + ui->ComboBoxZoneColorOrder->addItem("Default"); + if(edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_DEFAULT) ui->ComboBoxZoneColorOrder->addItem("Default"); + if(edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_RGB) ui->ComboBoxZoneColorOrder->addItem("RGB"); + if(edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_RBG) ui->ComboBoxZoneColorOrder->addItem("RBG"); + if(edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_GRB) ui->ComboBoxZoneColorOrder->addItem("GRB"); + if(edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_GBR) ui->ComboBoxZoneColorOrder->addItem("GBR"); + if(edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_BRG) ui->ComboBoxZoneColorOrder->addItem("BRG"); + if(edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_BGR) ui->ComboBoxZoneColorOrder->addItem("BGR"); + ui->ComboBoxZoneColorOrder->blockSignals(false); + + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_COLOR_ORDER) == 0) + { + ui->ComboBoxZoneColorOrder->setEnabled(false); + } + else if(edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_COLOR_ORDER) + { + ui->LabelZoneColorOrder->setText("Zone Color Order (*):"); + } /*-----------------------------------------------------*\ | Initialize segment list | @@ -53,16 +162,15 @@ OpenRGBZoneEditorDialog::OpenRGBZoneEditorDialog(RGBController* edit_dev_ptr, un header_labels << "Name" << "Type" << "Matrix Map" << "Size" << ""; ui->SegmentsTreeWidget->setHeaderLabels(header_labels); - ui->ResizeSlider->setRange(size_min, size_max); - ui->ResizeBox->setRange(size_min, size_max); - - ui->ResizeSlider->setValue(size_current); - ui->ResizeBox->setValue(size_current); - - for(unsigned int segment_idx = 0; segment_idx < edit_dev->GetZoneSegmentCount(edit_zone_idx); segment_idx++) + for(std::size_t segment_idx = 0; segment_idx < edit_zone.segments.size(); segment_idx++) { - matrix_map_type new_matrix_map = edit_dev->GetZoneSegmentMatrixMap(edit_zone_idx, segment_idx); - AddSegmentRow(QString::fromStdString(edit_dev->GetZoneSegmentName(edit_zone_idx, segment_idx)), edit_dev->GetZoneSegmentLEDsCount(edit_zone_idx, segment_idx), edit_dev->GetZoneSegmentType(edit_zone_idx, segment_idx), new_matrix_map); + AddSegmentRow(QString::fromStdString(edit_zone.segments[segment_idx].name), edit_zone.segments[segment_idx].leds_count, edit_zone.segments[segment_idx].type, edit_zone.segments[segment_idx].matrix_map); + } + + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURABLE_SEGMENTS) == 0) + { + ui->AddSegmentButton->setEnabled(false); + ui->RemoveSegmentButton->setEnabled(false); } } @@ -79,11 +187,11 @@ void OpenRGBZoneEditorDialog::changeEvent(QEvent *event) } } -void OpenRGBZoneEditorDialog::on_ResizeSlider_valueChanged(int value) +void OpenRGBZoneEditorDialog::on_SliderZoneSize_valueChanged(int value) { - ui->ResizeBox->blockSignals(true); - ui->ResizeBox->setValue(value); - ui->ResizeBox->blockSignals(false); + ui->SpinBoxZoneSize->blockSignals(true); + ui->SpinBoxZoneSize->setValue(value); + ui->SpinBoxZoneSize->blockSignals(false); /*-----------------------------------------------------*\ | Set maximum value for all segment sliders to new zone | @@ -94,6 +202,12 @@ void OpenRGBZoneEditorDialog::on_ResizeSlider_valueChanged(int value) ((QSlider*)ui->SegmentsTreeWidget->itemWidget(ui->SegmentsTreeWidget->topLevelItem(item_idx), 4))->setMaximum(value); } + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE) == 0) + { + edit_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SIZE; + ui->LabelZoneSize->setText("Zone Size (*):"); + } + CheckSegmentsValidity(); } @@ -139,11 +253,11 @@ void OpenRGBZoneEditorDialog::on_segment_slider_valueChanged(int) CheckSegmentsValidity(); } -void OpenRGBZoneEditorDialog::on_ResizeBox_valueChanged(int value) +void OpenRGBZoneEditorDialog::on_SpinBoxZoneSize_valueChanged(int value) { - ui->ResizeSlider->blockSignals(true); - ui->ResizeSlider->setValue(value); - ui->ResizeSlider->blockSignals(false); + ui->SliderZoneSize->blockSignals(true); + ui->SliderZoneSize->setValue(value); + ui->SliderZoneSize->blockSignals(false); /*-----------------------------------------------------*\ | Set maximum value for all segment sliders to new zone | @@ -154,45 +268,73 @@ void OpenRGBZoneEditorDialog::on_ResizeBox_valueChanged(int value) ((QSlider*)ui->SegmentsTreeWidget->itemWidget(ui->SegmentsTreeWidget->topLevelItem(item_idx), 4))->setMaximum(value); } + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE) == 0) + { + edit_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SIZE; + ui->LabelZoneSize->setText("Zone Size (*):"); + } + CheckSegmentsValidity(); } int OpenRGBZoneEditorDialog::show() { - int ret_val = 0; + /*-----------------------------------------------------*\ + | Execute this dialog | + \*-----------------------------------------------------*/ + int ret_val = 0; + int result = this->exec(); - int result = this->exec(); - - if(result == QDialog::Rejected) + /*-----------------------------------------------------*\ + | Return -1 if cancelled or edit device is invalid | + \*-----------------------------------------------------*/ + if(result == QDialog::Rejected || edit_dev == NULL) { - ret_val = -1; + ret_val = -1; } else { - ret_val = ui->ResizeBox->value(); - } + /*-------------------------------------------------*\ + | Read the selected color order | + \*-------------------------------------------------*/ + zone_color_order new_color_order = 0; + int new_color_order_index = ui->ComboBoxZoneColorOrder->currentIndex(); - if(ret_val >= 0 && edit_dev != NULL) - { - edit_dev->ResizeZone(edit_zone_idx, ret_val); + if(((int)new_color_order < new_color_order_index) && (edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_DEFAULT)) new_color_order++; + if(((int)new_color_order < new_color_order_index) && (edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_RGB)) new_color_order++; + if(((int)new_color_order < new_color_order_index) && (edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_RBG)) new_color_order++; + if(((int)new_color_order < new_color_order_index) && (edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_GRB)) new_color_order++; + if(((int)new_color_order < new_color_order_index) && (edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_GBR)) new_color_order++; + if(((int)new_color_order < new_color_order_index) && (edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_BRG)) new_color_order++; + if(((int)new_color_order < new_color_order_index) && (edit_zone.flags & ZONE_FLAG_SUPPORTS_COLOR_ORDER_BGR)) new_color_order++; - edit_dev->ClearSegments(edit_zone_idx); + /*-------------------------------------------------*\ + | Update zone with new settings | + \*-------------------------------------------------*/ + edit_zone.name = ui->LineEditZoneName->text().toStdString(); + edit_zone.leds_count = ui->SliderZoneSize->value(); + edit_zone.type = ui->ComboBoxZoneType->currentIndex(); + edit_zone.color_order = ui->ComboBoxZoneColorOrder->currentIndex(); - unsigned int start_idx = 0; + /*-------------------------------------------------*\ + | Configure the zone | + \*-------------------------------------------------*/ + edit_dev->ConfigureZone(edit_zone_idx, edit_zone); - for(int item_idx = 0; item_idx < ui->SegmentsTreeWidget->topLevelItemCount(); item_idx++) + /*-------------------------------------------------*\ + | Save the size profile | + \*-------------------------------------------------*/ + ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); + + if(profile_manager != NULL) { - segment new_segment; - new_segment.type = ((QComboBox*)ui->SegmentsTreeWidget->itemWidget(ui->SegmentsTreeWidget->topLevelItem(item_idx), 1))->currentIndex(); - new_segment.name = ((QLineEdit*)ui->SegmentsTreeWidget->itemWidget(ui->SegmentsTreeWidget->topLevelItem(item_idx), 0))->text().toStdString(); - new_segment.start_idx = start_idx; - new_segment.leds_count = ((QLineEdit*)ui->SegmentsTreeWidget->itemWidget(ui->SegmentsTreeWidget->topLevelItem(item_idx), 3))->text().toInt(); - new_segment.matrix_map = ((SegmentTreeWidgetItem*)(ui->SegmentsTreeWidget->topLevelItem(item_idx)))->matrix_map; - - edit_dev->AddSegment(edit_zone_idx, new_segment); - - start_idx += new_segment.leds_count; + profile_manager->SaveSizes(); } + + /*-------------------------------------------------*\ + | Return new zone size | + \*-------------------------------------------------*/ + ret_val = edit_zone.leds_count; } return(ret_val); @@ -200,19 +342,19 @@ int OpenRGBZoneEditorDialog::show() void OpenRGBZoneEditorDialog::AddSegmentRow(QString name, unsigned int length, zone_type type, matrix_map_type matrix_map) { - /*---------------------------------------------------------*\ - | Create new line in segments list tree | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Create new line in segments list tree | + \*-----------------------------------------------------*/ SegmentTreeWidgetItem* new_item = new SegmentTreeWidgetItem(ui->SegmentsTreeWidget); - /*---------------------------------------------------------*\ - | Set the matrix map | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Set the matrix map | + \*-----------------------------------------------------*/ new_item->matrix_map = matrix_map; - /*---------------------------------------------------------*\ - | Create new widgets for line | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Create new widgets for line | + \*-----------------------------------------------------*/ QComboBox* combobox_type = new QComboBox(ui->SegmentsTreeWidget); QLineEdit* lineedit_name = new QLineEdit(ui->SegmentsTreeWidget); QLineEdit* lineedit_length = new QLineEdit(ui->SegmentsTreeWidget); @@ -221,14 +363,14 @@ void OpenRGBZoneEditorDialog::AddSegmentRow(QString name, unsigned int length, z button_matrix_map->setText(QString::number(new_item->matrix_map.height) + "x" + QString::number(new_item->matrix_map.width)); - /*---------------------------------------------------------*\ - | Fill in Name field | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Fill in Name field | + \*-----------------------------------------------------*/ lineedit_name->setText(name); - /*---------------------------------------------------------*\ - | Set up segment type combo box | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Set up segment type combo box | + \*-----------------------------------------------------*/ combobox_type->addItem("Single"); combobox_type->addItem("Linear"); combobox_type->addItem("Matrix"); @@ -239,29 +381,29 @@ void OpenRGBZoneEditorDialog::AddSegmentRow(QString name, unsigned int length, z combobox_type->setCurrentIndex(type); - /*---------------------------------------------------------*\ - | Fill in Length field | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Fill in Length field | + \*-----------------------------------------------------*/ lineedit_length->setText(QString::number(length)); - /*---------------------------------------------------------*\ - | Fill in slider length and maximum | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Fill in slider length and maximum | + \*-----------------------------------------------------*/ slider_length->setMaximum(edit_dev->GetZoneLEDsCount(edit_zone_idx)); slider_length->setValue(length); - /*---------------------------------------------------------*\ - | Add new widgets to tree | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Add new widgets to tree | + \*-----------------------------------------------------*/ ui->SegmentsTreeWidget->setItemWidget(new_item, 0, lineedit_name); ui->SegmentsTreeWidget->setItemWidget(new_item, 1, combobox_type); ui->SegmentsTreeWidget->setItemWidget(new_item, 2, button_matrix_map); ui->SegmentsTreeWidget->setItemWidget(new_item, 3, lineedit_length); ui->SegmentsTreeWidget->setItemWidget(new_item, 4, slider_length); - /*---------------------------------------------------------*\ - | Connect signals for handling slider and line edits | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Connect signals for handling slider and line edits | + \*-----------------------------------------------------*/ connect(lineedit_name, &QLineEdit::textChanged, this, &OpenRGBZoneEditorDialog::on_segment_lineedit_textChanged); connect(slider_length, &QSlider::valueChanged, this, &OpenRGBZoneEditorDialog::on_segment_slider_valueChanged); connect(lineedit_length, &QLineEdit::textChanged, this, &OpenRGBZoneEditorDialog::on_segment_lineedit_textChanged); @@ -270,9 +412,9 @@ void OpenRGBZoneEditorDialog::AddSegmentRow(QString name, unsigned int length, z void OpenRGBZoneEditorDialog::on_AddSegmentButton_clicked() { - /*---------------------------------------------------------*\ - | Create new empty row with name "Segment X" | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Create new empty row with name "Segment X" | + \*-----------------------------------------------------*/ QString new_name = "Segment " + QString::number(ui->SegmentsTreeWidget->topLevelItemCount() + 1); matrix_map_type new_matrix_map; @@ -285,23 +427,23 @@ void OpenRGBZoneEditorDialog::CheckSegmentsValidity() { bool segments_valid = true; - /*---------------------------------------------------------*\ - | Only check validity if segments are configured | - \*---------------------------------------------------------*/ + /*-----------------------------------------------------*\ + | Only check validity if segments are configured | + \*-----------------------------------------------------*/ if(ui->SegmentsTreeWidget->topLevelItemCount() != 0) { - /*-----------------------------------------------------*\ - | Verify all segments add up to zone size | - \*-----------------------------------------------------*/ + /*-------------------------------------------------*\ + | Verify all segments add up to zone size | + \*-------------------------------------------------*/ int total_segment_leds = 0; for(int segment_idx = 0; segment_idx < ui->SegmentsTreeWidget->topLevelItemCount(); segment_idx++) { unsigned int segment_leds = ((QLineEdit*)ui->SegmentsTreeWidget->itemWidget(ui->SegmentsTreeWidget->topLevelItem(segment_idx), 3))->text().toInt(); - /*-------------------------------------------------*\ - | Zero-length segment is not allowed | - \*-------------------------------------------------*/ + /*---------------------------------------------*\ + | Zero-length segment is not allowed | + \*---------------------------------------------*/ if(segment_leds == 0) { segments_valid = false; @@ -309,16 +451,16 @@ void OpenRGBZoneEditorDialog::CheckSegmentsValidity() total_segment_leds += segment_leds; - /*-------------------------------------------------*\ - | Empty name is not allowed | - \*-------------------------------------------------*/ + /*---------------------------------------------*\ + | Empty name is not allowed | + \*---------------------------------------------*/ if(((QLineEdit*)ui->SegmentsTreeWidget->itemWidget(ui->SegmentsTreeWidget->topLevelItem(segment_idx), 0))->text().isEmpty()) { segments_valid = false; } } - if(total_segment_leds != ui->ResizeBox->value()) + if(total_segment_leds != ui->SpinBoxZoneSize->value()) { segments_valid = false; } @@ -366,7 +508,7 @@ void OpenRGBZoneEditorDialog::on_ImportConfigurationButton_clicked() \*-----------------------------------------*/ if(config_json.contains("segments")) { - unsigned int total_leds_count = ui->ResizeSlider->value(); + unsigned int total_leds_count = ui->SliderZoneSize->value(); for(std::size_t segment_idx = 0; segment_idx < config_json["segments"].size(); segment_idx++) { @@ -397,8 +539,8 @@ void OpenRGBZoneEditorDialog::on_ImportConfigurationButton_clicked() } - ui->ResizeSlider->setValue(total_leds_count); - ui->ResizeBox->setValue(total_leds_count); + ui->SliderZoneSize->setValue(total_leds_count); + ui->SpinBoxZoneSize->setValue(total_leds_count); } } catch(const std::exception& e) @@ -475,3 +617,74 @@ void OpenRGBZoneEditorDialog::on_ExportConfigurationButton_clicked() } } +void OpenRGBZoneEditorDialog::on_ButtonZoneMatrixMap_clicked() +{ + unsigned int total_leds_count = ui->SliderZoneSize->value(); + + OpenRGBMatrixMapEditorDialog dialog(QString::fromStdString(edit_dev->GetZoneName(edit_zone_idx)), &edit_zone.matrix_map, total_leds_count); + + int ret = dialog.show(); + + ui->ButtonZoneMatrixMap->setText(QString::number(edit_zone.matrix_map.height) + "x" + QString::number(edit_zone.matrix_map.width)); + + if(ret >= 0) + { + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP) == 0) + { + edit_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP; + ui->LabelZoneMatrixMap->setText("Zone Matrix Map (*):"); + } + } +} + +void OpenRGBZoneEditorDialog::on_ButtonResetZoneConfiguration_clicked() +{ + edit_zone.flags &= ~ZONE_FLAGS_MANUALLY_CONFIGURED; + + /*-------------------------------------------------*\ + | Configure the zone | + \*-------------------------------------------------*/ + edit_dev->ConfigureZone(edit_zone_idx, edit_zone); + + /*-------------------------------------------------*\ + | Save the size profile | + \*-------------------------------------------------*/ + ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager(); + + if(profile_manager != NULL) + { + profile_manager->SaveSizes(); + } + + done(0); +} + +void OpenRGBZoneEditorDialog::on_LineEditZoneName_textChanged(const QString& /*arg1*/) +{ + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME) == 0) + { + edit_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURED_NAME; + ui->LabelZoneName->setText("Zone Name (*):"); + } +} + + +void OpenRGBZoneEditorDialog::on_ComboBoxZoneType_currentIndexChanged(int /*index*/) +{ + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE) == 0) + { + edit_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURED_TYPE; + ui->LabelZoneType->setText("Zone Type (*):"); + } +} + + +void OpenRGBZoneEditorDialog::on_ComboBoxZoneColorOrder_currentIndexChanged(int /*index*/) +{ + if((edit_zone.flags & ZONE_FLAG_MANUALLY_CONFIGURED_COLOR_ORDER) == 0) + { + edit_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURED_COLOR_ORDER; + ui->LabelZoneColorOrder->setText("Zone Color Order (*):"); + } +} + diff --git a/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.h b/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.h index e6253283b..4d718825d 100644 --- a/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.h +++ b/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.h @@ -44,20 +44,25 @@ public: private slots: void changeEvent(QEvent *event); - void on_ResizeSlider_valueChanged(int value); - void on_ResizeBox_valueChanged(int arg1); + void on_SliderZoneSize_valueChanged(int value); + void on_SpinBoxZoneSize_valueChanged(int arg1); void on_AddSegmentButton_clicked(); void on_RemoveSegmentButton_clicked(); void on_segment_slider_valueChanged(int); void on_segment_lineedit_textChanged(); void on_ImportConfigurationButton_clicked(); - void on_ExportConfigurationButton_clicked(); + void on_ButtonZoneMatrixMap_clicked(); + void on_ButtonResetZoneConfiguration_clicked(); + void on_LineEditZoneName_textChanged(const QString& arg1); + void on_ComboBoxZoneType_currentIndexChanged(int index); + void on_ComboBoxZoneColorOrder_currentIndexChanged(int index); private: - Ui::OpenRGBZoneEditorDialog *ui; - RGBController* edit_dev; - unsigned int edit_zone_idx; + Ui::OpenRGBZoneEditorDialog* ui; + RGBController* edit_dev; + zone edit_zone; + unsigned int edit_zone_idx; void AddSegmentRow(QString name, unsigned int length, zone_type type, matrix_map_type matrix_map); void CheckSegmentsValidity(); diff --git a/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.ui b/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.ui index 6b63ac927..6d07a135b 100644 --- a/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.ui +++ b/qt/OpenRGBZoneEditorDialog/OpenRGBZoneEditorDialog.ui @@ -14,42 +14,10 @@ Zone Editor - - - - Zone Size - - - - - - - 0 - 0 - - - - Qt::Orientation::Horizontal - - - - - - - - 0 - 0 - - - - - - - - Segments + Segments Configuration @@ -110,22 +78,120 @@ - - - - - 0 - 0 - - - - Qt::Orientation::Horizontal - - - QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok + + + + Zone Configuration + + + + + + + + + + + + + Zone Type: + + + + + + + Zone Matrix Map: + + + + + + + Zone Color Order: + + + + + + + + + + + + + + + + Zone Name: + + + + + + + Zone Size: + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Qt::Orientation::Horizontal + + + + + + + + + + + + + Reset Zone Configuration + + + + + + + + 0 + 0 + + + + Qt::Orientation::Horizontal + + + QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok + + + + + diff --git a/qt/OpenRGBZonesBulkResizer/OpenRGBZonesBulkResizer.cpp b/qt/OpenRGBZonesBulkResizer/OpenRGBZonesBulkResizer.cpp index 94af16f77..2fe36d68c 100644 --- a/qt/OpenRGBZonesBulkResizer/OpenRGBZonesBulkResizer.cpp +++ b/qt/OpenRGBZonesBulkResizer/OpenRGBZonesBulkResizer.cpp @@ -63,7 +63,7 @@ void OpenRGBZonesBulkResizer::RunChecks(QWidget *parent) \*---------------------------------------------*/ if((controller->GetZoneLEDsCount(zone_index) == 0) && (controller->GetZoneLEDsCount(zone_index) < controller->GetZoneLEDsMax(zone_index)) && - (controller->GetZoneFlags(zone_index) & ZONE_FLAG_MANUALLY_CONFIGURED) == 0) + (controller->GetZoneFlags(zone_index) & ZONE_FLAGS_MANUALLY_CONFIGURED) == 0) { unconfigured_zones.push_back({controller, zone_index}); }