From d4e802f3b315c638269bec189a8c2844f213283e Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Mon, 20 Oct 2025 12:18:56 -0500 Subject: [PATCH] Clean up Linux LED controller --- .../LinuxLEDController_Linux.cpp | 30 ++++++++++--------- .../RGBController_LinuxLED_Linux.cpp | 13 ++++++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Controllers/LinuxLEDController/LinuxLEDController_Linux.cpp b/Controllers/LinuxLEDController/LinuxLEDController_Linux.cpp index b4b2ff15b..4304dbbdc 100644 --- a/Controllers/LinuxLEDController/LinuxLEDController_Linux.cpp +++ b/Controllers/LinuxLEDController/LinuxLEDController_Linux.cpp @@ -75,10 +75,12 @@ void LinuxLEDController::SetRGB(unsigned char red, unsigned char grn, unsigned c { std::string brightness_str; - if (led_rgb_path.empty()) { - /*-------------------------------------------------------------*\ - | My phone LED that I tested this on shuts down if you set zero | - \*-------------------------------------------------------------*/ + if(led_rgb_path.empty()) + { + /*-------------------------------------------------*\ + | My phone LED that I tested this on shuts down if | + | you set zero | + \*-------------------------------------------------*/ if(red == 0) red = 1; if(grn == 0) grn = 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.flush(); } - - else { - /* - * For the led_classdev_mc brightness just aplies a coefficient to the - * multi_intensity. Set brightness to maximum and use the RGB values - * directly instead. - */ + else + { + /*-------------------------------------------------*\ + | For the led_classdev_mc brightness just applies a | + | coefficient to the multi_intensity. Set brightness| + | to maximum and use the RGB values directly | + | instead. | + \*-------------------------------------------------*/ brightness_str = std::to_string((unsigned int)255); led_rgb_brightness.write(brightness_str.c_str(), brightness_str.length()); led_rgb_brightness.flush(); - brightness_str = std::to_string((unsigned int)red) + " " \ - + std::to_string((unsigned int)grn) + " " \ - + std::to_string((unsigned int)blu); + + brightness_str = std::to_string((unsigned int)red) + " " + std::to_string((unsigned int)grn) + " " + std::to_string((unsigned int)blu); led_rgb_color.write(brightness_str.c_str(), brightness_str.length()); led_rgb_color.flush(); } diff --git a/Controllers/LinuxLEDController/RGBController_LinuxLED_Linux.cpp b/Controllers/LinuxLEDController/RGBController_LinuxLED_Linux.cpp index 2816d86f5..c9d478af2 100644 --- a/Controllers/LinuxLEDController/RGBController_LinuxLED_Linux.cpp +++ b/Controllers/LinuxLEDController/RGBController_LinuxLED_Linux.cpp @@ -30,10 +30,17 @@ RGBController_LinuxLED::RGBController_LinuxLED(LinuxLEDController* controller_pt type = DEVICE_TYPE_LEDSTRIP; 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" + - "B: " + controller->GetBluePath() + "\r\n" + - "M: " + controller->GetRgbPath(); + "B: " + controller->GetBluePath(); + } + else + { + location = controller->GetRgbPath(); + } + mode Direct; Direct.name = "Direct"; Direct.value = 0;