From 8dd0d8510442e12a4a8f49e20532719f5dd4e237 Mon Sep 17 00:00:00 2001 From: Jonas Malaco Date: Thu, 19 Nov 2020 12:56:27 -0300 Subject: [PATCH] Get active mode and last color set from EVGA v1 cards Improve the user experience by allowing the UI to be initialized with the settings that are currently active on the hardware. --- .../EVGAGPUController/EVGAGPUv1Controller.cpp | 5 +++++ .../EVGAGPUController/EVGAGPUv1Controller.h | 1 + .../RGBController_EVGAGPUv1.cpp | 20 ++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Controllers/EVGAGPUController/EVGAGPUv1Controller.cpp b/Controllers/EVGAGPUController/EVGAGPUv1Controller.cpp index 9e175a1f2..fb83b6d3a 100644 --- a/Controllers/EVGAGPUController/EVGAGPUv1Controller.cpp +++ b/Controllers/EVGAGPUController/EVGAGPUv1Controller.cpp @@ -30,6 +30,11 @@ std::string EVGAGPUv1Controller::GetDeviceLocation() return("I2C: " + return_string); } +unsigned char EVGAGPUv1Controller::GetMode() +{ + return(bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V1_REG_MODE)); +} + unsigned char EVGAGPUv1Controller::GetRed() { return(bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V1_REG_RED)); diff --git a/Controllers/EVGAGPUController/EVGAGPUv1Controller.h b/Controllers/EVGAGPUController/EVGAGPUv1Controller.h index 570d5abe6..a1c69d532 100644 --- a/Controllers/EVGAGPUController/EVGAGPUv1Controller.h +++ b/Controllers/EVGAGPUController/EVGAGPUv1Controller.h @@ -38,6 +38,7 @@ public: std::string GetDeviceLocation(); + unsigned char GetMode(); unsigned char GetRed(); unsigned char GetGreen(); unsigned char GetBlue(); diff --git a/Controllers/EVGAGPUController/RGBController_EVGAGPUv1.cpp b/Controllers/EVGAGPUController/RGBController_EVGAGPUv1.cpp index eaa3e324f..f8a2f0194 100644 --- a/Controllers/EVGAGPUController/RGBController_EVGAGPUv1.cpp +++ b/Controllers/EVGAGPUController/RGBController_EVGAGPUv1.cpp @@ -49,8 +49,26 @@ RGBController_EVGAGPUv1::RGBController_EVGAGPUv1(EVGAGPUv1Controller* evga_ptr) SetupZones(); - // Initialize active mode + // Initialize active mode and stored color + + unsigned char raw_active_mode = evga->GetMode(); + active_mode = 0; + for(unsigned int i = 0; i < modes.size(); i++) + { + if (modes[i].value == raw_active_mode) + { + active_mode = i; + break; + } + } + + unsigned char r = evga->GetRed(); + unsigned char g = evga->GetGreen(); + unsigned char b = evga->GetBlue(); + + RGBColor color = ToRGBColor(r, g, b); + colors[0] = color; } void RGBController_EVGAGPUv1::SetupZones()