Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/RGBLED/RGBLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/RGBLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>(RGB_LED_RED_REGISTER_INFO);
uint8_t green = readFromRegister<uint8_t>(RGB_LED_GREEN_REGISTER_INFO);
uint8_t blue = readFromRegister<uint8_t>(RGB_LED_BLUE_REGISTER_INFO);
Expand Down
12 changes: 6 additions & 6 deletions src/RGBLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions src/registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
Loading