From fde468a1624a9fb174a5347e2280fda54006fa53 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sat, 7 Mar 2020 01:38:32 -0600 Subject: [PATCH] Update LED Strip controller to new RGBController API --- OpenRGB.cpp | 2 +- OpenRGB.pro | 8 ++--- RGBController/RGBController_LEDStrip.cpp | 41 ++++++++++++++---------- RGBController/RGBController_LEDStrip.h | 5 +++ 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/OpenRGB.cpp b/OpenRGB.cpp index bc202c6d..8f9e7780 100644 --- a/OpenRGB.cpp +++ b/OpenRGB.cpp @@ -327,7 +327,7 @@ void DetectRGBControllers(void) DetectRGBFusionControllers(busses, rgb_controllers); //DetectMSIRGBControllers(rgb_controllers); - //DetectLEDStripControllers(rgb_controllers); + DetectLEDStripControllers(rgb_controllers); //DetectHue2Controllers(rgb_controllers); //DetectHuePlusControllers(rgb_controllers); diff --git a/OpenRGB.pro b/OpenRGB.pro index 146fe19b..a992cee7 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -41,7 +41,7 @@ INCLUDEPATH += \ # Controllers/HuePlusController/ \ Controllers/HyperXController/ \ # Controllers/HyperXKeyboardController/ \ -# Controllers/LEDStripController/ \ + Controllers/LEDStripController/ \ # Controllers/MSI3ZoneController/ \ # Controllers/MSIRGBController/ \ # Controllers/PatriotViperController/ \ @@ -99,8 +99,8 @@ SOURCES += \ Controllers/HyperXController/HyperXControllerDetect.cpp \ # Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp \ # Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp \ -# Controllers/LEDStripController/LEDStripController.cpp \ -# Controllers/LEDStripController/LEDStripControllerDetect.cpp \ + Controllers/LEDStripController/LEDStripController.cpp \ + Controllers/LEDStripController/LEDStripControllerDetect.cpp \ # Controllers/MSI3ZoneController/MSI3ZoneController.cpp \ # Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \ # Controllers/MSIRGBController/MSIRGBController.cpp \ @@ -135,7 +135,7 @@ SOURCES += \ RGBController/RGBController_HyperX.cpp \ # RGBController/RGBController_HyperXKeyboard.cpp \ # RGBController/RGBController_E131.cpp \ -# RGBController/RGBController_LEDStrip.cpp \ + RGBController/RGBController_LEDStrip.cpp \ # RGBController/RGBController_MSI3Zone.cpp \ # RGBController/RGBController_MSIRGB.cpp \ # RGBController/RGBController_PatriotViper.cpp \ diff --git a/RGBController/RGBController_LEDStrip.cpp b/RGBController/RGBController_LEDStrip.cpp index 68015d84..fbc5c076 100644 --- a/RGBController/RGBController_LEDStrip.cpp +++ b/RGBController/RGBController_LEDStrip.cpp @@ -25,29 +25,36 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr) Direct.color_mode = MODE_COLORS_PER_LED; modes.push_back(Direct); - colors.resize(strip->num_leds); - - for (int i = 0; i < strip->num_leds; i++) - { - char id_buf[16]; - snprintf(id_buf, 16, "%d", i); + SetupZones(); +} +void RGBController_LEDStrip::SetupZones() +{ + zone led_zone; + led_zone.name = "LED Strip"; + led_zone.type = ZONE_TYPE_LINEAR; + led_zone.leds_min = strip->num_leds; + led_zone.leds_max = strip->num_leds; + led_zone.leds_count = strip->num_leds; + zones.push_back(led_zone); + + for(int led_idx = 0; led_idx < strip->num_leds; led_idx++) + { led new_led; new_led.name = "LED "; - new_led.name.append(id_buf); - + new_led.name.append(std::to_string(led_idx)); + leds.push_back(new_led); } - zone led_zone; - led_zone.name = "LED Strip"; - std::vector led_zone_map; - for (int i = 0; i < strip->num_leds; i++) - { - led_zone_map.push_back(i); - } - led_zone.map.push_back(led_zone_map); - zones.push_back(led_zone); + SetupColors(); +} + +void RGBController_LEDStrip::ResizeZone(int /*zone*/, int /*new_size*/) +{ + /*---------------------------------------------------------*\ + | This device does not support resizing zones | + \*---------------------------------------------------------*/ } void RGBController_LEDStrip::UpdateLEDs() diff --git a/RGBController/RGBController_LEDStrip.h b/RGBController/RGBController_LEDStrip.h index 11a10cfe..5e12c0a3 100644 --- a/RGBController/RGBController_LEDStrip.h +++ b/RGBController/RGBController_LEDStrip.h @@ -16,6 +16,11 @@ class RGBController_LEDStrip : public RGBController { public: RGBController_LEDStrip(LEDStripController* ledstrip_ptr); + + void SetupZones(); + + void ResizeZone(int zone, int new_size); + void UpdateLEDs(); void UpdateZoneLEDs(int zone); void UpdateSingleLED(int led);