124 lines
2.2 KiB
C
124 lines
2.2 KiB
C
/*
|
|
* ws2812_effect.c
|
|
*
|
|
* Created on: Mar 25, 2026
|
|
* Author: ewars
|
|
*/
|
|
|
|
#include "ws2812_drv.h"
|
|
#include "ws2812_effect.h"
|
|
//#include "clock.h"
|
|
#include <stdlib.h>
|
|
|
|
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};
|
|
static colour_s colour_background = {0, 0, 0};
|
|
|
|
void clock_setColourHours(uint8_t r, uint8_t g, uint8_t b){
|
|
colour_hours.r = r;
|
|
colour_hours.g = g;
|
|
colour_hours.b = b;
|
|
}
|
|
|
|
void clock_setColourMinutes(uint8_t r, uint8_t g, uint8_t b){
|
|
colour_minutes.r = r;
|
|
colour_minutes.g = g;
|
|
colour_minutes.b = b;
|
|
}
|
|
|
|
void clock_setColourSeconds(uint8_t r, uint8_t g, uint8_t b){
|
|
colour_seconds.r = r;
|
|
colour_seconds.g = g;
|
|
colour_seconds.b = b;
|
|
}
|
|
|
|
|
|
void ws_Effect_InitModule(void){
|
|
|
|
ws2812_Init();
|
|
|
|
}
|
|
|
|
void clock_setColourBackground(uint8_t r, uint8_t g, uint8_t b){
|
|
|
|
colour_background.r = r;
|
|
colour_background.g = g;
|
|
colour_background.b = b;
|
|
}
|
|
|
|
|
|
|
|
|
|
void ws_Effect_RoudTheClock(void){
|
|
|
|
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();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void ws_Effect_RandRound(void){
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
void ws_effect_display_time(uint8_t hour, uint8_t minute, uint8_t second){
|
|
|
|
ws2812_reset();
|
|
//ws2812_resetColour(colour_background.r, colour_background.g, colour_background.b);
|
|
ws2812_update();
|
|
|
|
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){
|
|
|
|
uint8_t r = rand();
|
|
uint8_t g = rand();
|
|
uint8_t b = rand();
|
|
|
|
uint8_t led = rand();
|
|
|
|
ws2812_set_colour(led, r, g, b);
|
|
ws2812_update();
|
|
}
|