-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathws2812b_fx.c
More file actions
48 lines (40 loc) · 799 Bytes
/
ws2812b_fx.c
File metadata and controls
48 lines (40 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "ws2812b_fx.h"
void _delay_ms(u16 wait);
RGBColor_t Wheel(unsigned char WheelPos)
{
WheelPos = 255 - WheelPos;
RGBColor_t color;
if(WheelPos < 85)
{
color.R = 255 - WheelPos * 3;
color.G = 0;
color.B = WheelPos * 3;
return color;
}
if(WheelPos < 170)
{
WheelPos -= 85;
color.R = 0;
color.G = WheelPos * 3;
color.B = 255 - WheelPos * 3;
return color;
}
WheelPos -= 170;
color.R = WheelPos * 3;
color.G = 255 - WheelPos * 3;
color.B = 0;
return color;
}
void rainbowCycle(uint8_t wait)
{
uint16_t i, j;
for(j=0; j<256 * 5; j++)
{ // 5 cycles of all colors on wheel
for(i=0; i < NB_LEDS; i++)
{
rgb_SetColor(i,Wheel(((i * 256 / 10) + j) & 255));
}
rgb_SendArray();
_delay_ms(wait);
}
}