/* * ws2812_effect.c * * Created on: Mar 25, 2026 * Author: ewars */ #include "ws2812_effect.h" #include "ws2812_drv.h" #include typedef struct { uint8_t r; uint8_t g; uint8_t b; } colour_s; static colour_s colour_hours = {250, 0, 0}; static colour_s colour_minutes = {0, 250, 0}; static colour_s colour_seconds = {0, 0, 250}; void ws_Effect_RoudTheClock(void){ #define RAND_MAX 25 uint8_t r = rand(); uint8_t g = rand(); uint8_t b = rand(); for (uint8_t led = 0; led < 24; led++) { ws2812_reset(); ws2812_set_colour(led, r, g, b); ws2812_update(); HAL_Delay(20); } } void ws_Effect_RandRound(void){ #define RAND_MAX 25 uint8_t r = rand(); uint8_t g = rand(); uint8_t b = rand(); for (uint8_t led = 0; led < 24; led++) { ws2812_set_colour(led, r, g, b); ws2812_update(); HAL_Delay(20); } } void ws_effect_display_time(uint8_t hour, uint8_t minute, uint8_t second){ ws2812_reset(); ws2812_set_colour(hour, colour_hours.r, colour_hours.g, colour_hours.b); ws2812_update(); ws2812_set_colour(minute, colour_minutes.r, colour_minutes.g, colour_minutes.b); ws2812_update(); ws2812_set_colour(second, colour_seconds.r, colour_seconds.g, colour_seconds.b); ws2812_update(); } void ws_effect_display_hour(uint8_t hour){ ws2812_reset(); ws2812_set_colour(hour, colour_hours.r, colour_hours.g, colour_hours.b); } void ws_Effect_RandRand(void){ #define RAND_MAX 25 uint8_t r = rand(); uint8_t g = rand(); uint8_t b = rand(); #define RAND_MAX 24 uint8_t led = rand(); ws2812_set_colour(led, r, g, b); ws2812_update(); HAL_Delay(1); }