diff --git a/src/CycloTiny85.ino b/src/CycloTiny85.ino index 807e4d7..4434643 100644 --- a/src/CycloTiny85.ino +++ b/src/CycloTiny85.ino @@ -2,42 +2,42 @@ #include // How many leds in your strip? -#define BRIGHTNESS 96 -#define NUM_LEDS 12 -#define TEMPO 100 +#define BRIGHTNESS 127 +#define NUM_LEDS 90 // 12 +#define TEMPO 25 #define DATA_PIN 0 // led pin #define BTN_PIN 3 // button pin 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 tempo_anim = TEMPO; -uint8_t gHue = 0; // rotating "base color" +// uint8_t gHue = 0; // rotating "base color" boolean run_mod = false; // run mode Button button1(BTN_PIN, PULLUP, 3000); -void colorWipe_up(struct CRGB rgb, uint8_t wait) -{ +// void colorWipe_up(struct CRGB rgb, uint8_t wait) +// { - for (int i = 0; i < NUM_LEDS; i++) { - leds[i] = rgb; - FastSPI_LED.show(); - delay(wait); - } -} +// for (int i = 0; i < NUM_LEDS; i++) { +// leds[i] = rgb; +// FastSPI_LED.show(); +// delay(wait); +// } +// } -void colorWipe_down(struct CRGB rgb, uint8_t wait) -{ +// void colorWipe_down(struct CRGB rgb, uint8_t wait) +// { - for (int i = NUM_LEDS - 1; i >= 0; i--) { - leds[i] = rgb; - FastSPI_LED.show(); - delay(wait); - } -} +// for (int i = NUM_LEDS - 1; i >= 0; i--) { +// leds[i] = rgb; +// FastSPI_LED.show(); +// delay(wait); +// } +// } void black_out() { @@ -46,24 +46,24 @@ void black_out() FastSPI_LED.show(); } -void dual_color(struct CRGB color1, struct CRGB color2, uint8_t wait) -{ - for (int i = 0; i < NUM_LEDS; i++) { - memset(leds, 0, NUM_LEDS * 3); // all leds off - leds[i] = color1; - leds[NUM_LEDS - (i + 1)] = color2; - FastSPI_LED.show(); - delay(wait); - } -} +// void dual_color(struct CRGB color1, struct CRGB color2, uint8_t wait) +// { +// for (int i = 0; i < NUM_LEDS; i++) { +// memset(leds, 0, NUM_LEDS * 3); // all leds off +// leds[i] = color1; +// leds[NUM_LEDS - (i + 1)] = color2; +// FastSPI_LED.show(); +// delay(wait); +// } +// } void xmas(uint8_t wait) { for (int j = 0; j < 2; j++) { for (int i = 0; i < NUM_LEDS; i++) { leds[i] = ((i % 2) == j) ? CRGB::Red : CRGB::Green; - FastSPI_LED.show(); } + FastSPI_LED.show(); delay(wait); } } @@ -114,7 +114,7 @@ void loop() } delay(tempo_anim); for (int i = 0; i < NUM_LEDS; i++) { - leds[i] = CRGB::Green; + leds[NUM_LEDS - (i + 1)] = CRGB::Green; FastSPI_LED.show(); delay(tempo_anim); if (check_button()) { @@ -132,31 +132,45 @@ void loop() } breaked = false; // dual color + // if (run_mod) { + // for (int j = 0; j < 5; j++) { + // for (int i = 0; i < NUM_LEDS; i++) { + // memset(leds, 0, NUM_LEDS * 3); // all leds off + // leds[i] = CRGB::Red; + // leds[NUM_LEDS - (i + 1)] = CRGB::Green; + // FastSPI_LED.show(); + // delay(tempo_anim); + // if (check_button()) { + // breaked = true; + // break; + // } + // } + // if (breaked) + // break; + // } + // } + // breaked = false; +// Xmas if (run_mod) { - for (int i = 0; i < 5; i++) { - for (int i = 0; i < NUM_LEDS; i++) { - memset(leds, 0, NUM_LEDS * 3); // all leds off - leds[i] = CRGB::Red; - leds[NUM_LEDS - (i + 1)] = CRGB::Green; + for (int k = 0; k < 20; k++) { + for (int j = 0; j < 2; j++) { + for (int i = 0; i < NUM_LEDS; i++) { + leds[i] = ((i % 2) == j) ? CRGB::Red : CRGB::Green; + } FastSPI_LED.show(); - delay(tempo_anim); + delay(tempo_anim * 5); if (check_button()) { breaked = true; break; } + if (breaked) + break; } - if (breaked) - break; - } - } -// Xmas - if (run_mod) { - for (int i = 0; i < 20; i++) { - xmas(tempo_anim); - if (check_button()) + if (breaked || check_button()) break; } } + breaked = false; // aller-retour if (run_mod) { int i = 1; @@ -164,9 +178,11 @@ void loop() black_out(); for (int k = 0; k < NUM_LEDS * 10; k++) { leds[j] = CRGB::Red; + leds[NUM_LEDS - (j + 1)] = CRGB::Green; FastSPI_LED.show(); delay(tempo_anim / 2); leds[j] = CRGB::Black; + leds[NUM_LEDS - (j + 1)] = CRGB::Black; j = j + i; if (j == NUM_LEDS - 1 || j == 0) i = -i; @@ -175,6 +191,40 @@ void loop() break; } } + // eteincelles + if (run_mod) { + int led2ligth[10]; + //int l; + for (int j = 0; j < 50; j++) { + int leds4l; + leds4l = random(2, 10); // nombre de leds a allumer + memset(leds, 0, NUM_LEDS * 3); // all leds off + for (int l = 0; l < leds4l; l++) { + led2ligth[l] = random(NUM_LEDS); + leds[led2ligth[l]] = CRGB(255, 255, 255); + } + for (int i = 0; i < 10; i++) { + for (int l = 0; l < leds4l; l++) { + leds[led2ligth[l]].fadeLightBy(25 * i); + FastSPI_LED.show(); + delay(tempo_anim / (10 - i)); + if (check_button()) { + breaked = true; + break; + } + } + if (breaked || check_button()) + break; + } + if (breaked) + break; + if (check_button()) + break; + delay(tempo_anim * random(1, 5)); + } + } + breaked = false; + check_button(); black_out(); // delay(tempo_anim);