mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2025-12-24 07:47:49 -05:00
Update the LinuxLEDController to support multicolor LEDs defined by the Linux kernel. For multicolor LEDs Linux exposes a single brightness which allows a range of 0 (off) to 255 (max) and a multi_intensity value that accepts multiple channels of colors. This current implementation assumes that there are 3 multi_intensity channels between 0 and 255. https://docs.kernel.org/leds/leds-class-multicolor.html Note that for now in Linux the brightness value doesn't so much affect the brightness of the LED as it does apply a coefficient to the individual channel intensities. For now hard code the brightness to 255 and simply adjust the intensities to alter the color. This change should keep the existing sysfs code path as-is and only attempt to use this new method when a led_rgb_path is present in the config file. For reference, my OpenRGB.json has the following lines: ` "LinuxLEDDevices" : { "devices": [ { "name": "Fan LED 1", "rgb_path": "/sys/class/leds/rgb:programming-0/" } ] }` Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
/*---------------------------------------------------------*\
|
|
| LinuxLEDController_Linux.h |
|
|
| |
|
|
| Driver for Linux sysfs LEDs |
|
|
| |
|
|
| Adam Honse (calcprogrammer1@gmail.com) 25 Sep 2020 |
|
|
| |
|
|
| This file is part of the OpenRGB project |
|
|
| SPDX-License-Identifier: GPL-2.0-or-later |
|
|
\*---------------------------------------------------------*/
|
|
|
|
#pragma once
|
|
|
|
#include <fstream>
|
|
|
|
class LinuxLEDController
|
|
{
|
|
public:
|
|
LinuxLEDController(std::string dev_name);
|
|
~LinuxLEDController();
|
|
|
|
std::string GetName();
|
|
|
|
std::string GetRedPath();
|
|
std::string GetBluePath();
|
|
std::string GetGreenPath();
|
|
std::string GetRgbPath();
|
|
|
|
void OpenRedPath(std::string red_path);
|
|
void OpenGreenPath(std::string green_path);
|
|
void OpenBluePath(std::string blue_path);
|
|
void OpenRgbPath(std::string rgb_path);
|
|
|
|
void SetRGB(unsigned char red, unsigned char grn, unsigned char blu);
|
|
|
|
private:
|
|
std::string led_r_path;
|
|
std::string led_g_path;
|
|
std::string led_b_path;
|
|
std::string led_rgb_path;
|
|
std::ofstream led_r_brightness;
|
|
std::ofstream led_g_brightness;
|
|
std::ofstream led_b_brightness;
|
|
std::ofstream led_rgb_brightness;
|
|
std::ofstream led_rgb_color;
|
|
std::string name;
|
|
};
|