From a605d5581a31bdb5a0553c79c0ca2a33115f6217 Mon Sep 17 00:00:00 2001 From: TheRogueZeta <6479694-TheRogueZeta@users.noreply.gitlab.com> Date: Mon, 7 Sep 2020 00:24:53 -0700 Subject: [PATCH] Update zones on mode update Minor cleanup, logic tweak to only update per-zone modes for Polychrome V1 by Adam Honse --- .../PolychromeController.cpp | 18 ++++++++++++++---- .../PolychromeController.h | 3 ++- RGBController/RGBController_Polychrome.cpp | 12 +++++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Controllers/PolychromeController/PolychromeController.cpp b/Controllers/PolychromeController/PolychromeController.cpp index 6ee97b35..6d12cfdd 100644 --- a/Controllers/PolychromeController/PolychromeController.cpp +++ b/Controllers/PolychromeController/PolychromeController.cpp @@ -257,9 +257,10 @@ void PolychromeController::SetColorsAndSpeed(unsigned char led, unsigned char re } } -void PolychromeController::SetMode(unsigned char mode, unsigned char speed) +void PolychromeController::SetMode(unsigned char zone,unsigned char mode, unsigned char speed) { unsigned char led_count_pkt[1] = { 0x00 }; + active_zone = zone; active_mode = mode; active_speed = speed; @@ -271,13 +272,22 @@ void PolychromeController::SetMode(unsigned char mode, unsigned char speed) break; case ASROCK_TYPE_POLYCHROME_V1: - bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode); + /*-----------------------------------------------------*\ + | Make sure set all register is set to 0 | + \*-----------------------------------------------------*/ + bus->i2c_smbus_write_block_data(dev, POLYCHROME_V1_REG_SET_ALL, 1, led_count_pkt); std::this_thread::sleep_for(1ms); /*-----------------------------------------------------*\ - | Select a single LED | + | Set the zone we are working on | \*-----------------------------------------------------*/ - bus->i2c_smbus_write_block_data(dev, POLYCHROME_V1_REG_SET_ALL, 0, led_count_pkt); + bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, &active_zone); + std::this_thread::sleep_for(1ms); + + /*-----------------------------------------------------*\ + | Write the mode | + \*-----------------------------------------------------*/ + bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode); std::this_thread::sleep_for(1ms); break; diff --git a/Controllers/PolychromeController/PolychromeController.h b/Controllers/PolychromeController/PolychromeController.h index a569f9e4..0b509c55 100644 --- a/Controllers/PolychromeController/PolychromeController.h +++ b/Controllers/PolychromeController/PolychromeController.h @@ -203,13 +203,14 @@ public: unsigned int GetMode(); unsigned int GetASRockType(); void SetColorsAndSpeed(unsigned char led, unsigned char red, unsigned char green, unsigned char blue); - void SetMode(unsigned char mode, unsigned char speed); + void SetMode(unsigned char zone, unsigned char mode, unsigned char speed); unsigned char zone_led_count[6]; private: unsigned int asrock_type; std::string device_name; + unsigned char active_zone; unsigned char active_mode; unsigned char active_speed; i2c_smbus_interface* bus; diff --git a/RGBController/RGBController_Polychrome.cpp b/RGBController/RGBController_Polychrome.cpp index 3e296849..4ffb69c0 100644 --- a/RGBController/RGBController_Polychrome.cpp +++ b/RGBController/RGBController_Polychrome.cpp @@ -613,7 +613,17 @@ void RGBController_Polychrome::SetCustomMode() void RGBController_Polychrome::DeviceUpdateMode() { - polychrome->SetMode(modes[active_mode].value, modes[active_mode].speed); + if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1) + { + for(unsigned int led_idx = 0; led_idx <= leds.size(); led_idx++) + { + polychrome->SetMode(led_idx, modes[active_mode].value, modes[active_mode].speed); + } + } + else + { + polychrome->SetMode(0, modes[active_mode].value, modes[active_mode].speed); + } DeviceUpdateLEDs(); }