From 96774b77a82aeda38ff66c304f5d44e92d187113 Mon Sep 17 00:00:00 2001 From: JbLb Date: Tue, 7 Dec 2021 09:35:14 +0100 Subject: [PATCH] implementation controle par BP --- src/CycloTiny85.ino | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/CycloTiny85.ino b/src/CycloTiny85.ino index d283527..0d067c9 100644 --- a/src/CycloTiny85.ino +++ b/src/CycloTiny85.ino @@ -14,8 +14,9 @@ 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" +boolean run_mod = false; // run mode -Button button1(BTN_PIN, PULLUP, 5000); +Button button1(BTN_PIN, PULLUP, 3000); void colorWipe_up(struct CRGB rgb, uint8_t wait) @@ -55,38 +56,49 @@ void dual_color(struct CRGB color1, struct CRGB color2, uint8_t wait) delay(wait); } } - - +boolean check_button(){ + if (button1.checkPress() == 1) { + run_mod = true; // Serial.println("SHORT PRESS!"); + } else if (button1.checkPress() == -1) { + black_out(); + run_mod = false; + // Serial.println("LONG PRESS!"); + } + return run_mod; +} void setup() { // put your setup code here, to run once: FastLED.addLeds < WS2812B, DATA_PIN, GRB > (leds, NUM_LEDS); FastLED.setBrightness(BRIGHTNESS); + black_out(); } void loop() { - +if (run_mod){ // put your main code here, to run repeatedly: for (int i = 0; i < 10; i++) { colorWipe_up(CRGB::Red, tempo_anim); - delay(100); + delay(tempo_anim); colorWipe_up(CRGB::Green, tempo_anim); delay(tempo_anim); + if (!check_button()) break; } +} +if (run_mod) { //dual_color( CRGB::LightGreen,CRGB::Aqua,tempo_anim); // dual_color( CRGB::Aqua,CRGB::LightGreen,tempo_anim); for (int i = 0; i < 10; i++) { dual_color(CRGB::Red, CRGB::Green, tempo_anim); // dual_color( CRGB::Green,CRGB::Red,tempo_anim); + if (!check_button()) break; } + } + check_button(); black_out(); delay(tempo_anim); - - if (button1.checkPress() == 1) { - void (); // Serial.println("SHORT PRESS!"); - } else if (button1.checkPress() == -1) { - void (); // Serial.println("LONG PRESS!"); - } } + +