Skip to content

Commit 35e350e

Browse files
committed
modified data types
1 parent 81e8114 commit 35e350e

File tree

6 files changed

+78
-74
lines changed

6 files changed

+78
-74
lines changed

src/BacklightColors.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88

99
#include "BacklightColors.h"
1010

11-
const int BacklightColors::BLACK[3] = {0, 0, 0}; ///< Black color (0, 0, 0).
12-
const int BacklightColors::WHITE[3] = {255, 255, 255}; ///< White color (255, 255, 255).
13-
const int BacklightColors::HOTPINK[3] = {255, 10, 127}; ///< Hot Pink color (255, 10, 127).
14-
const int BacklightColors::RED[3] = {255, 10, 10}; ///< Red color (255, 10, 10).
15-
const int BacklightColors::ORANGE[3] = {255, 127, 10}; ///< Orange color (255, 127, 10).
16-
const int BacklightColors::YELLOW[3] = {255, 255, 10}; ///< Yellow color (255, 255, 10).
17-
const int BacklightColors::LIME[3] = {127, 255, 10}; ///< Lime Green color (127, 255, 10).
18-
const int BacklightColors::GREEN[3] = {10, 255, 10}; ///< Green color (10, 255, 10).
19-
const int BacklightColors::SPRING[3] = {10, 255, 127}; ///< Spring Green color (10, 255, 127).
20-
const int BacklightColors::CYAN[3] = {10, 255, 255}; ///< Cyan color (10, 255, 255).
21-
const int BacklightColors::SKY[3] = {10, 127, 255}; ///< Sky Blue color (10, 127, 255).
22-
const int BacklightColors::BLUE[3] = {10, 10, 255}; ///< Blue color (10, 10, 255).
23-
const int BacklightColors::VIOLET[3] = {127, 10, 255}; ///< Violet color (127, 10, 255).
24-
const int BacklightColors::MAGENTA[3] = {255, 10, 255}; ///< Magenta color (255, 10, 255).
25-
const int BacklightColors::GRAY[3] = {128, 128, 128}; ///< Gray color (128, 128, 128).
26-
const int BacklightColors::GREY[3] = {128, 128, 128}; ///< Grey color (128, 128, 128).
27-
const int BacklightColors::OLIVE[3] = {128, 128, 10}; ///< Olive color (128, 128, 10).
28-
const int BacklightColors::TEAL[3] = {10, 128, 128}; ///< Teal color (10, 128, 128).
29-
const int BacklightColors::PURPLE[3] = {128, 10, 128}; ///< Purple color (128, 10, 128).
11+
const uint8_t BacklightColors::BLACK[3] = {0, 0, 0}; ///< Black color (0, 0, 0).
12+
const uint8_t BacklightColors::WHITE[3] = {255, 255, 255}; ///< White color (255, 255, 255).
13+
const uint8_t BacklightColors::HOTPINK[3] = {255, 10, 127}; ///< Hot Pink color (255, 10, 127).
14+
const uint8_t BacklightColors::RED[3] = {255, 10, 10}; ///< Red color (255, 10, 10).
15+
const uint8_t BacklightColors::ORANGE[3] = {255, 127, 10}; ///< Orange color (255, 127, 10).
16+
const uint8_t BacklightColors::YELLOW[3] = {255, 255, 10}; ///< Yellow color (255, 255, 10).
17+
const uint8_t BacklightColors::LIME[3] = {127, 255, 10}; ///< Lime Green color (127, 255, 10).
18+
const uint8_t BacklightColors::GREEN[3] = {10, 255, 10}; ///< Green color (10, 255, 10).
19+
const uint8_t BacklightColors::SPRING[3] = {10, 255, 127}; ///< Spring Green color (10, 255, 127).
20+
const uint8_t BacklightColors::CYAN[3] = {10, 255, 255}; ///< Cyan color (10, 255, 255).
21+
const uint8_t BacklightColors::SKY[3] = {10, 127, 255}; ///< Sky Blue color (10, 127, 255).
22+
const uint8_t BacklightColors::BLUE[3] = {10, 10, 255}; ///< Blue color (10, 10, 255).
23+
const uint8_t BacklightColors::VIOLET[3] = {127, 10, 255}; ///< Violet color (127, 10, 255).
24+
const uint8_t BacklightColors::MAGENTA[3] = {255, 10, 255}; ///< Magenta color (255, 10, 255).
25+
const uint8_t BacklightColors::GRAY[3] = {128, 128, 128}; ///< Gray color (128, 128, 128).
26+
const uint8_t BacklightColors::GREY[3] = {128, 128, 128}; ///< Grey color (128, 128, 128).
27+
const uint8_t BacklightColors::OLIVE[3] = {128, 128, 10}; ///< Olive color (128, 128, 10).
28+
const uint8_t BacklightColors::TEAL[3] = {10, 128, 128}; ///< Teal color (10, 128, 128).
29+
const uint8_t BacklightColors::PURPLE[3] = {128, 10, 128}; ///< Purple color (128, 10, 128).

