From 64f3a84e53588c9816cd936b4358d42372346f03 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 12 Oct 2021 22:22:37 -0500 Subject: [PATCH] Enable per-LED color for each Crucial mode, though new sticks only seem to use last value --- .../CrucialController/CrucialController.cpp | 9 --- .../CrucialController/CrucialController.h | 1 - .../RGBController_Crucial.cpp | 63 ++++++++++--------- 3 files changed, 35 insertions(+), 38 deletions(-) diff --git a/Controllers/CrucialController/CrucialController.cpp b/Controllers/CrucialController/CrucialController.cpp index 19fb7c532..0052053a9 100644 --- a/Controllers/CrucialController/CrucialController.cpp +++ b/Controllers/CrucialController/CrucialController.cpp @@ -15,9 +15,6 @@ CrucialController::CrucialController(i2c_smbus_interface* bus, crucial_dev_id de { this->bus = bus; this->dev = dev; - - // We don't know what mode the sticks are in until we set one. - this->last_mode = CRUCIAL_MODE_UNKNOWN; } CrucialController::~CrucialController() @@ -47,11 +44,7 @@ unsigned int CrucialController::GetLEDCount() void CrucialController::SetMode(unsigned char mode) { - // Don't set a mode if we've already set the same one before. - // This is mostly useful for direct mode and updating colors often. - if (mode == last_mode) return; SendEffectMode(mode, 0x10); - last_mode = mode; } void CrucialController::SetAllColorsDirect(RGBColor* colors) @@ -87,8 +80,6 @@ void CrucialController::SendEffectMode(unsigned char mode, unsigned char speed) void CrucialController::SendDirectColors(RGBColor* color_buf) { - SetMode(CRUCIAL_MODE_STATIC); - //Red Channels CrucialRegisterWrite(0x8300, RGBGetRValue(color_buf[0])); CrucialRegisterWrite(0x8301, RGBGetRValue(color_buf[1])); diff --git a/Controllers/CrucialController/CrucialController.h b/Controllers/CrucialController/CrucialController.h index f3fc6c4cf..3a950ddd6 100644 --- a/Controllers/CrucialController/CrucialController.h +++ b/Controllers/CrucialController/CrucialController.h @@ -59,7 +59,6 @@ private: unsigned char config_table[64]; unsigned int led_count; unsigned char channel_cfg; - unsigned char last_mode; i2c_smbus_interface * bus; crucial_dev_id dev; diff --git a/Controllers/CrucialController/RGBController_Crucial.cpp b/Controllers/CrucialController/RGBController_Crucial.cpp index 06dd4c807..6c61cdc34 100644 --- a/Controllers/CrucialController/RGBController_Crucial.cpp +++ b/Controllers/CrucialController/RGBController_Crucial.cpp @@ -29,88 +29,85 @@ RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr) mode Shift; Shift.name = "Shift"; Shift.value = CRUCIAL_MODE_SHIFT; - Shift.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; - Shift.colors_min = 1; - Shift.colors_max = 1; - Shift.color_mode = MODE_COLORS_MODE_SPECIFIC; - Shift.colors.resize(1); + Shift.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Shift.color_mode = MODE_COLORS_PER_LED; modes.push_back(Shift); mode GradientShift; GradientShift.name = "Gradient Shift"; GradientShift.value = CRUCIAL_MODE_GRADIENT_SHIFT; - GradientShift.flags = 0; - GradientShift.color_mode = MODE_COLORS_NONE; + GradientShift.flags = MODE_FLAG_HAS_PER_LED_COLOR; + GradientShift.color_mode = MODE_COLORS_PER_LED; modes.push_back(GradientShift); mode Fill; Fill.name = "Fill"; Fill.value = CRUCIAL_MODE_FILL; - Fill.flags = 0; - Fill.color_mode = MODE_COLORS_NONE; + Fill.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Fill.color_mode = MODE_COLORS_PER_LED; modes.push_back(Fill); mode Stack; Stack.name = "Stack"; Stack.value = CRUCIAL_MODE_STACK; - Stack.flags = 0; - Stack.color_mode = MODE_COLORS_NONE; + Stack.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Stack.color_mode = MODE_COLORS_PER_LED; modes.push_back(Stack); mode DoubleStack; DoubleStack.name = "Double Stack"; DoubleStack.value = CRUCIAL_MODE_DOUBLE_STACK; - DoubleStack.flags = 0; - DoubleStack.color_mode = MODE_COLORS_NONE; + DoubleStack.flags = MODE_FLAG_HAS_PER_LED_COLOR; + DoubleStack.color_mode = MODE_COLORS_PER_LED; modes.push_back(DoubleStack); mode Breathing; Breathing.name = "Breathing"; Breathing.value = CRUCIAL_MODE_BREATHING; - Breathing.flags = 0; - Breathing.color_mode = MODE_COLORS_NONE; + Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Breathing.color_mode = MODE_COLORS_PER_LED; modes.push_back(Breathing); mode MotionPoint; MotionPoint.name = "Motion Point"; MotionPoint.value = CRUCIAL_MODE_MOTION_POINT; - MotionPoint.flags = 0; - MotionPoint.color_mode = MODE_COLORS_NONE; + MotionPoint.flags = MODE_FLAG_HAS_PER_LED_COLOR; + MotionPoint.color_mode = MODE_COLORS_PER_LED; modes.push_back(MotionPoint); mode InsideOut; InsideOut.name = "Inside Out"; InsideOut.value = CRUCIAL_MODE_INSIDE_OUT; - InsideOut.flags = 0; - InsideOut.color_mode = MODE_COLORS_NONE; + InsideOut.flags = MODE_FLAG_HAS_PER_LED_COLOR; + InsideOut.color_mode = MODE_COLORS_PER_LED; modes.push_back(InsideOut); mode ColorStep; ColorStep.name = "Color Step"; ColorStep.value = CRUCIAL_MODE_COLOR_STEP; - ColorStep.flags = 0; - ColorStep.color_mode = MODE_COLORS_NONE; + ColorStep.flags = MODE_FLAG_HAS_PER_LED_COLOR; + ColorStep.color_mode = MODE_COLORS_PER_LED; modes.push_back(ColorStep); mode WaterWave; WaterWave.name = "Water Wave (Color Blending)"; WaterWave.value = CRUCIAL_MODE_WATER_WAVE; - WaterWave.flags = 0; - WaterWave.color_mode = MODE_COLORS_NONE; + WaterWave.flags = MODE_FLAG_HAS_PER_LED_COLOR; + WaterWave.color_mode = MODE_COLORS_PER_LED; modes.push_back(WaterWave); mode Flashing; Flashing.name = "Flashing"; Flashing.value = CRUCIAL_MODE_FLASHING; - Flashing.flags = 0; - Flashing.color_mode = MODE_COLORS_NONE; + Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Flashing.color_mode = MODE_COLORS_PER_LED; modes.push_back(Flashing); mode Static; Static.name = "Static"; Static.value = CRUCIAL_MODE_STATIC; - Static.flags = 0; - Static.color_mode = MODE_COLORS_NONE; + Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Static.color_mode = MODE_COLORS_PER_LED; modes.push_back(Static); SetupZones(); @@ -185,6 +182,16 @@ void RGBController_Crucial::SetCustomMode() void RGBController_Crucial::DeviceUpdateMode() { - if (modes[active_mode].value == 0xFFFF) return; + if(modes[active_mode].value == 0xFFFF) + { + crucial->SetMode(CRUCIAL_MODE_STATIC); + return; + } + + if(modes[active_mode].color_mode == MODE_COLORS_PER_LED) + { + crucial->SetAllColorsEffect(&colors[0]); + } + crucial->SetMode(modes[active_mode].value); }