-
Notifications
You must be signed in to change notification settings - Fork 0
/
ws2812.c
92 lines (76 loc) · 1.52 KB
/
ws2812.c
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ws2812.pio.h"
#include "banner.h"
#include "demo.h"
//=============================================================================
void demo (void)
{
#if 0
brightness(10);
demo_fader(CLR_RND, 1);
sleep_ms(500);
#endif
#if 1
brightness(5);
demo_primary(500);
sleep_ms(1000);
#endif
#if 0
brightness(5);
demo_walk(CLR_MAG, 10);
sleep_ms(1000);
#endif
#if 0
brightness(5);
cls(CLR_BLK);
demo_steps(CLR_RND,8);
demo_steps(CLR_BLK,8);
#endif
#if 0
brightness(5);
demo_twinkle(5000); // mS
#endif
#if 0
brightness(20);
demo_hrot(1); // repetitions
sleep_ms(1000);
#endif
#if 0
brightness(50);
clsr(CLR_RND);
for (int b = bright; b >= 0; fx_fader(b--, 20)) ; // fade to black
cls(CLR_BLK);
sleep_ms(1000);
#endif
#if 1
brightness(5);
demo_font(); // never returns
#endif
}
//=============================================================================
void hang (void)
{
brightness(5);
while (true) {
clsr(CLR_RND);
sleep_ms(100);
}
}
//++===========================================================================
int main (void)
{
// Start the serial monitor
stdio_init_all();
// Load PIO program
PIO pio = pio0;
int sm = 0;
uint offset = pio_add_program(pio, &ws2812_program);
ws2812_program_init(pio, sm, offset, PIN_WS2812, 800000, WS_IS_RGBW);
// sleep_ms(3000); // wait for minicom
printf("# WS2812 demo @ GPIO Pin #%d\n", PIN_WS2812);
(void)frameSetup(T_3X2_A);
demo();
// hang(); // never returns
}