src/BacklightColors.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef BACKLIGHT_COLORS_H
1010
#define BACKLIGHT_COLORS_H
1111

12+
#include <stdint.h> ///< For uint8_t
13+
1214
/**
1315
* @class BacklightColors
1416
* @brief A collection of predefined RGB color constants.
@@ -19,26 +21,26 @@
1921
* - The third element represents the blue intensity (0 to 255).
2022
*/
2123
class BacklightColors {
22-
public:
23-
static const int BLACK[3]; ///< Black color (0, 0, 0).
24-
static const int WHITE[3]; ///< White color (255, 255, 255).
25-
static const int HOTPINK[3]; ///< Hot Pink color (255, 10, 127).
26-
static const int RED[3]; ///< Red color (255, 10, 10).
27-
static const int ORANGE[3]; ///< Orange color (255, 127, 10).
28-
static const int YELLOW[3]; ///< Yellow color (255, 255, 10).
29-
static const int LIME[3]; ///< Lime Green color (127, 255, 10).
30-
static const int GREEN[3]; ///< Green color (10, 255, 10).
31-
static const int SPRING[3]; ///< Spring color (10, 255, 127).
32-
static const int CYAN[3]; ///< Cyan color (10, 255, 255).
33-
static const int SKY[3]; ///< Sky Blue color (10, 127, 255).
34-
static const int BLUE[3]; ///< Blue color (10, 10, 255).
35-
static const int VIOLET[3]; ///< Violet color (127, 10, 255).
36-
static const int MAGENTA[3]; ///< Magenta color (255, 10, 255).
37-
static const int GRAY[3]; ///< Gray color (128, 128, 128).
38-
static const int GREY[3]; ///< Grey color (128, 128, 128).
39-
static const int OLIVE[3]; ///< Olive color (128, 128, 10).
40-
static const int TEAL[3]; ///< Teal color (10, 128, 128).
41-
static const int PURPLE[3]; ///< Purple color (128, 10, 128).
24+
public:
25+
static const uint8_t BLACK[3]; ///< Black color (0, 0, 0).
26+
static const uint8_t WHITE[3]; ///< White color (255, 255, 255).
27+
static const uint8_t HOTPINK[3]; ///< Hot Pink color (255, 10, 127).
28+
static const uint8_t RED[3]; ///< Red color (255, 10, 10).
29+
static const uint8_t ORANGE[3]; ///< Orange color (255, 127, 10).
30+
static const uint8_t YELLOW[3]; ///< Yellow color (255, 255, 10).
31+
static const uint8_t LIME[3]; ///< Lime Green color (127, 255, 10).
32+
static const uint8_t GREEN[3]; ///< Green color (10, 255, 10).
33+
static const uint8_t SPRING[3]; ///< Spring color (10, 255, 127).
34+
static const uint8_t CYAN[3]; ///< Cyan color (10, 255, 255).
35+
static const uint8_t SKY[3]; ///< Sky Blue color (10, 127, 255).
36+
static const uint8_t BLUE[3]; ///< Blue color (10, 10, 255).
37+
static const uint8_t VIOLET[3]; ///< Violet color (127, 10, 255).
38+
static const uint8_t MAGENTA[3]; ///< Magenta color (255, 10, 255).
39+
static const uint8_t GRAY[3]; ///< Gray color (128, 128, 128).
40+
static const uint8_t GREY[3]; ///< Grey color (128, 128, 128).
41+
static const uint8_t OLIVE[3]; ///< Olive color (128, 128, 10).
42+
static const uint8_t TEAL[3]; ///< Teal color (10, 128, 128).
43+
static const uint8_t PURPLE[3]; ///< Purple color (128, 10, 128).
4244
};
4345

