forked from dekuNukem/exixe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
996 additions
and
878 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
63 changes: 63 additions & 0 deletions
63
resources/exixe_led_crossfade/5_multiple_tubes_crossfade.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
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 | ||
*/ | ||
|
||
#define RAINBOW_COLORS 6 | ||
|
||
#include "exixe.h" | ||
|
||
// change those to the cs pins you're using | ||
int cs1 = 10; | ||
int cs2 = 9; | ||
unsigned char count; | ||
|
||
unsigned char cl_red[RAINBOW_COLORS] = {148, 0, 0, 255, 255, 255}; | ||
unsigned char cl_green[RAINBOW_COLORS] = {0, 0, 255, 255, 127, 0}; | ||
unsigned char cl_blue[RAINBOW_COLORS] = {211, 255, 0, 0, 0, 0}; | ||
|
||
|
||
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(); | ||
randomSeed(analogRead(0)); | ||
} | ||
|
||
void loop() | ||
{ | ||
count = (count + 1) % 10; // keep count between 0 to 9 | ||
unsigned char cc1 = random(RAINBOW_COLORS); | ||
unsigned char cc2 = random(RAINBOW_COLORS); | ||
|
||
my_tube1.crossfade_init(count, 15, 127, 0, cl_red[cc1]/2, cl_green[cc1]/2, cl_blue[cc1]/2); | ||
my_tube2.crossfade_init(10-count, 15, 127, 0, cl_red[cc2]/2, cl_green[cc2]/2, cl_blue[cc2]/2); | ||
|
||
/* | ||
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; | ||
} | ||
|
||
delay(500); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
exixe modules: | ||
https://github.com/dekuNukem/exixe | ||
library docs: | ||
https://github.com/dekuNukem/exixe/tree/master/arduino_library | ||
Demo 3: Loop digits with crossfade animation | ||
*/ | ||
|
||
#define RAINBOW_COLORS 6 | ||
|
||
#include "exixe.h" | ||
|
||
// change this to the cs pin you're using | ||
int cs_pin = 10; | ||
unsigned char count; | ||
exixe my_tube = exixe(cs_pin); | ||
|
||
unsigned char cl_red[RAINBOW_COLORS] = {148, 0, 0, 255, 255, 255}; | ||
unsigned char cl_green[RAINBOW_COLORS] = {0, 0, 255, 255, 127, 0}; | ||
unsigned char cl_blue[RAINBOW_COLORS] = {211, 255, 0, 0, 0, 0}; | ||
|
||
void setup() | ||
{ | ||
my_tube.spi_init(); | ||
my_tube.clear(); | ||
} | ||
|
||
void loop() | ||
{ | ||
count = (count + 1) % RAINBOW_COLORS; | ||
/* | ||
1st arg: Digit to show, 0 to 9 | ||
2nd arg: how many frames does crossfade last, 30 frames = 1 second | ||
3rd arg: digit brightness, 0 to 127 | ||
4th arg: overdrive, 0 disable 1 enable | ||
This function sets up the crossfade animation | ||
call crossfade_run() to actually start it | ||
*/ | ||
my_tube.crossfade_init(count, 15, 127, 0, cl_red[count]/2, cl_green[count]/2, cl_blue[count]/2); | ||
|
||
// crossfade_run() is non-blocking and returns right away | ||
// call it regularly(at least every 33ms) for a smooth animation | ||
// check its return value to see if the animation is finished | ||
while(my_tube.crossfade_run() == EXIXE_ANIMATION_IN_PROGRESS) | ||
; | ||
|
||
delay(250); | ||
} |
Binary file not shown.