forked from dekuNukem/exixe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
5_multiple_tubes_crossfade.ino
56 lines (44 loc) · 1.27 KB
/
5_multiple_tubes_crossfade.ino
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
/*
exixe modules:
https://github.com/dekuNukem/exixe
library docs:
https://github.com/dekuNukem/exixe/tree/master/arduino_library
Demo 5: Loop digits on two tubes with crossfade animation
*/
#include "exixe.h"
// change those to the cs pins you're using
int cs1 = 10;
int cs2 = 9;
unsigned char count;
exixe my_tube1 = exixe(cs1);
exixe my_tube2 = exixe(cs2);
void setup()
{
// ONLY CALL THIS ONCE
my_tube1.spi_init();
my_tube1.clear();
my_tube2.clear();
}
void loop()
{
count = (count + 1) % 10; // keep count between 0 to 9
my_tube1.crossfade_init(count, 15, 127, 0);
my_tube2.crossfade_init(10-count, 15, 127, 0);
/*
again, crossfade_run() is non-blocking, that means
you can run other tasks in the loop.
just make sure to call it at least every 33ms
and check its return value to see if it's finished.
*/
while(1)
{
unsigned char result1 = my_tube1.crossfade_run();
unsigned char result2 = my_tube2.crossfade_run();
// exit when both animations are finished
if(result1 == EXIXE_ANIMATION_FINISHED && result2 == EXIXE_ANIMATION_FINISHED)
break;
}
my_tube1.set_led(127, 40, 0); // orange;
my_tube2.set_led(127, 0, 127); // purple;
delay(500);
}