Оновлення стану системи
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#define WS2812_ALERT_GAP_PERIOD pdMS_TO_TICKS(2000)
|
||||
#define WS2812_VPN_ALERT_BLINKS 2
|
||||
#define WS2812_APP_ALERT_BLINKS 3
|
||||
#define WS2812_BRIGHTNESS_PERCENT 5
|
||||
|
||||
#define WS2812_VPN_SECTION_TICKS (WS2812_ALERT_BLINK_PERIOD * 2U * WS2812_VPN_ALERT_BLINKS)
|
||||
#define WS2812_APP_SECTION_TICKS (WS2812_ALERT_BLINK_PERIOD * 2U * WS2812_APP_ALERT_BLINKS)
|
||||
@@ -54,6 +55,7 @@ static void ws2812_status_compute_color(size_t index,
|
||||
uint8_t *g,
|
||||
uint8_t *b);
|
||||
static bool ws2812_recalculate_alert_counts(void);
|
||||
static uint8_t ws2812_apply_brightness(uint8_t component);
|
||||
|
||||
static void ws2812_animation_timer_cb(TimerHandle_t timer)
|
||||
{
|
||||
@@ -176,7 +178,11 @@ static esp_err_t ws2812_status_apply(void)
|
||||
for (size_t i = 0; i < WS2812_STATUS_LED_COUNT && err == ESP_OK; ++i) {
|
||||
uint8_t r = 0, g = 0, b = 0;
|
||||
ws2812_status_compute_color(i, now_ticks, &r, &g, &b);
|
||||
err = led_strip_set_pixel(s_strip, i, g, r, b);
|
||||
err = led_strip_set_pixel(s_strip,
|
||||
i,
|
||||
ws2812_apply_brightness(g),
|
||||
ws2812_apply_brightness(r),
|
||||
ws2812_apply_brightness(b));
|
||||
}
|
||||
if (err == ESP_OK) {
|
||||
err = led_strip_refresh(s_strip);
|
||||
@@ -352,3 +358,10 @@ static bool ws2812_recalculate_alert_counts(void)
|
||||
s_active_app_alerts = app;
|
||||
return changed;
|
||||
}
|
||||
|
||||
static uint8_t ws2812_apply_brightness(uint8_t component)
|
||||
{
|
||||
// Scale brightness down (component * 20%) with rounding to nearest.
|
||||
const uint16_t scaled = (component * WS2812_BRIGHTNESS_PERCENT + 50U) / 100U;
|
||||
return (uint8_t)scaled;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user