4446
#endif

src/BacklightRGB.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
#include "BacklightRGB.h"
1010

1111

12-
BacklightRGB::BacklightRGB(int redPin, int greenPin, int bluePin) {
12+
BacklightRGB::BacklightRGB(uint8_t redPin, uint8_t greenPin, uint8_t bluePin) {
1313
_redPin = redPin; _greenPin = greenPin; _bluePin = bluePin;
1414
_COMMON_ANODE = true;
1515
_brightness = 255;
1616
_currentColor[0] = _currentColor[1] = _currentColor[2] = 0;
1717
}
1818

19-
BacklightRGB::BacklightRGB(int redPin, int greenPin, int bluePin, bool COMMON_ANODE) {
19+
BacklightRGB::BacklightRGB(uint8_t redPin, uint8_t greenPin, uint8_t bluePin, bool COMMON_ANODE) {
2020
_redPin = redPin; _greenPin = greenPin; _bluePin = bluePin;
2121
_COMMON_ANODE = COMMON_ANODE;
2222
_brightness = 255;
@@ -40,7 +40,7 @@ void BacklightRGB::begin() {
4040
#endif
4141
}
4242

43-
void BacklightRGB::setBrightness(int brightness) {
43+
void BacklightRGB::setBrightness(uint8_t brightness) {
4444
_brightness = constrain(brightness, 0, 255);
4545
showRGB(_currentColor[0], _currentColor[1], _currentColor[2]);
4646
}
@@ -49,46 +49,46 @@ int BacklightRGB::getBrightness() const {
4949
return _brightness;
5050
}
5151

52-
void BacklightRGB::setRGB(const int rgb[3]) {
52+
void BacklightRGB::setRGB(const uint8_t rgb[3]) {
5353
showRGB(rgb[0], rgb[1], rgb[2]);
5454
}
5555

56-
void BacklightRGB::setRGB(const int rgb[3], int brightness) {
56+
void BacklightRGB::setRGB(const uint8_t rgb[3], uint8_t brightness) {
5757
_currentColor[0] = rgb[0];
5858
_currentColor[1] = rgb[1];
5959
_currentColor[2] = rgb[2];
6060
setBrightness(brightness);
6161
}
6262

63-
void BacklightRGB::setRGB(int red, int green, int blue) {
63+
void BacklightRGB::setRGB(uint8_t red, uint8_t green, uint8_t blue) {
6464
showRGB(red, green, blue);
6565
}
6666

67-
void BacklightRGB::setRGB(int red, int green, int blue, int brightness) {
67+
void BacklightRGB::setRGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness) {
6868
_currentColor[0] = red;
6969
_currentColor[1] = green;
7070
_currentColor[2] = blue;
7171
setBrightness(brightness);
7272
}
7373

7474
void BacklightRGB::setHex(uint32_t hexColor) {
75-
int red = (hexColor >> 16) & 0xFF;
76-
int green = (hexColor >> 8) & 0xFF;
77-
int blue = hexColor & 0xFF;
75+
uint8_t red = (hexColor >> 16) & 0xFF;
76+
uint8_t green = (hexColor >> 8) & 0xFF;
77+
uint8_t blue = hexColor & 0xFF;
7878
showRGB(red, green, blue);
7979
}
8080

81-
void BacklightRGB::setHex(uint32_t hexColor, int brightness) {
82-
int red = (hexColor >> 16) & 0xFF;
83-
int green = (hexColor >> 8) & 0xFF;
84-
int blue = hexColor & 0xFF;
81+
void BacklightRGB::setHex(uint32_t hexColor, uint8_t brightness) {
82+
uint8_t red = (hexColor >> 16) & 0xFF;
83+
uint8_t green = (hexColor >> 8) & 0xFF;
84+
uint8_t blue = hexColor & 0xFF;
8585
_currentColor[0] = red;
8686
_currentColor[1] = green;
8787
_currentColor[2] = blue;
8888
setBrightness(brightness);
8989
}
9090

91-
int BacklightRGB::setColor(int color) {
91+
uint8_t BacklightRGB::setColor(uint8_t color) {
9292
color = constrain(color, 0, 255);
9393
color = color * _brightness / 255;
9494
if (_COMMON_ANODE) {
@@ -97,7 +97,7 @@ int BacklightRGB::setColor(int color) {
9797
return color;
9898
}
9999

100-
void BacklightRGB::showRGB(int red, int green, int blue) {
100+
void BacklightRGB::showRGB(uint8_t red, uint8_t green, uint8_t blue) {
101101
_currentColor[0] = red;
102102
_currentColor[1] = green;
103103
_currentColor[2] = blue;
@@ -115,7 +115,7 @@ void BacklightRGB::showRGB(int red, int green, int blue) {
115115
#endif
116116
}
117117

118-
const int* BacklightRGB::getRGB() const {
118+
const uint8_t* BacklightRGB::getRGB() const {
119119
return _currentColor;
120120
}
121121

src/BacklightRGB.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@
2020
class BacklightRGB {
2121
private:
2222
bool _COMMON_ANODE; ///< True if common anode RGB LED
23-
int _redPin; ///< Pin connected to the red LED.
24-
int _greenPin; ///< Pin connected to the green LED.
25-
int _bluePin; ///< Pin connected to the blue LED.
26-
int _brightness; ///< Brightness value (0 to 255).
27-
int _currentColor[3]; ///< Array storing the current RGB values.
23+
uint8_t _redPin; ///< Pin connected to the red LED.
24+
uint8_t _greenPin; ///< Pin connected to the green LED.
25+
uint8_t _bluePin; ///< Pin connected to the blue LED.
26+
uint8_t _brightness; ///< Brightness value (0 to 255).
27+
uint8_t _currentColor[3]; ///< Array storing the current RGB values.
2828

2929
/**
3030
* @brief Adjusts the intensity of a color component based on brightness.
3131
* @param color Original color component value (0 to 255).
3232
* @return Adjusted color value.
3333
*/
34-
inline int setColor(int color);
34+
inline uint8_t setColor(uint8_t color);
3535

3636
/**
3737
* @brief Updates the RGB LED with the specified red, green, and blue values.
3838
* @param red Red value (0 to 255)
3939
* @param green Green value (0 to 255)
4040
* @param blue Blue value (0 to 255)
4141
*/
42-
inline void showRGB(int red, int green, int blue);
42+
inline void showRGB(uint8_t red, uint8_t green, uint8_t blue);
4343

4444
public:
4545
/**
@@ -49,7 +49,7 @@ class BacklightRGB {
4949
* @param bluePin Pin connected to blue LED
5050
* @note common anode configuration by default
5151
*/
52-
BacklightRGB(int redPin, int greenPin, int bluePin);
52+
BacklightRGB(uint8_t redPin, uint8_t greenPin, uint8_t bluePin);
5353

5454
/**
5555
* @brief Constructor to initialize RGB pins.
@@ -58,7 +58,7 @@ class BacklightRGB {
5858
* @param bluePin Pin connected to blue LED
5959
* @param COMMON_ANODE Boolean variable indicating common anode RGB LED.
6060
*/
61-
BacklightRGB(int redPin, int greenPin, int bluePin, bool COMMON_ANODE);
61+
BacklightRGB(uint8_t redPin, uint8_t greenPin, uint8_t bluePin, bool COMMON_ANODE);
6262

6363
/**
6464
* @brief Initializes the RGB LED pins as outputs or PWM channels for ESP32.
@@ -81,7 +81,7 @@ class BacklightRGB {
8181
* @brief Sets the brightness of the LED.
8282
* @param brightness Brightness value (0 to 255).
8383
*/
84-
void setBrightness(int brightness);
84+
void setBrightness(uint8_t brightness);
8585

8686
/**
8787
* @brief Gets the current brightness level.
@@ -93,22 +93,22 @@ class BacklightRGB {
9393
* @brief Sets the RGB color using an array.
9494
* @param rgb Array containing red, green, and blue values.
9595
*/
96-
void setRGB(const int rgb[3]);
96+
void setRGB(const uint8_t rgb[3]);
9797

9898
/**
9999
* @brief Sets the RGB color and brightness using an array.
100100
* @param rgb Array containing red, green, and blue values.
101101
* @param brightness Brightness value (0 to 255).
102102
*/
103-
void setRGB(const int rgb[3], int brightness);
103+
void setRGB(const uint8_t rgb[3], uint8_t brightness);
104104

105105
/**
106106
* @brief Sets the RGB color using red, green, and blue values.
107107
* @param red Red value (0 to 255)
108108
* @param green Green value (0 to 255)
109109
* @param blue Blue value (0 to 255)
110110
*/
111-
void setRGB(int red, int green, int blue);
111+
void setRGB(uint8_t red, uint8_t green, uint8_t blue);
112112

113113
/**
114114
* @brief Sets the RGB color and brightness using red, green, and blue values.
@@ -117,7 +117,7 @@ class BacklightRGB {
117117
* @param blue Blue value (0 to 255)
118118
* @param brightness Brightness value (0 to 255)
119119
*/
120-
void setRGB(int red, int green, int blue, int brightness);
120+
void setRGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness);
121121

122122
/**
123123
* @brief Sets the RGB color using a hexadecimal value.
@@ -130,13 +130,15 @@ class BacklightRGB {
130130
* @param hexColor 24-bit hexadecimal value representing the color.
131131
* @param brightness Brightness value (0 to 255).
132132
*/
133-
void setHex(uint32_t hexColor, int brightness);
133+
void setHex(uint32_t hexColor, uint8_t brightness);
134134

135135
/**
136136
* @brief Gets the current RGB color.
137137
* @return Pointer to an array containing red, green, and blue values.
138138
*/
139-
const int* getRGB() const;
139+
//const int* getRGB() const;
140+
const uint8_t* getRGB() const;
141+
140142

141143
/**
142144
* @brief Gets the current color as a 24-bit hexadecimal value.

src/LCD_BacklightRGB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void LCD_BacklightRGB::setRGB(int red, int green, int blue, int brightness) {
3434
rgb.setRGB(red, green, blue, brightness);
3535
}
3636

37-
const int* LCD_BacklightRGB::getRGB() const {
37+
const uint8_t* LCD_BacklightRGB::getRGB() const {
3838
return rgb.getRGB();
3939
}
4040

src/LCD_BacklightRGB.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class LCD_BacklightRGB {
8080
* @brief Returns the current RGB values.
8181
* @return Pointer to an array of 3 uint8_t values {R, G, B}.
8282
*/
83-
const int* getRGB() const;
83+
const uint8_t* getRGB() const;
8484

8585
/**
8686
* @brief Sets the RGB color using a hexadecimal color value.

0 commit comments

Comments
 (0)