-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
88 lines (72 loc) · 1.9 KB
/
main.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
/**
* Baumhaus tree firmware
*/
#include <stdbool.h>
#include <stdint.h>
#include <nrf51.h>
#include <nrf_delay.h>
#include <board.h>
#include <leds.h>
#include <timer.h>
#include <patterns.h>
extern neopixel_strip_t strip[];
extern uint8_t leds_per_strip[];
/**
* Main program
*/
int main(void)
{
init_gpio();
init_ledstrips();
init_timer();
init_patterns();
atx_powersupply_enable();
/*
works on nRFduino...
// all on
while (true)
{
uint8_t value = 30;
for (uint8_t led=0; led<TOTAL_NUM_LEDS; led++)
neopixel_set_color(&strip[0], led, value, value, value);
neopixel_show(&strip[0]);
nrf_delay_ms(2000);
value = 0;
for (uint8_t led=0; led<TOTAL_NUM_LEDS; led++)
neopixel_set_color(&strip[0], led, value, value, value);
neopixel_show(&strip[0]);
nrf_delay_ms(2000);
}
*/
// infinite loop: all LEDs: brightness up, brightness down
while(true)
{
uint8_t value, led, s;
// brightness up
for (value=0; value<60; value++)
{
// set all LEDs
for (s=0; s<LEDSTRIP_COUNT; s++)
for (led=0; led<leds_per_strip[s]; led++)
neopixel_set_color(&strip[s], led, value, value, value);
// show
for (s=0; s<LEDSTRIP_COUNT; s++)
neopixel_show(&strip[s]);
// wait
nrf_delay_ms(3);
}
// brightness down
for (value=60; value>0; value--)
{
// set all LEDs
for (s=0; s<LEDSTRIP_COUNT; s++)
for (led=0; led<leds_per_strip[s]; led++)
neopixel_set_color(&strip[s], led, value, value, value);
// show
for (s=0; s<LEDSTRIP_COUNT; s++)
neopixel_show(&strip[s]);
// wait
nrf_delay_ms(3);
}
}
}