Add RGB pixel and brightness APIs, update Blinkt example (#1210)

* Added API to get the RGB pixel and brightness values from the blinkt interface.

* Fixed Channel object for Color object present-value which does not use coercion.

* Added API to the color-RGB library to convert from ASCII CSS color name to X,Y and brightness.

* Converted the Blinkt example app to use the basic-server.  Added a default color name command line option --color that accepts CSS color names. Set the color and brightness at startup.

* Added vacancy timer for lights using timer object defaulted to 30m and started at startup.
This commit is contained in:
Steve Karg
2026-01-27 07:34:32 -06:00
committed by GitHub
parent 4924a57ccc
commit 2b59aa1a99
8 changed files with 317 additions and 197 deletions
+37
View File
@@ -69,6 +69,29 @@ void blinkt_set_pixel(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
Blinkt_LED[led] = blinkt_rgbb(r, g, b, Blinkt_LED[led] & 0x1F);
}
/**
* @brief Get the current RGB color of one LED
* @param led index 0..#BLINKT_NUM_LEDS
* @param r pointer to store the red component (0..255), may be NULL
* @param g pointer to store the green component (0..255), may be NULL
* @param b pointer to store the blue component (0..255), may be NULL
*/
void blinkt_get_pixel(uint8_t led, uint8_t *r, uint8_t *g, uint8_t *b)
{
if (led >= BLINKT_NUM_LEDS) {
return;
}
if (r) {
*r = (Blinkt_LED[led] >> 24) & 0xFF;
}
if (g) {
*g = (Blinkt_LED[led] >> 16) & 0xFF;
}
if (b) {
*b = (Blinkt_LED[led] >> 8) & 0xFF;
}
}
/**
* @brief Set one LED to specific intensity
* @param led index 0..#BLINKT_NUM_LEDS
@@ -83,6 +106,20 @@ void blinkt_set_pixel_brightness(uint8_t led, uint8_t brightness)
Blinkt_LED[led] = (Blinkt_LED[led] & 0xFFFFFF00) | (brightness & 0x1F);
}
/**
* @brief Get the brightness of one LED
* @param led index 0..#BLINKT_NUM_LEDS
* @return brightness intensity from 0..31, 0=OFF, 1=dimmest, 31=brightest
*/
uint8_t blinkt_get_pixel_brightness(uint8_t led)
{
if (led >= BLINKT_NUM_LEDS) {
return 0;
}
return Blinkt_LED[led] & 0x1F;
}
/**
* @brief Set one LED to RGB color and brightness
* @param led index 0..#BLINKT_NUM_LEDS