Merge pull request #2 from Trasselfrisyr/various-cleanup
Various cleanup
This commit is contained in:
commit
205689dbdf
1 changed files with 411 additions and 402 deletions
133
NuEVI.ino
133
NuEVI.ino
|
@ -22,9 +22,11 @@ PROGRAMME FUNCTION: EVI Wind Controller using the Freescale MP3V5004GP breath
|
|||
|
||||
// Compile options, comment/uncomment to change
|
||||
|
||||
#define FIRMWARE_VERSION "1.2.6" // FIRMWARE VERSION NUMBER HERE <<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
#define REVB
|
||||
|
||||
//Uncomment the following line if you have Teensyduino 1.4.1 or later, to make pitch bend over USB-MIDI work.
|
||||
//Uncomment the following line if you have Teensyduino 1.4.0 or earlier, to make pitch bend over USB-MIDI work.
|
||||
#define NEWTEENSYDUINO
|
||||
|
||||
|
||||
|
@ -41,6 +43,8 @@ PROGRAMME FUNCTION: EVI Wind Controller using the Freescale MP3V5004GP breath
|
|||
#define pbDnPin 22
|
||||
#define vibratoPin 15
|
||||
|
||||
#define breathSensorPin A0
|
||||
|
||||
#define dPin 3
|
||||
#define ePin 4
|
||||
#define uPin 5
|
||||
|
@ -48,6 +52,7 @@ PROGRAMME FUNCTION: EVI Wind Controller using the Freescale MP3V5004GP breath
|
|||
|
||||
#define bLedPin 10
|
||||
#define pLedPin 9
|
||||
#define statusLedPin 13
|
||||
|
||||
#define vMeterPin A11
|
||||
|
||||
|
@ -250,8 +255,6 @@ PROGRAMME FUNCTION: EVI Wind Controller using the Freescale MP3V5004GP breath
|
|||
#define OLED_RESET 4
|
||||
Adafruit_SSD1306 display(OLED_RESET);
|
||||
|
||||
#define LOGO16_GLCD_HEIGHT 16
|
||||
#define LOGO16_GLCD_WIDTH 16
|
||||
|
||||
// 'NuEVI' logo
|
||||
static const unsigned char PROGMEM nuevi_logo_bmp[] = {
|
||||
|
@ -321,8 +324,8 @@ static const unsigned char PROGMEM nuevi_logo_bmp[] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#if (SSD1306_LCDHEIGHT != 64)
|
||||
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
|
||||
#ifndef SSD1306_128_64
|
||||
#error("Incorrect display type, please fix Adafruit_SSD1306.h!");
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -583,24 +586,11 @@ 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
|
||||
|
||||
if ((readSetting(VERSION_ADDR) != VERSION) && (readSetting(VERSION_ADDR) < 24) || (!digitalRead(ePin) && !digitalRead(mPin))){
|
||||
writeSetting(VERSION_ADDR,VERSION);
|
||||
writeSetting(BREATH_THR_ADDR,BREATH_THR_FACTORY);
|
||||
writeSetting(BREATH_MAX_ADDR,BREATH_MAX_FACTORY);
|
||||
writeSetting(PORTAM_THR_ADDR,PORTAM_THR_FACTORY);
|
||||
writeSetting(PORTAM_MAX_ADDR,PORTAM_MAX_FACTORY);
|
||||
writeSetting(PITCHB_THR_ADDR,PITCHB_THR_FACTORY);
|
||||
writeSetting(PITCHB_MAX_ADDR,PITCHB_MAX_FACTORY);
|
||||
writeSetting(EXTRAC_THR_ADDR,EXTRAC_THR_FACTORY);
|
||||
writeSetting(EXTRAC_MAX_ADDR,EXTRAC_MAX_FACTORY);
|
||||
writeSetting(CTOUCH_THR_ADDR,CTOUCH_THR_FACTORY);
|
||||
}
|
||||
|
||||
if ((readSetting(VERSION_ADDR) != VERSION) || (!digitalRead(ePin) && !digitalRead(mPin))){
|
||||
writeSetting(VERSION_ADDR,VERSION);
|
||||
|
||||
|
@ -638,6 +628,21 @@ void setup() {
|
|||
writeSetting(VIB_RETN_ADDR,VIB_RETN_FACTORY);
|
||||
writeSetting(VIB_SQUELCH_ADDR,VIB_SQUELCH_FACTORY);
|
||||
writeSetting(VIB_DIRECTION_ADDR,VIB_DIRECTION_FACTORY);
|
||||
|
||||
//Set threshold/max sensor values only if upgrading from something before version 24
|
||||
//In other cases, these values are saved between factory resets
|
||||
if (readSetting(VERSION_ADDR) < 24) {
|
||||
writeSetting(VERSION_ADDR,VERSION);
|
||||
writeSetting(BREATH_THR_ADDR,BREATH_THR_FACTORY);
|
||||
writeSetting(BREATH_MAX_ADDR,BREATH_MAX_FACTORY);
|
||||
writeSetting(PORTAM_THR_ADDR,PORTAM_THR_FACTORY);
|
||||
writeSetting(PORTAM_MAX_ADDR,PORTAM_MAX_FACTORY);
|
||||
writeSetting(PITCHB_THR_ADDR,PITCHB_THR_FACTORY);
|
||||
writeSetting(PITCHB_MAX_ADDR,PITCHB_MAX_FACTORY);
|
||||
writeSetting(EXTRAC_THR_ADDR,EXTRAC_THR_FACTORY);
|
||||
writeSetting(EXTRAC_MAX_ADDR,EXTRAC_MAX_FACTORY);
|
||||
writeSetting(CTOUCH_THR_ADDR,CTOUCH_THR_FACTORY);
|
||||
}
|
||||
}
|
||||
// read settings from EEPROM
|
||||
breathThrVal = readSetting(BREATH_THR_ADDR);
|
||||
|
@ -714,33 +719,34 @@ void setup() {
|
|||
display.display();
|
||||
|
||||
//auto-calibrate the vibrato threshold while showing splash screen
|
||||
int cv1=touchRead(15);
|
||||
int bc1=analogRead(A0);
|
||||
digitalWrite(13,HIGH);
|
||||
int cv1=touchRead(vibratoPin);
|
||||
int bc1=analogRead(breathSensorPin);
|
||||
digitalWrite(statusLedPin,HIGH);
|
||||
delay(250);
|
||||
int cv2=touchRead(15);
|
||||
int bc2=analogRead(A0);
|
||||
digitalWrite(13,LOW);
|
||||
int cv2=touchRead(vibratoPin);
|
||||
int bc2=analogRead(breathSensorPin);
|
||||
digitalWrite(statusLedPin,LOW);
|
||||
delay(250);
|
||||
int cv3=touchRead(15);
|
||||
int bc3=analogRead(A0);
|
||||
digitalWrite(13,HIGH);
|
||||
int cv3=touchRead(vibratoPin);
|
||||
int bc3=analogRead(breathSensorPin);
|
||||
digitalWrite(statusLedPin,HIGH);
|
||||
delay(250);
|
||||
digitalWrite(13,LOW);
|
||||
int cv4=touchRead(15);
|
||||
int bc4=analogRead(A0);
|
||||
digitalWrite(statusLedPin,LOW);
|
||||
int cv4=touchRead(vibratoPin);
|
||||
int bc4=analogRead(breathSensorPin);
|
||||
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);
|
||||
display.println("v.1.2.6"); // FIRMWARE VERSION NUMBER HERE <<<<<<<<<<<<<<<<<<<<<<<
|
||||
display.print("v.");
|
||||
display.println(FIRMWARE_VERSION);
|
||||
display.display();
|
||||
|
||||
delay(1500);
|
||||
|
@ -756,7 +762,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
|
||||
|
||||
}
|
||||
|
||||
|
@ -769,7 +775,7 @@ void loop() {
|
|||
void mainLoop() {
|
||||
FilterOnePole breathFilter( LOWPASS, filterFreq ); // create a one pole (RC) lowpass filter
|
||||
while (1){
|
||||
breathFilter.input(analogRead(A0));
|
||||
breathFilter.input(analogRead(breathSensorPin));
|
||||
pressureSensor = constrain((int)breathFilter.output(),0,4095); // Get the filtered pressure sensor reading from analog pin A0, input from sensor MP3V5004GP
|
||||
//pressureSensor = analogRead(A0);
|
||||
//pressureSensor = smooth(analogRead(0), filterVal, smoothedVal); // second parameter determines smoothness - 0 is off, .9999 is max smooth
|
||||
|
@ -798,35 +804,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1186,6 +1192,9 @@ unsigned int breathCurve(unsigned int inputVal){
|
|||
// Z2
|
||||
return multiMap(inputVal,curveIn,curveZ2,17);
|
||||
break;
|
||||
default: //Fallback option that should never be reached, use linear
|
||||
return inputVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1417,10 +1426,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 +1454,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 +1796,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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue