123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- /*TODO
- * Fastled and sd reading ?
- * stop state
- * stop running state
- * fade leds
- */
- #include <Eventually.h>
- #include "Adafruit_TLC59711.h"
- #include <SD.h>
- #include <SPI.h>
- #include <Tsunami.h>
- #include <FadeLed.h>
- //#include <OctoWS2811.h>
- #include "FastLED.h"
- const int BUTTON_PIN[10] = {30, 31, 32, 33, 34, 35, 36, 37, 38, 39} ;
- int currentButton ;
- // TLC59711
- #define NUM_TLC59711 1
- #define data 28
- #define clock 27
- Adafruit_TLC59711 tlc = Adafruit_TLC59711(NUM_TLC59711, clock, data);
- uint32_t ledState[12] ;
- // SD card
- File btnFile ;
- String buf;
- boolean SDfound;
- //Tsunami wav player
- Tsunami tsunami;
- int gNumTracks; // Number of tracks on SD card
- char gTsunamiVersion[VERSION_STRING_LEN]; // Tsunami version string
- //Eventually pointers to manage creation/deletion of listeners
- EvtManager mgr;
- EvtListener *pSD; // identified listener for non-blocking file reading
- EvtListener *pDelay ;
- //delay
- int delay_start ;
- unsigned long delay_length ;
- bool inibSDreading = true;
- bool delay_flag ; //prevent first event to fire
- //Dimmer
- #define DIMMER_PIN 9
- FadeLed dimmer(DIMMER_PIN);
- // FastLED
- #define NUM_LEDS_LUSTRE 240
- CRGB lustreLeds[NUM_LEDS_LUSTRE];
- byte lustre_currentBrightness ; //for fading
- byte lustre_targetBrightness ;
- int lustre_stepBrightness;
- CRGBPalette16 lustre_currentPalette( CRGB::Blue);
- CRGBPalette16 lustre_targetPalette( CRGB::Red );
- #define NUM_LEDS_TABLE 50
- CRGB tableLeds[NUM_LEDS_TABLE];
- byte table_currentBrightness ;
- byte table_targetBrightness ;
- int table_stepBrightness;
- CRGBPalette16 table_currentPalette( CRGB::Pink);
- CRGBPalette16 table_targetPalette( CRGB::Blue );
- // FastLED Palettes
- CRGBPalette16 TIGER_DOWN_MER (CRGB::DarkBlue);
- CRGBPalette16 SOLEIL (CRGB::Orange);
- CRGBPalette16 CREPUSCULE (CRGB::YellowGreen);
- CRGBPalette16 FLAMINGO (CRGB::LightCoral);
- //Functions prototypes
- void EvtResetButtonContext ();
- void tlcWrite();
- void buttonFocus(int);
- //////////////////////// SETUP /////////////////////////////////
- void setup() {
- Serial.begin(9600);
- // TLC
- tlc.begin();
- tlc.write();
- // SD
- Serial.println("Lecture carte SD");
- if (SDfound == 0) {
- if (!SD.begin(BUILTIN_SDCARD)) {
- Serial.print("The SD card cannot be found");
- while(1);
- }
- }
- SDfound = 1;
- // DIMMER
- dimmer.off();
- // LEDS
- FastLED.addLeds<NEOPIXEL, 2>(lustreLeds, NUM_LEDS_LUSTRE);
- FastLED.addLeds<NEOPIXEL, 14>(tableLeds, NUM_LEDS_TABLE);
-
- // TSUNAMI
- // We should wait for the Tsunami to finish reset
- Serial.println("Demarrage du Tsunami wav player");
- delay(1000);
- tsunami.start();
- delay(10);
- tsunami.stopAllTracks();
- tsunami.samplerateOffset(0, 0);
- tsunami.setReporting(true);
- delay(100);
- if (tsunami.getVersion(gTsunamiVersion, VERSION_STRING_LEN)) {
- Serial.print(gTsunamiVersion);
- Serial.print("\n");
- gNumTracks = tsunami.getNumTracks();
- Serial.print("Number of tracks = ");
- Serial.print(gNumTracks);
- Serial.print("\n");
- }
- else
- Serial.print("WAV Trigger response not available");
-
- tsunami.setReporting(false);
-
-
-
- //Set button pins as input
- for (int i ; i < sizeof(BUTTON_PIN)/sizeof(int) ; i++) {
- pinMode(BUTTON_PIN[i],INPUT_PULLUP) ;
- }
- //EvtResetButtonContext();
- Serial.println();
- Serial.println();
- Serial.println("Demarrage termine, activation etat 0");
- // btnFile = SD.open("button0.txt");
- // while(!btnFile.available()){
- // Serial.println("bah alors");
- // }
- delay (3000) ;
-
- buttonFocus(0) ;
- // EvtResetButtonContext ();
-
- }
- ///////////////////////////// LOOP //////////////////////////////////
- USE_EVENTUALLY_LOOP(mgr) // Use this instead of your loop() function.
- //void loop() {
- // mgr.loopIteration();
- // //updateAll();
- //}
|