From 992c2dbb787485b68d638bb1b6fcbbdcdeb11b14 Mon Sep 17 00:00:00 2001 From: jblb Date: Tue, 7 Dec 2021 16:40:00 +0100 Subject: [PATCH] gestion bp pour changement d'annimation --- src/CycloTiny85.ino | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/CycloTiny85.ino b/src/CycloTiny85.ino index e607949..e265429 100644 --- a/src/CycloTiny85.ino +++ b/src/CycloTiny85.ino @@ -66,15 +66,20 @@ void xmas(uint8_t wait){ delay(wait); } } +// change run_mod retur true si appuis cour boolean check_button(){ if (button1.checkPress() == 1) { - run_mod = true; // Serial.println("SHORT PRESS!"); + // SHORT PRESS! + if (!run_mod){ + run_mod = true; + } + return true; } else if (button1.checkPress() == -1) { + // LONG PRESS! black_out(); run_mod = false; - // Serial.println("LONG PRESS!"); + return false; } - return run_mod; } void setup() @@ -94,24 +99,25 @@ if (run_mod){ delay(tempo_anim); colorWipe_up(CRGB::Green, tempo_anim); delay(tempo_anim); - if (!check_button()) break; + if (breaked) break; + if (check_button()) break; } } if (run_mod) { for (int i = 0; i < 5; i++) { dual_color(CRGB::Red, CRGB::Green, tempo_anim); - if (!check_button()) break; + if (check_button()) break; } } if (run_mod){ for (int i = 0; i < 20; i++) { xmas( tempo_anim); - if (!check_button()) break; + if (check_button()) break; } } check_button(); black_out(); - delay(tempo_anim); + // delay(tempo_anim); }