From 3ec91186e8cef2aff344aa377e87a0c86edb2148 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 5 Jun 2021 01:38:22 -0500 Subject: [PATCH] Add brightness control to Gigabyte RGB Fusion 2 USB Controller Commit split from original brightness commit by Adam Honse --- .../GigabyteRGBFusion2USBController.cpp | 4 +- .../GigabyteRGBFusion2USBController.h | 2 +- .../RGBController_GigabyteRGBFusion2USB.cpp | 101 ++++++++++-------- 3 files changed, 62 insertions(+), 45 deletions(-) diff --git a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.cpp b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.cpp index b882048f..534a34e3 100644 --- a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.cpp +++ b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.cpp @@ -354,7 +354,7 @@ static const std::array< std::array, 5> speeds = }, }; -void RGBFusion2USBController::SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char r, unsigned char g, unsigned char b) +void RGBFusion2USBController::SetLEDEffect(unsigned int led, int mode, unsigned int speed, unsigned char brightness, bool random, unsigned char r, unsigned char g, unsigned char b) { PktEffect pkt; @@ -371,6 +371,8 @@ void RGBFusion2USBController::SetLEDEffect(unsigned int led, int mode, unsigned pkt.e.period2 = s[2]; } + pkt.e.max_brightness = brightness; + switch(mode) { case 0: diff --git a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.h b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.h index 85250a9a..11524eba 100644 --- a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.h +++ b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBController.h @@ -219,7 +219,7 @@ public: int single_led = -1 ); - void SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char red, unsigned char green, unsigned char blue); + void SetLEDEffect(unsigned int led, int mode, unsigned int speed, unsigned char brightness, bool random, unsigned char red, unsigned char green, unsigned char blue); void SetLedCount(unsigned int led, unsigned int count); void SetMode(int mode); bool ApplyEffect(); diff --git a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp index 27b6659b..27dd7d85 100644 --- a/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp +++ b/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.cpp @@ -209,62 +209,77 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController modes.push_back(Direct); mode Static; - Static.name = "Static"; - Static.value = EFFECT_STATIC; - Static.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; - Static.colors_min = 1; - Static.colors_max = 1; - Static.color_mode = MODE_COLORS_MODE_SPECIFIC; + Static.name = "Static"; + Static.value = EFFECT_STATIC; + Static.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; + Static.brightness_min = 0; + Static.brightness_max = 100; + Static.brightness = Static.brightness_max; + Static.colors_min = 1; + Static.colors_max = 1; + Static.color_mode = MODE_COLORS_MODE_SPECIFIC; Static.colors.resize(1); modes.push_back(Static); mode Breathing; - Breathing.name = "Breathing"; - Breathing.value = EFFECT_PULSE; - Breathing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; - Breathing.speed_min = 0; - Breathing.speed_max = 4; - Breathing.colors_min = 1; - Breathing.colors_max = 1; - Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC; + Breathing.name = "Breathing"; + Breathing.value = EFFECT_PULSE; + Breathing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; + Breathing.brightness_min = 0; + Breathing.brightness_max = 100; + Breathing.brightness = Breathing.brightness_max; + Breathing.speed_min = 0; + Breathing.speed_max = 4; + Breathing.colors_min = 1; + Breathing.colors_max = 1; + Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC; Breathing.colors.resize(1); - Breathing.speed = 2; + Breathing.speed = 2; modes.push_back(Breathing); mode Blinking; - Blinking.name = "Blinking"; - Blinking.value = EFFECT_BLINKING; - Blinking.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; - Blinking.speed_min = 0; - Blinking.speed_max = 4; - Blinking.colors_min = 1; - Blinking.colors_max = 1; - Blinking.color_mode = MODE_COLORS_MODE_SPECIFIC; + Blinking.name = "Blinking"; + Blinking.value = EFFECT_BLINKING; + Blinking.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; + Blinking.brightness_min = 0; + Blinking.brightness_max = 100; + Blinking.brightness = Blinking.brightness_max; + Blinking.speed_min = 0; + Blinking.speed_max = 4; + Blinking.colors_min = 1; + Blinking.colors_max = 1; + Blinking.color_mode = MODE_COLORS_MODE_SPECIFIC; Blinking.colors.resize(1); - Blinking.speed = 2; + Blinking.speed = 2; modes.push_back(Blinking); mode ColorCycle; - ColorCycle.name = "Color Cycle"; - ColorCycle.value = EFFECT_COLORCYCLE; - ColorCycle.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED; - ColorCycle.speed_min = 0; - ColorCycle.speed_max = 4; - ColorCycle.color_mode = MODE_COLORS_NONE; - ColorCycle.speed = 2; + ColorCycle.name = "Color Cycle"; + ColorCycle.value = EFFECT_COLORCYCLE; + ColorCycle.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED; + ColorCycle.brightness_min = 0; + ColorCycle.brightness_max = 100; + ColorCycle.brightness = ColorCycle.brightness_max; + ColorCycle.speed_min = 0; + ColorCycle.speed_max = 4; + ColorCycle.color_mode = MODE_COLORS_NONE; + ColorCycle.speed = 2; modes.push_back(ColorCycle); mode Flashing; - Flashing.name = "Flashing"; - Flashing.value = 10; - Flashing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; - Flashing.speed_min = 0; - Flashing.speed_max = 4; - Flashing.colors_min = 1; - Flashing.colors_max = 1; - Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC; + Flashing.name = "Flashing"; + Flashing.value = 10; + Flashing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; + Flashing.brightness_min = 0; + Flashing.brightness_max = 100; + Flashing.brightness = Flashing.brightness_max; + Flashing.speed_min = 0; + Flashing.speed_max = 4; + Flashing.colors_min = 1; + Flashing.colors_max = 1; + Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC; Flashing.colors.resize(1); - Flashing.speed = 2; + Flashing.speed = 2; modes.push_back(Flashing); Load_Device_Config(); @@ -559,7 +574,7 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone) /*---------------------------------------------------------*\ | Apply the mode and color to the zone | \*---------------------------------------------------------*/ - controller->SetLEDEffect(zones[zone].leds[led_idx].value, mode_value, modes[active_mode].speed, random, red, grn, blu); + controller->SetLEDEffect(zones[zone].leds[led_idx].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu); } controller->ApplyEffect(); @@ -605,7 +620,7 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone) | Apply built-in effects to LED strips | \*---------------------------------------------------------*/ controller->DisableBuiltinEffect(0, hdr == HDR_D_LED1 ? 0x01 : 0x02); - controller->SetLEDEffect(hdr, modes[active_mode].value, modes[active_mode].speed, random, red, grn, blu); + controller->SetLEDEffect(hdr, modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu); controller->ApplyEffect(); } } @@ -652,7 +667,7 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led) blu = RGBGetBValue(modes[active_mode].colors[0]); } - controller->SetLEDEffect(leds[led].value, mode_value, modes[active_mode].speed, random, red, grn, blu); + controller->SetLEDEffect(leds[led].value, mode_value, modes[active_mode].speed, modes[active_mode].brightness, random, red, grn, blu); controller->ApplyEffect(); } /*---------------------------------------------------------*\