WIP: le boutton permet de lancer/couper l'animation

This commit is contained in:
Julien Cabillot 2017-08-01 18:05:48 +02:00 committed by Cabillot Julien
parent eb78801b22
commit 8776c1ac52
2 changed files with 26 additions and 7 deletions

View File

@ -4,6 +4,18 @@
#include "ledmask.h" #include "ledmask.h"
/** LEDS **/
/**
* Coupe tout le strip de led.
*/
void ledBlackAll()
{
FastLED.clear();
FastLED.show();
}
/** FIRE2012 **/
/* /*
TODO: à adapter TODO: à adapter
LED attached from pin 13 to ground LED attached from pin 13 to ground
@ -11,7 +23,6 @@
10K resistor attached to pin 2 from ground 10K resistor attached to pin 2 from ground
*/ */
/** FIRE2012 **/
void Fire2012() void Fire2012()
{ {
// Array of temperature readings at each simulation cell // Array of temperature readings at each simulation cell
@ -67,6 +78,8 @@ void setup() {
void loop() { void loop() {
/** BOUTON **/ /** BOUTON **/
// TODO : temporaire car le but est d'appuyer sur le boutton pour lancer/couper les yeux
// pas de rester appuyé dessus
EVERY_N_MILLISECONDS(500) { EVERY_N_MILLISECONDS(500) {
buttonState = digitalRead(BUTTON_PIN); buttonState = digitalRead(BUTTON_PIN);
@ -78,10 +91,14 @@ void loop() {
} }
/** LEDS **/ /** LEDS **/
if (buttonState == HIGH) {
// TODO : il faudra ici conditioner l'animation au fait que le button n'ai pas été pressé // TODO : il faudra ici conditioner l'animation au fait que le button n'ai pas été pressé
// Add entropy to random number generator; we use a lot of it. // Add entropy to random number generator; we use a lot of it.
random16_add_entropy(random()); random16_add_entropy(random());
Fire2012(); // run simulation frame Fire2012(); // run simulation frame
FastLED.show(); // display this frame
FastLED.delay(1000 / LED_FPS); FastLED.delay(1000 / LED_FPS);
} else {
// TODO : ne devrait pas être aussi simple, il faut que les yeux se fadent
ledBlackAll();
}
} }

View File

@ -17,6 +17,8 @@ int buttonState;
const bool gReverseDirection = false; const bool gReverseDirection = false;
CRGB leds[LED_NUM]; CRGB leds[LED_NUM];
void ledBlackAll();
/** FIRE2012 **/ /** FIRE2012 **/
#define COOLING 55 #define COOLING 55
#define SPARKING 120 #define SPARKING 120