implementation controle par BP

master
JbLb 4 years ago
parent 2378bf05ff
commit 96774b77a8

@ -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!");
}
}

Loading…
Cancel
Save