Skip to content

Commit cf1df34

Browse files
authored
Merge pull request #6 from arduino-libraries/name-clash-fix
Fix name clash of Color class
2 parents ed084d3 + e6cddfc commit cf1df34

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

Diff for: examples/RGBLED/RGBLED.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ void pulseColors(RGBLED &led) {
2424
led.setColor({255, 0, 0}); // Red
2525
pulseLED(led);
2626

27-
// Color can be set via Color struct or 3 separate uint8_t values
27+
// Color can be set via LEDColor struct or 3 separate uint8_t values
2828
led.setColor(0, 255, 0); // Green
2929
pulseLED(led);
3030

31-
Color blueColor = {0, 0, 255};
31+
LEDColor blueColor = {0, 0, 255};
3232
led.setColor(blueColor); // Blue
3333
pulseLED(led);
3434

Diff for: src/RGBLED.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ bool RGBLED::setColor(uint8_t r, uint8_t g, uint8_t b, bool persist) {
2323
return true;
2424
}
2525

26-
bool RGBLED::setColor(Color color, bool persist) {
26+
bool RGBLED::setColor(LEDColor color, bool persist) {
2727
return setColor(color.red, color.green, color.blue, persist);
2828
}
2929

30-
Color RGBLED::color() {
30+
LEDColor RGBLED::color() {
3131
uint8_t red = readFromRegister<uint8_t>(RGB_LED_RED_REGISTER_INFO);
3232
uint8_t green = readFromRegister<uint8_t>(RGB_LED_GREEN_REGISTER_INFO);
3333
uint8_t blue = readFromRegister<uint8_t>(RGB_LED_BLUE_REGISTER_INFO);

Diff for: src/RGBLED.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @brief Represents a color with red, green, and blue components.
55
*/
6-
struct Color {
6+
struct LEDColor {
77
uint8_t red; /**< The red component of the color. */
88
uint8_t green; /**< The green component of the color. */
99
uint8_t blue; /**< The blue component of the color. */
@@ -57,21 +57,21 @@ class RGBLED : public I2CDevice {
5757
bool setColor(uint8_t r, uint8_t g, uint8_t b, bool persist = false);
5858

5959
/**
60-
* @brief Sets the RGB color of the LED using a Color object.
61-
* The Color object contains the red, green, and blue values that can be changed individually.
60+
* @brief Sets the RGB color of the LED using a LEDColor object.
61+
* The LEDColor object contains the red, green, and blue values that can be changed individually.
6262
* Note: A value of 0, 0, 0 will set the color based on the IAQ value from the Indoor Air Quality sensor.
6363
* @param color The RGB color to set.
6464
* @param persist If true, the change will be saved to flash memory.
6565
* @return True if the color was set successfully, false otherwise.
6666
*/
67-
bool setColor(Color color, bool persist = false);
67+
bool setColor(LEDColor color, bool persist = false);
6868

6969
/**
7070
* @brief Gets the current RGB color of the LED.
7171
*
72-
* @return The current RGB color as a Color object.
72+
* @return The current RGB color as a LEDColor object.
7373
*/
74-
Color color();
74+
LEDColor color();
7575

7676
/**
7777
* @brief Get the brightness of the RGB LED (0-255)

Diff for: src/registers.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ constexpr RegisterInfo SLAVE_ADDRESS_REGISTER_INFO{0x01, "uint8", 1};
1616
constexpr RegisterInfo CONTROL_REGISTER_INFO{0x02, "uint8", 1};
1717
constexpr RegisterInfo ORANGE_LED_REGISTER_INFO{0x03, "uint8", 1};
1818
constexpr RegisterInfo RGB_LED_RED_REGISTER_INFO{0x04, "uint8", 1};
19-
constexpr RegisterInfo RGB_LED_GREEN_REGISTER_INFO{0x05, "uint8", 1};
20-
constexpr RegisterInfo RGB_LED_BLUE_REGISTER_INFO{0x06, "uint8", 1};
19+
20+
/*
21+
According to the firmware design speciation the Green LED register is at address 0x05
22+
and the Blue LED register is at address 0x06. However due to a different LED
23+
being used in the final design the addresses are swapped.
24+
*/
25+
constexpr RegisterInfo RGB_LED_BLUE_REGISTER_INFO{0x05, "uint8", 1};
26+
constexpr RegisterInfo RGB_LED_GREEN_REGISTER_INFO{0x06, "uint8", 1};
27+
2128
constexpr RegisterInfo INTENSITY_REGISTER_INFO{0x07, "uint8", 1};
2229
constexpr RegisterInfo UART_CONTROL_REGISTER_INFO{0x08, "uint8", 1};
2330
constexpr RegisterInfo CSV_DELIMITER_REGISTER_INFO{0x09, "uint8", 1};

0 commit comments

Comments
 (0)