Skip to content

Commit d4e802f

Browse files
Clean up Linux LED controller
1 parent c1781bc commit d4e802f

2 files changed

Lines changed: 26 additions & 17 deletions

File tree

Controllers/LinuxLEDController/LinuxLEDController_Linux.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ void LinuxLEDController::SetRGB(unsigned char red, unsigned char grn, unsigned c
7575
{
7676
std::string brightness_str;
7777

78-
if (led_rgb_path.empty()) {
79-
/*-------------------------------------------------------------*\
80-
| My phone LED that I tested this on shuts down if you set zero |
81-
\*-------------------------------------------------------------*/
78+
if(led_rgb_path.empty())
79+
{
80+
/*-------------------------------------------------*\
81+
| My phone LED that I tested this on shuts down if |
82+
| you set zero |
83+
\*-------------------------------------------------*/
8284
if(red == 0) red = 1;
8385
if(grn == 0) grn = 1;
8486
if(blu == 0) blu = 1;
@@ -98,19 +100,19 @@ void LinuxLEDController::SetRGB(unsigned char red, unsigned char grn, unsigned c
98100
led_b_brightness.write(brightness_str.c_str(), brightness_str.length());
99101
led_b_brightness.flush();
100102
}
101-
102-
else {
103-
/*
104-
* For the led_classdev_mc brightness just aplies a coefficient to the
105-
* multi_intensity. Set brightness to maximum and use the RGB values
106-
* directly instead.
107-
*/
103+
else
104+
{
105+
/*-------------------------------------------------*\
106+
| For the led_classdev_mc brightness just applies a |
107+
| coefficient to the multi_intensity. Set brightness|
108+
| to maximum and use the RGB values directly |
109+
| instead. |
110+
\*-------------------------------------------------*/
108111
brightness_str = std::to_string((unsigned int)255);
109112
led_rgb_brightness.write(brightness_str.c_str(), brightness_str.length());
110113
led_rgb_brightness.flush();
111-
brightness_str = std::to_string((unsigned int)red) + " " \
112-
+ std::to_string((unsigned int)grn) + " " \
113-
+ std::to_string((unsigned int)blu);
114+
115+
brightness_str = std::to_string((unsigned int)red) + " " + std::to_string((unsigned int)grn) + " " + std::to_string((unsigned int)blu);
114116
led_rgb_color.write(brightness_str.c_str(), brightness_str.length());
115117
led_rgb_color.flush();
116118
}

Controllers/LinuxLEDController/RGBController_LinuxLED_Linux.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,17 @@ RGBController_LinuxLED::RGBController_LinuxLED(LinuxLEDController* controller_pt
3030
type = DEVICE_TYPE_LEDSTRIP;
3131
description = "Linux Sysfs LED Device";
3232

33-
location = "R: " + controller->GetRedPath() + "\r\n" +
33+
if(controller->GetRgbPath().empty())
34+
{
35+
location = "R: " + controller->GetRedPath() + "\r\n" +
3436
"G: " + controller->GetGreenPath() + "\r\n" +
35-
"B: " + controller->GetBluePath() + "\r\n" +
36-
"M: " + controller->GetRgbPath();
37+
"B: " + controller->GetBluePath();
38+
}
39+
else
40+
{
41+
location = controller->GetRgbPath();
42+
}
43+
3744
mode Direct;
3845
Direct.name = "Direct";
3946
Direct.value = 0;

0 commit comments

Comments
 (0)