diff --git a/Controllers/MSIGPUController/MSIGPUController/MSIGPUController.cpp b/Controllers/MSIGPUController/MSIGPUController/MSIGPUController.cpp index f75f853e..35b034a3 100644 --- a/Controllers/MSIGPUController/MSIGPUController/MSIGPUController.cpp +++ b/Controllers/MSIGPUController/MSIGPUController/MSIGPUController.cpp @@ -10,10 +10,11 @@ #include "MSIGPUController.h" #include -MSIGPUController::MSIGPUController(i2c_smbus_interface* bus, msi_gpu_dev_id dev) +MSIGPUController::MSIGPUController(i2c_smbus_interface* bus, msi_gpu_dev_id dev, std::string dev_name) { - this->bus = bus; - this->dev = dev; + this->bus = bus; + this->dev = dev; + this->name = dev_name; } MSIGPUController::~MSIGPUController() @@ -31,6 +32,11 @@ std::string MSIGPUController::GetDeviceLocation() return("I2C: " + return_string); } +std::string MSIGPUController::GetDeviceName() +{ + return(name); +} + void MSIGPUController::SetRGB1(unsigned char red, unsigned char green, unsigned char blue) { MSIGPURegisterWrite(MSI_GPU_REG_R1, red); diff --git a/Controllers/MSIGPUController/MSIGPUController/MSIGPUController.h b/Controllers/MSIGPUController/MSIGPUController/MSIGPUController.h index 0d3c3034..c4e5e01c 100644 --- a/Controllers/MSIGPUController/MSIGPUController/MSIGPUController.h +++ b/Controllers/MSIGPUController/MSIGPUController/MSIGPUController.h @@ -66,10 +66,11 @@ enum class MSIGPUController { public: - MSIGPUController(i2c_smbus_interface* bus, msi_gpu_dev_id dev); + MSIGPUController(i2c_smbus_interface* bus, msi_gpu_dev_id dev, std::string dev_name); ~MSIGPUController(); std::string GetDeviceLocation(); + std::string GetDeviceName(); void SetRGB1(unsigned char red, unsigned char green, unsigned char blue); void SetRGB2(unsigned char red, unsigned char green, unsigned char blue); @@ -84,4 +85,5 @@ public: private: i2c_smbus_interface * bus; msi_gpu_dev_id dev; + std::string name; }; diff --git a/Controllers/MSIGPUController/MSIGPUController/MSIGPUControllerDetect.cpp b/Controllers/MSIGPUController/MSIGPUController/MSIGPUControllerDetect.cpp index af45275c..5ac9a8a1 100644 --- a/Controllers/MSIGPUController/MSIGPUController/MSIGPUControllerDetect.cpp +++ b/Controllers/MSIGPUController/MSIGPUController/MSIGPUControllerDetect.cpp @@ -28,9 +28,8 @@ void DetectMSIGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const s return; } - MSIGPUController* controller = new MSIGPUController(bus, i2c_addr); + MSIGPUController* controller = new MSIGPUController(bus, i2c_addr, name); RGBController_MSIGPU* rgb_controller = new RGBController_MSIGPU(controller); - rgb_controller->name = name; ResourceManager::get()->RegisterRGBController(rgb_controller); diff --git a/Controllers/MSIGPUController/MSIGPUController/RGBController_MSIGPU.cpp b/Controllers/MSIGPUController/MSIGPUController/RGBController_MSIGPU.cpp index b49c8bec..3f431fec 100644 --- a/Controllers/MSIGPUController/MSIGPUController/RGBController_MSIGPU.cpp +++ b/Controllers/MSIGPUController/MSIGPUController/RGBController_MSIGPU.cpp @@ -14,7 +14,7 @@ static const std::array speed_values = { 0x04, 0x02, 0x01 int RGBController_MSIGPU::GetDeviceMode() { - unsigned char dev_mode = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_MODE); + unsigned char dev_mode = controller->MSIGPURegisterRead(MSI_GPU_REG_MODE); for(std::size_t mode = 0; mode < modes.size(); mode++) { @@ -30,7 +30,7 @@ int RGBController_MSIGPU::GetDeviceMode() int RGBController_MSIGPU::GetModeSpeed() { - unsigned char mode_speed = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_SPEED); + unsigned char mode_speed = controller->MSIGPURegisterRead(MSI_GPU_REG_SPEED); for(std::size_t speed = 0; speed < speed_values.size(); speed++) { @@ -54,15 +54,15 @@ int RGBController_MSIGPU::GetModeSpeed() @comment \*-------------------------------------------------------------------*/ -RGBController_MSIGPU::RGBController_MSIGPU(MSIGPUController * msi_gpu_ptr) +RGBController_MSIGPU::RGBController_MSIGPU(MSIGPUController * controller_ptr) { - msi_gpu = msi_gpu_ptr; + controller = controller_ptr; - name = "MSI GPU Device"; - vendor = "MSI"; - type = DEVICE_TYPE_GPU; - description = name; - location = msi_gpu->GetDeviceLocation(); + name = controller->GetDeviceName(); + vendor = "MSI"; + type = DEVICE_TYPE_GPU; + description = name; + location = controller->GetDeviceLocation(); mode Direct; Direct.name = "Direct"; @@ -319,12 +319,12 @@ RGBController_MSIGPU::RGBController_MSIGPU(MSIGPUController * msi_gpu_ptr) active_mode = GetDeviceMode(); modes[active_mode].speed = GetModeSpeed(); - modes[active_mode].brightness = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_BRIGHTNESS) / MSI_GPU_BRIGHTNESS_MULTI; + modes[active_mode].brightness = controller->MSIGPURegisterRead(MSI_GPU_REG_BRIGHTNESS) / MSI_GPU_BRIGHTNESS_MULTI; } RGBController_MSIGPU::~RGBController_MSIGPU() { - delete msi_gpu; + delete controller; } void RGBController_MSIGPU::SetupZones() @@ -359,15 +359,15 @@ void RGBController_MSIGPU::SetupZones() /*---------------------------------------------------------*\ | Initialize color | \*---------------------------------------------------------*/ - unsigned char r1 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_R1); - unsigned char g1 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_G1); - unsigned char b1 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_B1); - unsigned char r2 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_R2); - unsigned char g2 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_G2); - unsigned char b2 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_B2); - unsigned char r3 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_R3); - unsigned char g3 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_G3); - unsigned char b3 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_B3); + unsigned char r1 = controller->MSIGPURegisterRead(MSI_GPU_REG_R1); + unsigned char g1 = controller->MSIGPURegisterRead(MSI_GPU_REG_G1); + unsigned char b1 = controller->MSIGPURegisterRead(MSI_GPU_REG_B1); + unsigned char r2 = controller->MSIGPURegisterRead(MSI_GPU_REG_R2); + unsigned char g2 = controller->MSIGPURegisterRead(MSI_GPU_REG_G2); + unsigned char b2 = controller->MSIGPURegisterRead(MSI_GPU_REG_B2); + unsigned char r3 = controller->MSIGPURegisterRead(MSI_GPU_REG_R3); + unsigned char g3 = controller->MSIGPURegisterRead(MSI_GPU_REG_G3); + unsigned char b3 = controller->MSIGPURegisterRead(MSI_GPU_REG_B3); colors[0] = ToRGBColor(r1, g1, b1); colors[1] = ToRGBColor(r2, g2, b2); @@ -394,16 +394,16 @@ void RGBController_MSIGPU::DeviceUpdateLEDs() { if(TimeToSend()) { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_UNKNOWN, 0x00); + controller->MSIGPURegisterWrite(MSI_GPU_REG_UNKNOWN, 0x00); if(modes[active_mode].value == MSI_GPU_MODE_FADEIN) { - msi_gpu->SetRGB2(RGBGetRValue(colors[1]), RGBGetGValue(colors[1]), RGBGetBValue(colors[1])); - msi_gpu->SetRGB3(RGBGetRValue(colors[2]), RGBGetGValue(colors[2]), RGBGetBValue(colors[2])); + controller->SetRGB2(RGBGetRValue(colors[1]), RGBGetGValue(colors[1]), RGBGetBValue(colors[1])); + controller->SetRGB3(RGBGetRValue(colors[2]), RGBGetGValue(colors[2]), RGBGetBValue(colors[2])); } else { - msi_gpu->SetRGB1(RGBGetRValue(colors[0]), RGBGetGValue(colors[0]), RGBGetBValue(colors[0])); + controller->SetRGB1(RGBGetRValue(colors[0]), RGBGetGValue(colors[0]), RGBGetBValue(colors[0])); } /*-----------------------------------------------------*\ @@ -429,14 +429,14 @@ void RGBController_MSIGPU::DeviceUpdateMode() { if(modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS) { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_BRIGHTNESS, modes[active_mode].brightness * MSI_GPU_BRIGHTNESS_MULTI); + controller->MSIGPURegisterWrite(MSI_GPU_REG_BRIGHTNESS, modes[active_mode].brightness * MSI_GPU_BRIGHTNESS_MULTI); if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED) { - msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_SPEED, speed_values[modes[active_mode].speed]); + controller->MSIGPURegisterWrite(MSI_GPU_REG_SPEED, speed_values[modes[active_mode].speed]); } - msi_gpu->SetMode(modes[active_mode].value); + controller->SetMode(modes[active_mode].value); /*-----------------------------------------------------*\ | Update last commit time | @@ -448,5 +448,5 @@ void RGBController_MSIGPU::DeviceUpdateMode() void RGBController_MSIGPU::DeviceSaveMode() { - msi_gpu->Save(); + controller->Save(); } diff --git a/Controllers/MSIGPUController/MSIGPUController/RGBController_MSIGPU.h b/Controllers/MSIGPUController/MSIGPUController/RGBController_MSIGPU.h index 24a6b3a2..e4e59619 100644 --- a/Controllers/MSIGPUController/MSIGPUController/RGBController_MSIGPU.h +++ b/Controllers/MSIGPUController/MSIGPUController/RGBController_MSIGPU.h @@ -15,7 +15,7 @@ class RGBController_MSIGPU : public RGBController { public: - RGBController_MSIGPU(MSIGPUController* msi_gpu_ptr); + RGBController_MSIGPU(MSIGPUController* controller_ptr); ~RGBController_MSIGPU(); void SetupZones(); @@ -29,7 +29,7 @@ public: void DeviceSaveMode(); private: - MSIGPUController* msi_gpu; + MSIGPUController* controller; std::chrono::time_point last_commit_time; bool TimeToSend();