Wiki

Reso-nance numérique | Arts et cultures libres

Outils du site


projets:artdevivre:accueil

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
Dernière révision Les deux révisions suivantes
projets:artdevivre:accueil [2019/12/18 17:35]
laurent [code]
projets:artdevivre:accueil [2019/12/18 17:54]
laurent [Photos]
Ligne 36: Ligne 36:
 Le code du projet peut être consulté ci-dessous : Le code du projet peut être consulté ci-dessous :
 ++++ arduinoLeonardo.ino| ++++ arduinoLeonardo.ino|
-<code cpp>//#define SERIAL +<code cpp>//#define CALIBRATION 
-#if !defined(SERIAL)+#ifndef CALIBRATION
   #include "MIDIUSB.h"   #include "MIDIUSB.h"
 #endif #endif
Ligne 67: Ligne 67:
 }; };
  
-digital digitals[] = { {"A0", 33, 2, true, DEBOUNCE, 0}, {"F0", 29, 3, true, DEBOUNCE, 0}, {"D0", 26, 4, true, DEBOUNCE, 0}, {"G0", 31, 5, true, DEBOUNCE, 0}, +digital digitals[] = { {"A0", 33, 2, true, DEBOUNCE, 0}, {"F0", 29, 3, true, DEBOUNCE, 0}, 
-                       {"E0", 28, 6, true, DEBOUNCE, 0}, {"B0", 35, 7, true, DEBOUNCE, 0}, {"C0", 24, 8, true, DEBOUNCE, 0}, {"Bb0", 34, 9, true, DEBOUNCE, 0},};+                       {"D0", 26, 4, true, DEBOUNCE, 0}, {"G0", 31, 5, true, DEBOUNCE, 0}, 
 +                       {"E0", 28, 6, true, DEBOUNCE, 0}, {"B0", 35, 7, true, DEBOUNCE, 0}, 
 +                       {"C0", 24, 8, true, DEBOUNCE, 0}, {"Bb0", 34, 9, true, DEBOUNCE, 0},}; 
 +                       
 unsigned int digitalsCount = sizeof(digitals)/sizeof(digital); unsigned int digitalsCount = sizeof(digitals)/sizeof(digital);
  
Ligne 81: Ligne 84:
     analogs[i].currentValue = map(analogRead(analogs[i].pin), analogs[i].calibMin, analogs[i].calibMax, 0, 127);     analogs[i].currentValue = map(analogRead(analogs[i].pin), analogs[i].calibMin, analogs[i].calibMax, 0, 127);
   }   }
-  #if defined(SERIAL)+  #ifdef CALIBRATION
     Serial.begin(115200);     Serial.begin(115200);
     delay(100);     delay(100);
Ligne 96: Ligne 99:
     //if (analogs[i].lastValue != analogs[i].currentValue) {     //if (analogs[i].lastValue != analogs[i].currentValue) {
       if (analogs[i].lastValue < analogs[i].currentValue - analogs[i].deadBand || analogs[i].lastValue > analogs[i].currentValue + analogs[i].deadBand) {       if (analogs[i].lastValue < analogs[i].currentValue - analogs[i].deadBand || analogs[i].lastValue > analogs[i].currentValue + analogs[i].deadBand) {
-        #if defined(SERIAL)+        #ifdef CALIBRATION
           Serial.println(analogs[i].name + ": RAW"+String(analogRead(analogs[i].pin))+", SCALED : "+ String(analogs[i].currentValue));           Serial.println(analogs[i].name + ": RAW"+String(analogRead(analogs[i].pin))+", SCALED : "+ String(analogs[i].currentValue));
         //analogs[i].lastValue = analogs[i].currentValue;         //analogs[i].lastValue = analogs[i].currentValue;
Ligne 114: Ligne 117:
     // input has been pulled LOW     // input has been pulled LOW
     if (currentState == LOW && digitals[i].lastState == HIGH && millis() - digitals[i].lastTriggered > digitals[i].debounce) {     if (currentState == LOW && digitals[i].lastState == HIGH && millis() - digitals[i].lastTriggered > digitals[i].debounce) {
-      #if defined(SERIAL)  +      #ifdef CALIBRATION 
         Serial.println(digitals[i].name+":ON");         Serial.println(digitals[i].name+":ON");
       #else       #else
Ligne 124: Ligne 127:
     // input has been pulled HIGH     // input has been pulled HIGH
     if (currentState == HIGH && digitals[i].lastState == LOW && millis() - digitals[i].lastTriggered > digitals[i].debounce) {     if (currentState == HIGH && digitals[i].lastState == LOW && millis() - digitals[i].lastTriggered > digitals[i].debounce) {
-      #if defined(SERIAL)+      #ifdef CALIBRATION
         Serial.println(digitals[i].name+":OFF");         Serial.println(digitals[i].name+":OFF");
       #else       #else
Ligne 133: Ligne 136:
     digitals[i].lastState = currentState;     digitals[i].lastState = currentState;
   }   }
-  #if !defined(SERIAL)+  #ifndef CALIBRATION
     MidiUSB.flush();     MidiUSB.flush();
   #endif   #endif
Ligne 139: Ligne 142:
 } }
  
-#if !defined(SERIAL)+#ifndef CALIBRATION
   void noteOn(byte pitch, byte velocity) {   void noteOn(byte pitch, byte velocity) {
     midiEventPacket_t noteOn = {0x09, 0x90 | CHANNEL, pitch, velocity};     midiEventPacket_t noteOn = {0x09, 0x90 | CHANNEL, pitch, velocity};
/home/resonancg/www/wiki/data/pages/projets/artdevivre/accueil.txt · Dernière modification: 2019/12/19 15:05 de laurent