From 1d34681c40cff8831a07b72127c63a4916c42f47 Mon Sep 17 00:00:00 2001 From: Johan Berglund Date: Mon, 15 Jul 2019 07:51:44 +0200 Subject: [PATCH] EXTRAS menu page added, with items LEGACY PB, LEGACY BR, GATE HOLD and SPECIAL KEY to enable/disable these special functions. --- NuEVI/NuEVI.ino | 135 +++++++++++++++++++++++++++--------------------- NuEVI/config.h | 2 +- NuEVI/globals.h | 6 ++- NuEVI/menu.cpp | 73 +++++++++++++++++++++++++- NuEVI/menu.h | 1 + 5 files changed, 154 insertions(+), 63 deletions(-) diff --git a/NuEVI/NuEVI.ino b/NuEVI/NuEVI.ino index f562b9d..55378eb 100644 --- a/NuEVI/NuEVI.ino +++ b/NuEVI/NuEVI.ino @@ -81,6 +81,9 @@ uint16_t rotations[4]; // semitones { -5, -10, -7, -14 }; uint16_t parallel; // = 7; // semitones byte gateOpen = 0; // setting for gate always open, note on sent for every time fingering changes, no matter the breath status +uint16_t gateOpenEnable = 0; + +uint16_t specialKeyEnable = 0; int touch_Thr = 1300; @@ -109,8 +112,8 @@ byte activeMIDIchannel; // MIDI channel byte activePatch=0; byte doPatchUpdate=0; -byte legacy = 0; -byte legacyBrAct = 0; +uint16_t legacy = 0; +uint16_t legacyBrAct = 0; byte halfTime = 0; boolean programonce = false; byte slowMidi = 0; @@ -350,6 +353,8 @@ void setup() { legacy = dipSwBits & (1<<1); legacyBrAct = dipSwBits & (1<<2); slowMidi = dipSwBits & (1<<3); + gateOpenEnable = dipSwBits & (1<<4); + specialKeyEnable = dipSwBits & (1<<5); activePatch = patch; touch_Thr = map(ctouchThrVal,ctouchHiLimit,ctouchLoLimit,ttouchLoLimit,ttouchHiLimit); @@ -558,47 +563,54 @@ void loop() { if (analogRead(breathSensorPin) > (breathCalZero - 800)) programonce = false; - specialKey = (touchRead(specialKeyPin) > touch_Thr); //S2 on pcb - if (lastSpecialKey != specialKey) { - if (specialKey) { - // special key just pressed, check other keys - if (K4) { - if (!slurSustain) { - slurSustain = 1; - parallelChord = 0; - rotatorOn = 0; - } else slurSustain = 0; - } - if (K5) { - if (!parallelChord) { - parallelChord = 1; - slurSustain = 0; - rotatorOn = 0; - } else parallelChord = 0; - } - if (K1) { - if (!subOctaveDouble) { - subOctaveDouble = 1; - rotatorOn = 0; - } else subOctaveDouble = 0; - } - if (!K1 && !K4 && !K5) { - slurSustain = 0; - parallelChord = 0; - subOctaveDouble = 0; - rotatorOn = 0; - } - if (pinkyKey) { - if (!rotatorOn) { - rotatorOn = 1; + if (specialKeyEnable) { + specialKey = (touchRead(specialKeyPin) > touch_Thr); //S2 on pcb + if (lastSpecialKey != specialKey) { + if (specialKey) { + // special key just pressed, check other keys + if (K4) { + if (!slurSustain) { + slurSustain = 1; + parallelChord = 0; + rotatorOn = 0; + } else slurSustain = 0; + } + if (K5) { + if (!parallelChord) { + parallelChord = 1; + slurSustain = 0; + rotatorOn = 0; + } else parallelChord = 0; + } + if (K1) { + if (!subOctaveDouble) { + subOctaveDouble = 1; + rotatorOn = 0; + } else subOctaveDouble = 0; + } + if (!K1 && !K4 && !K5) { slurSustain = 0; parallelChord = 0; subOctaveDouble = 0; - } else rotatorOn = 0; + rotatorOn = 0; + } + if (pinkyKey) { + if (!rotatorOn) { + rotatorOn = 1; + slurSustain = 0; + parallelChord = 0; + subOctaveDouble = 0; + } else rotatorOn = 0; + } } } + lastSpecialKey = specialKey; + } else { + rotatorOn = 0; + slurSustain = 0; + parallelChord = 0; + subOctaveDouble = 0; } - lastSpecialKey = specialKey; } else if (mainState == RISE_WAIT) { if ((pressureSensor > breathThrVal) || gateOpen) { // Has enough time passed for us to collect our second @@ -1012,29 +1024,34 @@ void doorKnobCheck() { for (byte i = 0; i < 12; i++) { touchValue[i] = touchSensor.filteredData(i); } - 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(statusLedPin, LOW); - delay(50); - digitalWrite(statusLedPin, HIGH); - delay(50); - } else if (pbDn > ((pitchbMaxVal + pitchbThrVal) / 2)) { - gateOpen = 0; - midiPanic(); - digitalWrite(statusLedPin, LOW); - delay(50); - digitalWrite(statusLedPin, HIGH); - delay(50); - digitalWrite(statusLedPin, LOW); - delay(50); - digitalWrite(statusLedPin, HIGH); - delay(50); - digitalWrite(statusLedPin, LOW); - delay(50); - digitalWrite(statusLedPin, HIGH); - delay(700); + if (gateOpenEnable){ + if ((touchValue[K4Pin] < ctouchThrVal) && (touchValue[R1Pin] < ctouchThrVal) && (touchValue[R2Pin] < ctouchThrVal) && (touchValue[R3Pin] < ctouchThrVal)) { // doorknob grip on canister + if (!gateOpen && (pbUp > ((pitchbMaxVal + pitchbThrVal) / 2))) { + gateOpen = 1; + digitalWrite(statusLedPin, LOW); + delay(50); + digitalWrite(statusLedPin, HIGH); + delay(50); + } else if (gateOpen && (pbDn > ((pitchbMaxVal + pitchbThrVal) / 2))) { + gateOpen = 0; + midiPanic(); + digitalWrite(statusLedPin, LOW); + delay(50); + digitalWrite(statusLedPin, HIGH); + delay(50); + digitalWrite(statusLedPin, LOW); + delay(50); + digitalWrite(statusLedPin, HIGH); + delay(50); + digitalWrite(statusLedPin, LOW); + delay(50); + digitalWrite(statusLedPin, HIGH); + delay(700); + } } + } else if (gateOpen) { + gateOpen = 0; + midiPanic(); } } diff --git a/NuEVI/config.h b/NuEVI/config.h index a4172e6..ace77cf 100644 --- a/NuEVI/config.h +++ b/NuEVI/config.h @@ -5,7 +5,7 @@ // Compile options, comment/uncomment to change -#define FIRMWARE_VERSION "1.3.6" // FIRMWARE VERSION NUMBER HERE <<<<<<<<<<<<<<<<<<<<<<< +#define FIRMWARE_VERSION "1.3.7" // FIRMWARE VERSION NUMBER HERE <<<<<<<<<<<<<<<<<<<<<<< //#define CASSIDY diff --git a/NuEVI/globals.h b/NuEVI/globals.h index dd42168..da5c789 100644 --- a/NuEVI/globals.h +++ b/NuEVI/globals.h @@ -61,6 +61,8 @@ extern unsigned short vibRetn; // vibrato return speed extern unsigned short vibSquelch; //vibrato signal squelch extern unsigned short vibDirection; //direction of first vibrato wave UPWD or DNWD extern unsigned short fastPatch[7]; +extern uint16_t gateOpenEnable; +extern uint16_t specialKeyEnable; extern byte rotatorOn; extern byte currentRotation; extern uint16_t rotations[4]; @@ -73,8 +75,8 @@ extern unsigned long cursorBlinkTime; // the last time the cursor was t extern byte activePatch; extern byte doPatchUpdate; -extern byte legacy; -extern byte legacyBrAct; +extern uint16_t legacy; +extern uint16_t legacyBrAct; extern byte slowMidi; diff --git a/NuEVI/menu.cpp b/NuEVI/menu.cpp index 4615983..9bcd67a 100644 --- a/NuEVI/menu.cpp +++ b/NuEVI/menu.cpp @@ -19,7 +19,7 @@ enum CursorIdx { EControl, ERotator, EVibrato, - + EExtras, // NEVER ADD ANYTHING AFTER THIS, ONLY ABOVE NUM_CURSORS }; @@ -449,6 +449,72 @@ static void midiCustomDrawFunc(SubMenuRef __unused, char* __unused, const char** } } + +//*********************************************************** + +const MenuEntrySub legacyPBMenu = { + MenuType::ESub, "LEGACY PB", "LEGACY PB", &legacy, 0, 1, MenuEntryFlags::EMenuEntryWrap, + [](SubMenuRef __unused, char* out, const char ** __unused unit) { + strncpy(out, legacy?"ON":"OFF", 4); + }, [](const MenuEntrySub & __unused sub) { + dipSwBits = dipSwBits & ~(1<<1); + dipSwBits |= (legacy <<1); + writeSetting(DIPSW_BITS_ADDR,dipSwBits); + } + , nullptr +}; + +const MenuEntrySub legacyBRMenu = { + MenuType::ESub, "LEGACY BR", "LEGACY BR", &legacyBrAct, 0, 1, MenuEntryFlags::EMenuEntryWrap, + [](SubMenuRef __unused, char* out, const char ** __unused unit) { + strncpy(out, legacyBrAct?"ON":"OFF", 4); + }, [](const MenuEntrySub & __unused sub) { + dipSwBits = dipSwBits & ~(1<<2); + dipSwBits |= (legacyBrAct <<2); + writeSetting(DIPSW_BITS_ADDR,dipSwBits); + } + , nullptr +}; + +const MenuEntrySub gateOpenMenu = { + MenuType::ESub, "GATE HOLD", "GATE HOLD", &gateOpenEnable, 0, 1, MenuEntryFlags::EMenuEntryWrap, + [](SubMenuRef __unused, char* out, const char ** __unused unit) { + strncpy(out, gateOpenEnable?"ON":"OFF", 4); + }, [](const MenuEntrySub & __unused sub) { + dipSwBits = dipSwBits & ~(1<<4); + dipSwBits |= (gateOpenEnable <<4); + writeSetting(DIPSW_BITS_ADDR,dipSwBits); + } + , nullptr +}; + +const MenuEntrySub specialKeyMenu = { + MenuType::ESub, "SPEC KEY", "SPEC KEY", &specialKeyEnable, 0, 1, MenuEntryFlags::EMenuEntryWrap, + [](SubMenuRef __unused, char* out, const char ** __unused unit) { + strncpy(out, specialKeyEnable?"ON":"OFF", 4); + }, [](const MenuEntrySub & __unused sub) { + dipSwBits = dipSwBits & ~(1<<5); + dipSwBits |= (specialKeyEnable <<5); + writeSetting(DIPSW_BITS_ADDR,dipSwBits); + } + , nullptr +}; + +const MenuEntry* extrasMenuEntries[] = { + (MenuEntry*)&legacyPBMenu, + (MenuEntry*)&legacyBRMenu, + (MenuEntry*)&gateOpenMenu, + (MenuEntry*)&specialKeyMenu, +}; + +const MenuPage extrasMenuPage = { + "EXTRAS", + 0, + CursorIdx::EExtras, + MAIN_MENU, + ARR_LEN(extrasMenuEntries), extrasMenuEntries +}; + static bool midiEnterHandlerFunc() { readSwitches(); if (pinkyKey){ @@ -470,6 +536,7 @@ const MenuEntrySub midiMenu = { const MenuEntryStateCh adjustMenu = { MenuType::EStateChange, "ADJUST", ADJUST_MENU }; const MenuEntryStateCh breathMenu = { MenuType::EStateChange, "SETUP BR", SETUP_BR_MENU }; const MenuEntryStateCh controlMenu = { MenuType::EStateChange, "SETUP CTL", SETUP_CT_MENU }; +const MenuEntryStateCh extrasMenu = { MenuType::EStateChange, "EXTRAS", EXTRAS_MENU }; const MenuEntryStateCh aboutMenu = { MenuType::EStateChange, "ABOUT", ABOUT_MENU }; const MenuEntry* mainMenuEntries[] = { @@ -479,6 +546,7 @@ const MenuEntry* mainMenuEntries[] = { (MenuEntry*)&adjustMenu, (MenuEntry*)&breathMenu, (MenuEntry*)&controlMenu, + (MenuEntry*)&extrasMenu, (MenuEntry*)&aboutMenu, }; @@ -825,6 +893,7 @@ const MenuPage vibratoMenuPage = { "VIBRATO", 0, CursorIdx::EVibrato, SETUP_CT_MENU, ARR_LEN(vibratorMenuEntries), vibratorMenuEntries }; + //*********************************************************** static bool patchPageUpdate(KeyState& __unused input, uint32_t __unused timeNow); @@ -1337,6 +1406,8 @@ void menu() { redraw |= updatePage(&vibratoMenuPage, input, timeNow); } else if (menuState == ABOUT_MENU) { redraw |= updatePage((const MenuPage*)&aboutMenuPage, input, timeNow); + } else if (menuState == EXTRAS_MENU) { + redraw |= updatePage((const MenuPage*)&extrasMenuPage, input, timeNow); } if(redraw) { diff --git a/NuEVI/menu.h b/NuEVI/menu.h index c98e75b..93567a8 100644 --- a/NuEVI/menu.h +++ b/NuEVI/menu.h @@ -18,6 +18,7 @@ #define ROTATOR_MENU 6 #define VIBRATO_MENU 7 #define ABOUT_MENU 8 +#define EXTRAS_MENU 9 #define ARR_LEN(a) (sizeof (a) / sizeof (a[0]))