Skip to content

Commit f4c2375

Browse files
committed
update LCD_BacklightRGB
1 parent 67787d7 commit f4c2375

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/LCD_BacklightRGB.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ LCD_BacklightRGB::LCD_BacklightRGB(int r, int g, int b, bool isCommonAnode)
1515

1616
void LCD_BacklightRGB::begin() {
1717
rgb.begin();
18-
rgb.setHex(0x0A878F); // Set default color to teal
18+
constexpr uint32_t COLOR_TEAL = 0x0A878F;
19+
rgb.setHex(COLOR_TEAL);
1920
}
2021

2122
void LCD_BacklightRGB::setGamma(bool enabled) {
@@ -212,7 +213,7 @@ void LCD_BacklightRGB::scaleColor(int value, int fromValue, int toValue) {
212213
hue = map(value, fromValue, toValue, 0, 360);
213214
} else if (fromValue > toValue) {
214215
value = constrain(value, toValue, fromValue);
215-
hue = map(value, fromValue, toValue, 360, 0);
216+
hue = map(value, toValue, fromValue, 360, 0);
216217
} else {
217218
hue = 0; // Default to Red if range is invalid.
218219
}

src/LCD_BacklightRGB.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ class LCD_BacklightRGB {
2525

2626
public:
2727
/**
28-
* @brief Constructor for the BacklightRGB class.
28+
* @brief Constructor for the LCD_BacklightRGB class.
2929
* @param r Pin for the red LED.
3030
* @param g Pin for the green LED.
3131
* @param b Pin for the blue LED.
3232
*/
3333
LCD_BacklightRGB(int r, int g, int b);
3434

3535
/**
36-
* @brief Constructor for the BacklightRGB class.
36+
* @brief Constructor for the LCD_BacklightRGB class.
3737
* @param r Pin for the red LED.
3838
* @param g Pin for the green LED.
3939
* @param b Pin for the blue LED.
@@ -117,7 +117,7 @@ class LCD_BacklightRGB {
117117
void setHSV(int hue, float sat = 1.0, float val= 1.0);
118118

119119
/**
120-
* @brief Sets
120+
* @brief Sets the RGB color using CMYK color components.
121121
* @param cyan Cyan value (0.0-1.0)
122122
* @param magenta Magenta value (0.0-1.0)
123123
* @param yellow Yellow value (0.0-1.0)
@@ -174,10 +174,11 @@ class LCD_BacklightRGB {
174174
/// @}
175175

176176
/**
177-
* @brief Maps a value to a color on the color wheel.
177+
* @brief Maps a numeric value to a corresponding color across the RGB color wheel.
178178
* @param value The input value to map.
179-
* @param fromValue The minimum range of the input value.
180-
* @param toValue The maximum range of the input value.
179+
* @param fromValue The minimum input range.
180+
* @param toValue The maximum input range.
181+
* @note Internally maps the range to a hue (0–360) and applies full saturation/value.
181182
*/
182183
void scaleColor(int value, int fromValue, int toValue);
183184

0 commit comments

Comments
 (0)