nouvelles annimations

master
jblb 4 years ago
parent 992c2dbb78
commit 48311617f1

@ -10,10 +10,10 @@
#define BTN_PIN 3 // button pin #define BTN_PIN 3 // button pin
CRGB leds[NUM_LEDS]; CRGB leds[NUM_LEDS];
float tcount = 0.0; //-INC VAR FOR SIN LOOPS float tcount = 0.0; //-INC VAR FOR SIN LOOPS
int ibright = 0; //-BRIGHTNESS (0-255) int ibright = 0; //-BRIGHTNESS (0-255)
int tempo_anim = TEMPO; int tempo_anim = TEMPO;
uint8_t gHue = 0; // rotating "base color" uint8_t gHue = 0; // rotating "base color"
boolean run_mod = false; // run mode boolean run_mod = false; // run mode
Button button1(BTN_PIN, PULLUP, 3000); Button button1(BTN_PIN, PULLUP, 3000);
@ -66,13 +66,13 @@ void xmas(uint8_t wait){
delay(wait); delay(wait);
} }
} }
// change run_mod retur true si appuis cour // change run_mod return true si appuis cour
boolean check_button(){ boolean check_button(){
if (button1.checkPress() == 1) { if (button1.checkPress() == 1) {
// SHORT PRESS! // SHORT PRESS!
if (!run_mod){ if (!run_mod){
run_mod = true; run_mod = true;
} }
return true; return true;
} else if (button1.checkPress() == -1) { } else if (button1.checkPress() == -1) {
// LONG PRESS! // LONG PRESS!
@ -91,13 +91,31 @@ void setup()
} }
void loop() void loop()
// put your main code here, to run repeatedly:
{ {
boolean breaked =false;
if (run_mod){ if (run_mod){
// put your main code here, to run repeatedly:
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
colorWipe_up(CRGB::Red, tempo_anim); for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Red;
FastSPI_LED.show();
delay(tempo_anim);
if (check_button()) {
breaked =true;
break;
}
}
delay(tempo_anim); delay(tempo_anim);
colorWipe_up(CRGB::Green, tempo_anim); for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Green;
FastSPI_LED.show();
delay(tempo_anim);
if (check_button()){
breaked =true;
break;
}
}
delay(tempo_anim); delay(tempo_anim);
if (breaked) break; if (breaked) break;
if (check_button()) break; if (check_button()) break;
@ -113,11 +131,24 @@ if (run_mod){
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
xmas( tempo_anim); xmas( tempo_anim);
if (check_button()) break; if (check_button()) break;
} }
}
if (run_mod){
int i =1;
int j= 0;
black_out();
for (int k = 0; k < NUM_LEDS*10 ; k++) {
leds[j] = CRGB::Red;
FastSPI_LED.show();
delay(tempo_anim/2);
leds[j] = CRGB::Black;
j= j+i;
if(j==NUM_LEDS- 1|| j==0) i= -i;
if (check_button()) break;
}
} }
check_button(); check_button();
black_out(); black_out();
// delay(tempo_anim); // delay(tempo_anim);
} }

Loading…
Cancel
Save