Use defines instead of hardcoded pin numbers

Also automatic "dangling whitespace" cleanup
This commit is contained in:
John Stäck 2018-09-03 14:54:38 +02:00
parent 150290a9cb
commit 9411bc7d58

View file

@ -48,6 +48,7 @@ PROGRAMME FUNCTION: EVI Wind Controller using the Freescale MP3V5004GP breath
#define bLedPin 10
#define pLedPin 9
#define statusLedPin 13
#define vMeterPin A11
@ -583,7 +584,7 @@ void setup() {
pinMode(bLedPin, OUTPUT); // breath indicator LED
pinMode(pLedPin, OUTPUT); // portam indicator LED
pinMode(13,OUTPUT); // Teensy onboard LED
pinMode(statusLedPin,OUTPUT); // Teensy onboard LED
// if stored settings are not for current version, or Enter+Menu are pressed at startup, they are replaced by factory settings
@ -714,29 +715,29 @@ void setup() {
display.display();
//auto-calibrate the vibrato threshold while showing splash screen
int cv1=touchRead(15);
int cv1=touchRead(vibratoPin);
int bc1=analogRead(A0);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
delay(250);
int cv2=touchRead(15);
int cv2=touchRead(vibratoPin);
int bc2=analogRead(A0);
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(250);
int cv3=touchRead(15);
int cv3=touchRead(vibratoPin);
int bc3=analogRead(A0);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
delay(250);
digitalWrite(13,LOW);
int cv4=touchRead(15);
digitalWrite(statusLedPin,LOW);
int cv4=touchRead(vibratoPin);
int bc4=analogRead(A0);
vibZero=(cv1+cv2+cv3+cv4)/4;
vibThr=vibZero-vibSquelch;
vibThrLo=vibZero+vibSquelch;
breathCalZero=(bc1+bc2+bc3+bc4)/4;
delay(250);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
delay(250);
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(85,52);
@ -756,7 +757,7 @@ void setup() {
Serial3.begin(31250); // start serial with midi baudrate 31250
Serial3.flush();
digitalWrite(13,HIGH); // Switch on the onboard LED to indicate power on/ready
digitalWrite(statusLedPin,HIGH); // Switch on the onboard LED to indicate power on/ready
}
@ -798,35 +799,35 @@ void mainLoop() {
if (exSensor >= ((extracThrVal+extracMaxVal)/2)){ // instant midi setting
if ((fingeredNoteUntransposed >= 73) && (fingeredNoteUntransposed <= 88)) {
MIDIchannel = fingeredNoteUntransposed - 72; // Mid C and up
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(150);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
}
} else {
if (!pinkyKey){ // note number to patch number
if (patch != fingeredNoteUntransposed){
patch = fingeredNoteUntransposed;
doPatchUpdate = 1;
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(150);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
}
} else { // hi and lo patch numbers
if (fingeredNoteUntransposed > 75){
if (patch != patchLimit(fingeredNoteUntransposed + 24)){
patch = patchLimit(fingeredNoteUntransposed + 24); // add 24 to get high numbers 108 to 127
doPatchUpdate = 1;
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(150);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
}
} else {
if (patch != patchLimit(fingeredNoteUntransposed - 36)){
patch = patchLimit(fingeredNoteUntransposed - 36); // subtract 36 to get low numbers 0 to 36
doPatchUpdate = 1;
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(150);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
}
}
}
@ -1417,10 +1418,10 @@ void pitch_bend(){
pitchBend=constrain(pitchBend, 0, 16383);
if (subVibSquelch && (8192 != pitchBend)){
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
vibLedOff = 1;
} else if (vibLedOff){
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
vibLedOff = 0;
}
@ -1445,25 +1446,25 @@ void doorKnobCheck(){
if ((touchValue[K4Pin] < ctouchThrVal) && (touchValue[R1Pin] < ctouchThrVal) && (touchValue[R2Pin] < ctouchThrVal) && (touchValue[R3Pin] < ctouchThrVal)){ // doorknob grip on canister
if (pbUp > ((pitchbMaxVal + pitchbThrVal)/2)) {
gateOpen = 1;
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(50);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
delay(50);
}
else if (pbDn > ((pitchbMaxVal + pitchbThrVal)/2)) {
gateOpen = 0;
midiPanic();
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(50);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
delay(50);
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(50);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
delay(50);
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(50);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
delay(700);
}
}
@ -1787,24 +1788,24 @@ void menu() {
legacyBrAct = !legacyBrAct;
dipSwBits = dipSwBits ^ (1<<2);
writeSetting(DIPSW_BITS_ADDR,dipSwBits);
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(150);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
delay(150);
digitalWrite(13,LOW);
digitalWrite(statusLedPin, LOW);
delay(150);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
} else if ((exSensor >= ((extracThrVal+extracMaxVal)/2))){ // switch pb pad activated legacy settings control on/off
legacy = !legacy;
dipSwBits = dipSwBits ^ (1<<1);
writeSetting(DIPSW_BITS_ADDR,dipSwBits);
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(150);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
delay(150);
digitalWrite(13,LOW);
digitalWrite(statusLedPin,LOW);
delay(150);
digitalWrite(13,HIGH);
digitalWrite(statusLedPin,HIGH);
} else if (pinkyKey){
display.ssd1306_command(SSD1306_DISPLAYON);
state = ROTATOR_MENU;