Clean up Linux LED controller

master
Adam Honse 7 months ago
parent c1781bc4cb
commit d4e802f3b3

@ -75,10 +75,12 @@ void LinuxLEDController::SetRGB(unsigned char red, unsigned char grn, unsigned c
{ {
std::string brightness_str; std::string brightness_str;
if (led_rgb_path.empty()) { if(led_rgb_path.empty())
/*-------------------------------------------------------------*\ {
| My phone LED that I tested this on shuts down if you set zero | /*-------------------------------------------------*\
\*-------------------------------------------------------------*/ | My phone LED that I tested this on shuts down if |
| you set zero |
\*-------------------------------------------------*/
if(red == 0) red = 1; if(red == 0) red = 1;
if(grn == 0) grn = 1; if(grn == 0) grn = 1;
if(blu == 0) blu = 1; if(blu == 0) blu = 1;
@ -98,19 +100,19 @@ void LinuxLEDController::SetRGB(unsigned char red, unsigned char grn, unsigned c
led_b_brightness.write(brightness_str.c_str(), brightness_str.length()); led_b_brightness.write(brightness_str.c_str(), brightness_str.length());
led_b_brightness.flush(); led_b_brightness.flush();
} }
else
else { {
/* /*-------------------------------------------------*\
* For the led_classdev_mc brightness just aplies a coefficient to the | For the led_classdev_mc brightness just applies a |
* multi_intensity. Set brightness to maximum and use the RGB values | coefficient to the multi_intensity. Set brightness|
* directly instead. | to maximum and use the RGB values directly |
*/ | instead. |
\*-------------------------------------------------*/
brightness_str = std::to_string((unsigned int)255); brightness_str = std::to_string((unsigned int)255);
led_rgb_brightness.write(brightness_str.c_str(), brightness_str.length()); led_rgb_brightness.write(brightness_str.c_str(), brightness_str.length());
led_rgb_brightness.flush(); led_rgb_brightness.flush();
brightness_str = std::to_string((unsigned int)red) + " " \
+ std::to_string((unsigned int)grn) + " " \ brightness_str = std::to_string((unsigned int)red) + " " + std::to_string((unsigned int)grn) + " " + std::to_string((unsigned int)blu);
+ std::to_string((unsigned int)blu);
led_rgb_color.write(brightness_str.c_str(), brightness_str.length()); led_rgb_color.write(brightness_str.c_str(), brightness_str.length());
led_rgb_color.flush(); led_rgb_color.flush();
} }

@ -30,10 +30,17 @@ RGBController_LinuxLED::RGBController_LinuxLED(LinuxLEDController* controller_pt
type = DEVICE_TYPE_LEDSTRIP; type = DEVICE_TYPE_LEDSTRIP;
description = "Linux Sysfs LED Device"; description = "Linux Sysfs LED Device";
location = "R: " + controller->GetRedPath() + "\r\n" + if(controller->GetRgbPath().empty())
{
location = "R: " + controller->GetRedPath() + "\r\n" +
"G: " + controller->GetGreenPath() + "\r\n" + "G: " + controller->GetGreenPath() + "\r\n" +
"B: " + controller->GetBluePath() + "\r\n" + "B: " + controller->GetBluePath();
"M: " + controller->GetRgbPath(); }
else
{
location = controller->GetRgbPath();
}
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
Direct.value = 0; Direct.value = 0;

Loading…
Cancel
Save