forked from danjperron/rpi_ws281x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.c
59 lines (49 loc) · 1.22 KB
/
test1.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
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "neopixel.h"
#define GPIO_PIN 18
#define LED_COUNT 30
int main(int argc, char *argv[])
{
printf("Initializing\n");
printf(" Pin: %d\n", GPIO_PIN);
printf("Leds: %d\n", LED_COUNT);
if (!neo_init(GPIO_PIN, LED_COUNT))
{
return 1;
}
strip_set(0, 0x00200000); // red
strip_set(1, 0x00201000); // orange
strip_set(2, 0x00202000); // yellow
strip_set(3, 0x00002000); // green
strip_set(4, 0x00002020); // lightblue
strip_set(5, 0x00000020); // blue
strip_set(6, 0x00100010); // purple
strip_set(7, 0x00200010); // pink
time_t t;
srand((unsigned) time(&t));
int direction = 1;
printf("Starting loop\n");
while (!neo_loop_stop())
{
strip_render();
neo_sleep(0.05);
if (direction == 1)
{
strip_shift_down();
}
else
{
strip_shift_up();
}
if ((rand() % 1000) < 50)
{
direction *= -1;
}
}
printf("\nCleanup\n");
neo_deinit(true);
return 0;
}