diff --git a/examples/RGBLED/RGBLED.ino b/examples/RGBLED/RGBLED.ino index 28e210c..4cf3ab7 100644 --- a/examples/RGBLED/RGBLED.ino +++ b/examples/RGBLED/RGBLED.ino @@ -24,11 +24,11 @@ void pulseColors(RGBLED &led) { led.setColor({255, 0, 0}); // Red pulseLED(led); - // Color can be set via Color struct or 3 separate uint8_t values + // Color can be set via LEDColor struct or 3 separate uint8_t values led.setColor(0, 255, 0); // Green pulseLED(led); - Color blueColor = {0, 0, 255}; + LEDColor blueColor = {0, 0, 255}; led.setColor(blueColor); // Blue pulseLED(led); diff --git a/src/RGBLED.cpp b/src/RGBLED.cpp index df0229e..fae79b6 100644 --- a/src/RGBLED.cpp +++ b/src/RGBLED.cpp @@ -23,11 +23,11 @@ bool RGBLED::setColor(uint8_t r, uint8_t g, uint8_t b, bool persist) { return true; } -bool RGBLED::setColor(Color color, bool persist) { +bool RGBLED::setColor(LEDColor color, bool persist) { return setColor(color.red, color.green, color.blue, persist); } -Color RGBLED::color() { +LEDColor RGBLED::color() { uint8_t red = readFromRegister(RGB_LED_RED_REGISTER_INFO); uint8_t green = readFromRegister(RGB_LED_GREEN_REGISTER_INFO); uint8_t blue = readFromRegister(RGB_LED_BLUE_REGISTER_INFO); diff --git a/src/RGBLED.h b/src/RGBLED.h index cf8d71f..691e526 100644 --- a/src/RGBLED.h +++ b/src/RGBLED.h @@ -3,7 +3,7 @@ /** * @brief Represents a color with red, green, and blue components. */ -struct Color { +struct LEDColor { uint8_t red; /**< The red component of the color. */ uint8_t green; /**< The green component of the color. */ uint8_t blue; /**< The blue component of the color. */ @@ -57,21 +57,21 @@ class RGBLED : public I2CDevice { bool setColor(uint8_t r, uint8_t g, uint8_t b, bool persist = false); /** - * @brief Sets the RGB color of the LED using a Color object. - * The Color object contains the red, green, and blue values that can be changed individually. + * @brief Sets the RGB color of the LED using a LEDColor object. + * The LEDColor object contains the red, green, and blue values that can be changed individually. * Note: A value of 0, 0, 0 will set the color based on the IAQ value from the Indoor Air Quality sensor. * @param color The RGB color to set. * @param persist If true, the change will be saved to flash memory. * @return True if the color was set successfully, false otherwise. */ - bool setColor(Color color, bool persist = false); + bool setColor(LEDColor color, bool persist = false); /** * @brief Gets the current RGB color of the LED. * - * @return The current RGB color as a Color object. + * @return The current RGB color as a LEDColor object. */ - Color color(); + LEDColor color(); /** * @brief Get the brightness of the RGB LED (0-255) diff --git a/src/registers.h b/src/registers.h index 8ea4214..2d46cb4 100644 --- a/src/registers.h +++ b/src/registers.h @@ -16,8 +16,15 @@ constexpr RegisterInfo SLAVE_ADDRESS_REGISTER_INFO{0x01, "uint8", 1}; constexpr RegisterInfo CONTROL_REGISTER_INFO{0x02, "uint8", 1}; constexpr RegisterInfo ORANGE_LED_REGISTER_INFO{0x03, "uint8", 1}; constexpr RegisterInfo RGB_LED_RED_REGISTER_INFO{0x04, "uint8", 1}; -constexpr RegisterInfo RGB_LED_GREEN_REGISTER_INFO{0x05, "uint8", 1}; -constexpr RegisterInfo RGB_LED_BLUE_REGISTER_INFO{0x06, "uint8", 1}; + +/* +According to the firmware design speciation the Green LED register is at address 0x05 +and the Blue LED register is at address 0x06. However due to a different LED +being used in the final design the addresses are swapped. +*/ +constexpr RegisterInfo RGB_LED_BLUE_REGISTER_INFO{0x05, "uint8", 1}; +constexpr RegisterInfo RGB_LED_GREEN_REGISTER_INFO{0x06, "uint8", 1}; + constexpr RegisterInfo INTENSITY_REGISTER_INFO{0x07, "uint8", 1}; constexpr RegisterInfo UART_CONTROL_REGISTER_INFO{0x08, "uint8", 1}; constexpr RegisterInfo CSV_DELIMITER_REGISTER_INFO{0x09, "uint8", 1};