/*TODO * Fastled and sd reading ? * stop state * stop running state * fade leds */ #include #include "Adafruit_TLC59711.h" #include #include #include #include //#include #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 const int audioVolumePin = A21 ; int audioMasterVolume = 0 ; //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 byte refreshRate = 25 ; //Dimmer #define DIMMER_PIN 9 FadeLed dimmer(DIMMER_PIN); int dimmer_value = 15; byte dimmer_low = 20; byte dimmer_mid = 60; byte dimmer_high = 80; bool dimmer_random = false; // activate short-circuit effect int dimmer_move = 7; // FastLED #define NUM_LEDS_LUSTRE 140 CRGB lustreLeds[NUM_LEDS_LUSTRE]; float lustre_currentBrightness = 0; //for fading float lustre_targetBrightness = 0 ; float lustre_stepBrightness = 0; CRGBPalette16 lustre_currentPalette( CRGB::Green); CRGBPalette16 lustre_targetPalette( CRGB::Orange ); #define NUM_LEDS_TABLE 20 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 palette_MER (CRGB::DarkBlue); CRGBPalette16 palette_SOLEIL (CRGB::Orange);; CRGBPalette16 palette_CREPUSCULE (CRGB::Blue); CRGBPalette16 palette_FLAMINGO (CRGB::LightCoral); bool palette_BEAT = false; // activate beat sync palette int paletteBeatStart ; //to resync effect on activation int BPM =120; bool palette_MOVE = true ; int led_move = 80 ; // organic variation around base value //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; readSDconfig(); // DIMMER dimmer.off(); // dimmer.set(percent2PWM(25)); // dimmer.setTime(0, true); // while(!dimmer.done()){FadeLed::update();} // delay(2000); // dimmer.setTime(5000, true); // dimmer.set(percent2PWM(2)); // while(!dimmer.done()){FadeLed::update();} // // LEDS FastLED.addLeds(lustreLeds, NUM_LEDS_LUSTRE); FastLED.addLeds(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) ; EvtResetButtonContext (); buttonFocus(0) ; } ///////////////////////////// LOOP ////////////////////////////////// USE_EVENTUALLY_LOOP(mgr) // Use this instead of your loop() function.