The content is as shown in the title. I found a HP PC with such a function and wanted to reproduce it on my own PC. As a result of my research, I was able to realize it using some open source software and my own C# application.
The environment in which I tried it is as follows
The motherboard used, TUF GAMING B550-PLUS, supports both regular RGB LED and addressable RGB (ARGB) LED connections. In this case, we used the following ARGB LED strips.
AINEX 2Way ARGB LED Strip Light 30cm RLD-STRDM30B
The overall picture of the system I have created is shown in the figure below.
It consists of the following components.
The program to get the CPU temperature using LibreHardwareMonitorLib is shown below." The "/amdcpu/0/temperature/2" part may need to be changed depending on the CPU.
As a precaution, the temperature could not be obtained without "Run as administrator" when executing this program.
Computer computer = new Computer(); computer.IsCpuEnabled = true; computer.Open(); computer.Accept(new UpdateVisitor()); double temperature = 0; foreach (IHardware hardware in computer.Hardware) { foreach (ISensor sensor in hardware.Sensors) { if (sensor.Identifier.ToString() == "/amdcpu/0/temperature/2") { temperature = sensor.Value.GetValueOrDefault(); } } }
UpdateVisitor is defined as follows;
public class UpdateVisitor : IVisitor { public void VisitComputer(IComputer computer) { computer.Traverse(this); } public void VisitHardware(IHardware hardware) { hardware.Update(); foreach (IHardware subHardware in hardware.SubHardware) subHardware.Accept(this); } public void VisitSensor(ISensor sensor) { } public void VisitParameter(IParameter parameter) { } }
When you run OpenRGB, you will see a screen like the one below, which also allows you to control LEDs with OpenRGB alone.
If you want to control it from the client application, as in this case, you should set "Mode" to "Direct".
To run as a server, select the "SDK Server" tab and press the "Start Server" button. Then connect to the server from the client application.
The program to connect to the OpenRGB server using OpenRGB.NET and set the LED colors is shown below. The variables r, g, and b contain the brightness of each RGB color.
var openRgbClient = new OpenRGBClient(name: "My OpenRGB Client", autoconnect: true, timeout: 1000); var devices = openRgbClient.GetAllControllerData(); for (int i = 0; i < devices.Length; i++) { var leds = Enumerable.Range(0, devices[i].Colors.Length) .Select(_ => new OpenRGB.NET.Models.Color((byte)r, (byte)g, (byte)b)) .ToArray(); openRgbClient.UpdateLeds(i, leds); }
When I actually measured the CPU temperature, it was about 40°C at no load and about 90°C at 100% load. Therefore, we decided to change the LED color from green to yellow to red as the CPU temperature changes from 40°C to 65°C to 90°C.
In this case, the temperature to RGB conversion program is as follows
int temp = (int)temperature; // Temperature int r, g, b; // Brightness of each color if (temp < 40) { r = 0; g = 255; b = 0; } else if (temp < 65) { r = 255 * (temp - 40) / 25; g = 255; b = 0; } else if (temp < 90) { r = 255; g = 255 * (90 - temp) / 25; b = 0; } else { r = 255; g = 0; b = 0; }
In fact, when I use it, I can see the temperature of the CPU with my eyes, and I can feel how the CPU is working hard to perform calculations.
...and upwards.