diff --git a/NuEVI/NuEVI.ino b/NuEVI/NuEVI.ino index 5a85c5e..43db698 100644 --- a/NuEVI/NuEVI.ino +++ b/NuEVI/NuEVI.ino @@ -8,6 +8,8 @@ #include "hardware.h" #include "midi.h" #include "menu.h" +#include "config.h" +#include "settings.h" /* NAME: NuEVI @@ -21,26 +23,6 @@ PROGRAMME FUNCTION: EVI Wind Controller using the Freescale MP3V5004GP breath */ -//_______________________________________________________________________________________________ DECLARATIONS - -// Compile options, comment/uncomment to change - -#define FIRMWARE_VERSION "1.3.5" // FIRMWARE VERSION NUMBER HERE <<<<<<<<<<<<<<<<<<<<<<< - - -//#define CASSIDY -//#define CVSCALEBOARD - -#define ON_Delay 20 // Set Delay after ON threshold before velocity is checked (wait for tounging peak) -//#define touch_Thr 1200 // sensitivity for Teensy touch sensors -#define CCN_Port 5 // Controller number for portamento level -#define CCN_PortOnOff 65// Controller number for portamento on/off - - -// Send breath CC data no more than every CC_INTERVAL (other CC is sent with double interval) -// milliseconds (due to timing errors, the value should be about half the actual wanted value) -#define CC_INTERVAL 2 - // The three states of our main state machine @@ -56,93 +38,8 @@ PROGRAMME FUNCTION: EVI Wind Controller using the Freescale MP3V5004GP breath #define NOTE_ON 3 -// EEPROM addresses for settings -#define VERSION_ADDR 0 -#define BREATH_THR_ADDR 2 -#define BREATH_MAX_ADDR 4 -#define PORTAM_THR_ADDR 6 -#define PORTAM_MAX_ADDR 8 -#define PITCHB_THR_ADDR 10 -#define PITCHB_MAX_ADDR 12 -#define TRANSP_ADDR 14 -#define MIDI_ADDR 16 -#define BREATH_CC_ADDR 18 -#define BREATH_AT_ADDR 20 -#define VELOCITY_ADDR 22 -#define PORTAM_ADDR 24 -#define PB_ADDR 26 -#define EXTRA_ADDR 28 -#define VIBRATO_ADDR 30 -#define DEGLITCH_ADDR 32 -#define EXTRAC_THR_ADDR 34 -#define EXTRAC_MAX_ADDR 36 -#define PATCH_ADDR 38 -#define OCTAVE_ADDR 40 -#define CTOUCH_THR_ADDR 42 -#define BREATHCURVE_ADDR 44 -#define VEL_SMP_DL_ADDR 46 -#define VEL_BIAS_ADDR 48 -#define PINKY_KEY_ADDR 50 -#define FP1_ADDR 52 -#define FP2_ADDR 54 -#define FP3_ADDR 56 -#define FP4_ADDR 58 -#define FP5_ADDR 60 -#define FP6_ADDR 62 -#define FP7_ADDR 64 -#define DIPSW_BITS_ADDR 66 -#define PARAL_ADDR 68 -#define ROTN1_ADDR 70 -#define ROTN2_ADDR 72 -#define ROTN3_ADDR 74 -#define ROTN4_ADDR 76 -#define PRIO_ADDR 78 -#define VIB_SENS_ADDR 80 -#define VIB_RETN_ADDR 82 -#define VIB_SQUELCH_ADDR 84 -#define VIB_DIRECTION_ADDR 86 - -//"factory" values for settings -#define VERSION 31 -#define BREATH_THR_FACTORY 1400 -#define BREATH_MAX_FACTORY 4000 -#define PORTAM_THR_FACTORY 2600 -#define PORTAM_MAX_FACTORY 3300 -#define PORTPR_THR_FACTORY 1200 -#define PORTPR_MAX_FACTORY 2000 -#define PITCHB_THR_FACTORY 1400 -#define PITCHB_MAX_FACTORY 2300 -#define EXTRAC_THR_FACTORY 1200 -#define EXTRAC_MAX_FACTORY 2400 -#define TRANSP_FACTORY 12 // 12 is 0 transpose -#define MIDI_FACTORY 1 // 1-16 -#define BREATH_CC_FACTORY 2 //thats CC#2, see ccList -#define BREATH_AT_FACTORY 0 //aftertouch default off -#define VELOCITY_FACTORY 0 // 0 is dynamic/breath controlled velocity -#define PORTAM_FACTORY 2 // 0 - OFF, 1 - ON, 2 - SW -#define PB_FACTORY 1 // 0 - OFF, 1 - 12 -#define EXTRA_FACTORY 2 // 0 - OFF, 1 - Modulation wheel, 2 - Foot pedal, 3 - Filter Cutoff, 4 - Sustain pedal -#define VIBRATO_FACTORY 4 // 0 - OFF, 1 - 9 depth -#define DEGLITCH_FACTORY 20 // 0 - OFF, 5 to 70 ms in steps of 5 -#define PATCH_FACTORY 1 // MIDI program change 1-128 -#define OCTAVE_FACTORY 3 // 3 is 0 octave change -#define CTOUCH_THR_FACTORY 125 // MPR121 touch threshold -#define BREATHCURVE_FACTORY 4 // 0 to 12 (-4 to +4, S1 to S4) -#define VEL_SMP_DL_FACTORY 15 // 0 to 30 -#define VEL_BIAS_FACTORY 0 // 0 to 9 -#define PINKY_KEY_FACTORY 12 // 0 - 11 (QuickTranspose -12 to -1), 12 (pb/2), 13 - 22 (QuickTranspose +1 to +12) -#define DIPSW_BITS_FACTORY 0 // virtual dip switch settings for special modes (work in progress) -#define PARAL_FACTORY 31 // 7 (+ 24) Rotator parallel -#define ROTN1_FACTORY 19 // -5 (+24) Rotation 1 -#define ROTN2_FACTORY 14 // -10 (+24) Rotation 2 -#define ROTN3_FACTORY 17 // -7 (+24) Rotation 3 -#define ROTN4_FACTORY 10 // -14 (+24) Rotation 4 -#define PRIO_FACTORY 0 // Mono priority 0 - BAS(e note), 1 - ROT(ating note) -#define VIB_SENS_FACTORY 6 // 1 least sensitive, higher more sensitive -#define VIB_RETN_FACTORY 2 // 0, no return, 1 slow return, higher faster return -#define VIB_SQUELCH_FACTORY 15 // 0 to 30, vib signal squelch -#define VIB_DIRECTION_FACTORY 0 +//_______________________________________________________________________________________________ DECLARATIONS //variables setup @@ -210,27 +107,14 @@ int pitchbStep; int extracStep; int ctouchStep; - - byte ccList[11] = {0,1,2,7,11,1,2,7,11,74,20}; // OFF, Modulation, Breath, Volume, Expression (then same sent in hires), CC74 (cutoff/brightness), CC20 int pbDepthList[13] = {8192,8192,4096,2731,2048,1638,1365,1170,1024,910,819,744,683}; -byte cursorNow; -byte forcePix = 0; -byte forceRedraw = 0; - -int pos1; -int pos2; // the following variables are unsigned longs because the time, measured in // milliseconds, will quickly become a bigger number than can be stored in an int. -unsigned long lastDebounceTime = 0; // the last time the output pin was toggled -unsigned long debounceDelay = 30; // the debounce time; increase if the output flickers -unsigned long buttonRepeatTime = 0; -unsigned long buttonPressedTime = 0; -unsigned long buttonRepeatInterval = 50; -unsigned long buttonRepeatDelay = 400; + unsigned long pixelUpdateTime = 0; unsigned long pixelUpdateInterval = 80; unsigned long cursorBlinkTime = 0; // the last time the cursor was toggled @@ -292,8 +176,6 @@ int oldpb=8192; int vibSignal=0; int pbUp=0; int pbDn=0; -int lastPbUp=0; -int lastPbDn=0; byte vibLedOff = 0; byte oldpkey = 0; diff --git a/NuEVI/config.h b/NuEVI/config.h new file mode 100644 index 0000000..7762fc3 --- /dev/null +++ b/NuEVI/config.h @@ -0,0 +1,24 @@ + +#ifndef __CONFIG_H +#define __CONFIG_H + + +// Compile options, comment/uncomment to change + +#define FIRMWARE_VERSION "1.3.5" // FIRMWARE VERSION NUMBER HERE <<<<<<<<<<<<<<<<<<<<<<< + + +//#define CASSIDY +//#define CVSCALEBOARD + +#define ON_Delay 20 // Set Delay after ON threshold before velocity is checked (wait for tounging peak) +//#define touch_Thr 1200 // sensitivity for Teensy touch sensors +#define CCN_Port 5 // Controller number for portamento level +#define CCN_PortOnOff 65// Controller number for portamento on/off + +// Send breath CC data no more than every CC_INTERVAL (other CC is sent with double interval) +// milliseconds (due to timing errors, the value should be about half the actual wanted value) +#define CC_INTERVAL 2 + + +#endif diff --git a/NuEVI/globals.h b/NuEVI/globals.h new file mode 100644 index 0000000..0150a5d --- /dev/null +++ b/NuEVI/globals.h @@ -0,0 +1,125 @@ +#ifndef __GLOBALS_H +#define __GLOBALS_H + +#include "Wiring.h" + +extern unsigned short breathThrVal;//; +extern unsigned short breathMaxVal;//; +extern unsigned short portamThrVal;//; +extern unsigned short portamMaxVal;//; +extern unsigned short pitchbThrVal;//; +extern unsigned short pitchbMaxVal;//; +extern unsigned short extracThrVal;//; +extern unsigned short extracMaxVal;//; +extern unsigned short ctouchThrVal;//; +extern unsigned short transpose; +extern unsigned short MIDIchannel; +extern unsigned short breathCC; // OFF:MW:BR:VL:EX:MW+:BR+:VL+:EX+:CF +extern unsigned short breathAT; +extern unsigned short velocity; +extern unsigned short portamento;// switching on cc65? just cc5 enabled? SW:ON:OFF +extern unsigned short PBdepth; // OFF:1-12 divider +extern unsigned short extraCT; // OFF:MW:FP:CF:SP +extern unsigned short vibrato; // OFF:1-9 +extern unsigned short deglitch; // 0-70 ms in steps of 5 +extern unsigned short patch; // 1-128 +extern unsigned short octave; +extern unsigned short curve; +extern unsigned short velSmpDl; // 0-30 ms +extern unsigned short velBias; // 0-9 +extern unsigned short pinkySetting; // 0 - 11 (QuickTranspose -12 to -1), 12 (pb/2), 13 - 24 (QuickTranspose +1 to +12) +extern unsigned short dipSwBits; // virtual dip switch settings for special modes (work in progress) +extern unsigned short priority; // mono priority for rotator chords +extern unsigned short vibSens; // vibrato sensitivity +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 byte rotatorOn; +extern byte currentRotation; +extern int rotations[4]; +extern int parallel; // semitones +extern byte gateOpen; // setting for gate always open, note on sent for every time fingering changes, no matter the breath status + +extern int breathLoLimit; +extern int breathHiLimit; +extern int portamLoLimit; +extern int portamHiLimit; +extern int pitchbLoLimit; +extern int pitchbHiLimit; +extern int extracLoLimit; +extern int extracHiLimit; +extern int ctouchLoLimit; +extern int ctouchHiLimit; +extern int ttouchLoLimit; +extern int ttouchHiLimit; + +extern int touch_Thr; +extern int breathStep; +extern int portamStep; +extern int pitchbStep; +extern int extracStep; +extern int ctouchStep; + + +extern unsigned long pixelUpdateTime; +extern unsigned long pixelUpdateInterval; +extern unsigned long cursorBlinkTime; // the last time the cursor was toggled +extern unsigned long cursorBlinkInterval; // the cursor blink toggle interval time +extern unsigned long patchViewTime; +extern unsigned long patchViewTimeUp; // ms until patch view shuts off +extern unsigned long menuTime; +extern unsigned long menuTimeUp; // menu shuts off after one minute of button inactivity +extern unsigned long lastDeglitchTime; // The last time the fingering was changed +extern unsigned long ccSendTime; // The last time we sent CC values +extern unsigned long breath_on_time; // Time when breath sensor value went over the ON threshold +extern int lastFingering; // Keep the last fingering value for debouncing +extern int mainState; // The state of the main state machine +extern int initial_breath_value; // The breath value at the time we observed the transition +extern byte activeMIDIchannel; // MIDI channel +extern byte activePatch; +extern byte doPatchUpdate; + +extern byte legacy; +extern byte legacyBrAct; +extern byte halfTime; +extern byte FPD ; +extern boolean programonce; +extern byte slowMidi; + +extern int pressureSensor; // pressure data from breath sensor, for midi breath cc and breath threshold checks +extern int lastPressure; + +extern int biteSensor; // capacitance data from bite sensor, for midi cc and threshold checks +extern int lastBite; +extern byte biteJumper; + +extern int exSensor; +extern int lastEx; + +extern int pitchBend; + +extern int pbUp; +extern int pbDn; + +extern byte vibLedOff; +extern byte oldpkey; + +extern int vibThr; // this gets auto calibrated in setup +extern int vibThrLo; +extern int vibZero; + +// Key variables, TRUE (1) for pressed, FALSE (0) for not pressed +extern byte K1; // Valve 1 (pitch change -2) +extern byte K2; // Valve 2 (pitch change -1) +extern byte K3; // Valve 3 (pitch change -3) +extern byte K4; // Left Hand index finger (pitch change -5) +extern byte K5; // Trill key 1 (pitch change +2) +extern byte K6; // Trill key 2 (pitch change +1) +extern byte K7; // Trill key 3 (pitch change +4) + +extern byte halfPitchBendKey; +extern byte specialKey; +extern byte pinkyKey; + +#endif diff --git a/NuEVI/menu.ino b/NuEVI/menu.cpp similarity index 96% rename from NuEVI/menu.ino rename to NuEVI/menu.cpp index 5c0e208..516fab9 100644 --- a/NuEVI/menu.ino +++ b/NuEVI/menu.cpp @@ -1,34 +1,60 @@ #include "menu.h" +#include "hardware.h" +#include "config.h" +#include "globals.h" +#include "midi.h" +#include #include #include +#include +#include "settings.h" -#ifndef SSD1306_128_64 -#error("Incorrect display type, please fix Adafruit_SSD1306.h!"); -#endif +//#ifndef SSD1306_128_64 +//#error("Incorrect display type, please fix Adafruit_SSD1306.h!"); +//#endif #define OLED_RESET 4 -Adafruit_SSD1306 display(OLED_RESET); +Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET); -int minOffset = 50; +static int minOffset = 50; -int deumButtons = 0; -int lastDeumButtons = 0; -int deumButtonState = 0; -byte buttonPressedAndNotUsed = 0; +static int deumButtons = 0; +static int lastDeumButtons = 0; +static int deumButtonState = 0; +static byte buttonPressedAndNotUsed = 0; + +static byte mainMenuCursor = 1; +static byte setupBrMenuCursor = 1; +static byte setupCtMenuCursor = 1; +static byte rotatorMenuCursor = 1; +static byte vibratoMenuCursor = 1; + + +static byte cursorNow; +static byte forcePix = 0; +static byte forceRedraw = 0; + +static int pos1; +static int pos2; + +static unsigned long lastDebounceTime = 0; // the last time the output pin was toggled +static const unsigned long debounceDelay = 30; // the debounce time; increase if the output flickers +static unsigned long buttonRepeatTime = 0; +static unsigned long buttonPressedTime = 0; +static const unsigned long buttonRepeatInterval = 50; +static const unsigned long buttonRepeatDelay = 400; + +static int lastPbUp = 0; +static int lastPbDn = 0; -byte mainMenuCursor = 1; -byte setupBrMenuCursor = 1; -byte setupCtMenuCursor = 1; -byte rotatorMenuCursor = 1; -byte vibratoMenuCursor = 1; //Display state -byte state = DISPLAYOFF_IDL; -byte stateFirstRun = 1; +static byte state = DISPLAYOFF_IDL; +static byte stateFirstRun = 1; byte subTranspose = 0; byte subOctave = 0; @@ -124,6 +150,57 @@ static const unsigned char PROGMEM nuevi_logo_bmp[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +extern void readSwitches(void); +extern Adafruit_MPR121 touchSensor; + +// Forward declare local function + +static int readTrills(void); +static void clearFPS(int trills); +static void setFPS(int trills); + +static void clearSub(void); +static void drawRotatorMenuScreen(void); +static void drawSubRotator(void); +static void drawMenuScreen(void); +static void drawMenuCursor(byte itemNo, byte color); +static void drawSubTranspose(void); +static void drawPatchView(void); +static void drawTrills(void); +static void drawBreathScreen(void); +static void drawAdjCursor(byte color); + +static void plotTranspose(int color); +static void plotBreathCC(int color); +static void plotBreathAT(int color); +static void plotRotator(int color,int value); +static void plotOctave(int cursorNow); +static void plotMIDI(int color); +static void plotPriority(int color); +static void plotPort(int color); +static void plotPB(int color); +static void plotExtra(int color); +static void plotVibrato(int color); +static void plotVibSens(int color); +static void plotVibRetn(int color); +static void plotVibSquelch(int color); +static void plotVibDirection(int color); +static void plotDeglitch(int color); +static void plotCurve(int color); +static void plotVelocity(int color); +static void plotPinkyKey(int color); +static void plotVelSmpDl(int color); +static void plotVelBias(int color); + + + +// static void selectMainMenu(void); +// static void selectRotatorMenu(void); +// static void selectSetupBrMenu(void); +// static void selectSetupCtMenu(void); + + void initDisplay() { // by default, we'll generate the high voltage from the 3.3v line internally! (neat!) @@ -156,6 +233,1301 @@ void showVersion() { display.display(); } +void drawBreathScreen(){ + // Clear the buffer. + display.clearDisplay(); + + display.setTextSize(1); + display.setTextColor(WHITE); + display.setCursor(25,2); + display.println("BREATH"); + //display.drawLine(0,10,127,10,WHITE); + display.setCursor(0,20); + display.println("THR"); + display.drawLine(25,17,120,17,WHITE); + display.drawLine(25,18,25,19,WHITE); + display.drawLine(120,18,120,19,WHITE); + display.drawLine(25,29,120,29,WHITE); + display.drawLine(25,27,25,28,WHITE); + display.drawLine(120,27,120,28,WHITE); + display.setCursor(0,35); + display.println("SNS"); + //display.drawLine(25,38,120,38,WHITE); + display.drawLine(25,36,25,40,WHITE); + display.drawLine(120,36,120,40,WHITE); + display.setCursor(0,50); + display.println("MAX"); + display.drawLine(25,47,120,47,WHITE); + display.drawLine(25,48,25,49,WHITE); + display.drawLine(120,48,120,49,WHITE); + display.drawLine(25,60,120,60,WHITE); + display.drawLine(25,58,25,59,WHITE); + display.drawLine(120,58,120,59,WHITE); + + //display.drawLine(38,20,38,26,WHITE); // indikation thr + pos1 = map(breathThrVal, breathLoLimit, breathHiLimit, 27, 119); + display.drawLine(pos1,20,pos1,26,WHITE); + cursorNow = WHITE; + //display.drawLine(115,50,115,57,WHITE); // indikation max + pos2 = map(breathMaxVal, breathLoLimit, breathHiLimit, 27, 119); + display.drawLine(pos2,50,pos2,57,WHITE); + //display.drawPixel(34, 38, WHITE); + drawAdjCursor(WHITE); + display.display(); +} + +void drawPortamScreen(){ + // Clear the buffer. + display.clearDisplay(); + + display.setTextSize(1); + display.setTextColor(WHITE); + display.setCursor(25,2); + display.println("PORTAMENTO"); + //display.drawLine(0,10,127,10,WHITE); + display.setCursor(0,20); + display.println("THR"); + display.drawLine(25,17,120,17,WHITE); + display.drawLine(25,18,25,19,WHITE); + display.drawLine(120,18,120,19,WHITE); + display.drawLine(25,29,120,29,WHITE); + display.drawLine(25,27,25,28,WHITE); + display.drawLine(120,27,120,28,WHITE); + display.setCursor(0,35); + display.println("SNS"); + //display.drawLine(25,38,120,38,WHITE); + display.drawLine(25,36,25,40,WHITE); + display.drawLine(120,36,120,40,WHITE); + display.setCursor(0,50); + display.println("MAX"); + display.drawLine(25,47,120,47,WHITE); + display.drawLine(25,48,25,49,WHITE); + display.drawLine(120,48,120,49,WHITE); + display.drawLine(25,60,120,60,WHITE); + display.drawLine(25,58,25,59,WHITE); + display.drawLine(120,58,120,59,WHITE); + + //display.drawLine(38,20,38,26,WHITE); // indikation thr + pos1 = map(portamThrVal, portamLoLimit, portamHiLimit, 27, 119); + display.drawLine(pos1,20,pos1,26,WHITE); + cursorNow = WHITE; + //display.drawLine(115,50,115,57,WHITE); // indikation max + pos2 = map(portamMaxVal, portamLoLimit, portamHiLimit, 27, 119); + display.drawLine(pos2,50,pos2,57,WHITE); + //display.drawPixel(34, 38, WHITE); + drawAdjCursor(WHITE); + display.display(); +} + +void drawPitchbScreen(){ + // Clear the buffer. + display.clearDisplay(); + + display.setTextSize(1); + display.setTextColor(WHITE); + display.setCursor(25,2); + display.println("PITCH BEND"); + //display.drawLine(0,10,127,10,WHITE); + display.setCursor(0,20); + display.println("THR"); + display.drawLine(25,17,120,17,WHITE); + display.drawLine(25,18,25,19,WHITE); + display.drawLine(120,18,120,19,WHITE); + display.drawLine(25,29,120,29,WHITE); + display.drawLine(25,27,25,28,WHITE); + display.drawLine(120,27,120,28,WHITE); + display.setCursor(0,35); + display.println("SNS"); + //display.drawLine(25,38,120,38,WHITE); + display.drawLine(25,36,25,40,WHITE); + display.drawLine(120,36,120,40,WHITE); + display.setCursor(0,50); + display.println("MAX"); + display.drawLine(25,47,120,47,WHITE); + display.drawLine(25,48,25,49,WHITE); + display.drawLine(120,48,120,49,WHITE); + display.drawLine(25,60,120,60,WHITE); + display.drawLine(25,58,25,59,WHITE); + display.drawLine(120,58,120,59,WHITE); + + //display.drawLine(38,20,38,26,WHITE); // indikation thr + pos1 = map(pitchbThrVal, pitchbLoLimit, pitchbHiLimit, 27, 119); + display.drawLine(pos1,20,pos1,26,WHITE); + cursorNow = WHITE; + //display.drawLine(115,50,115,57,WHITE); // indikation max + pos2 = map(pitchbMaxVal, pitchbLoLimit, pitchbHiLimit, 27, 119); + display.drawLine(pos2,50,pos2,57,WHITE); + //display.drawPixel(34, 38, WHITE); + drawAdjCursor(WHITE); + display.display(); +} + +void drawExtracScreen(){ + // Clear the buffer. + display.clearDisplay(); + + display.setTextSize(1); + display.setTextColor(WHITE); + display.setCursor(25,2); + display.println("EXTRA CONTROLLER"); + //display.drawLine(0,10,127,10,WHITE); + display.setCursor(0,20); + display.println("THR"); + display.drawLine(25,17,120,17,WHITE); + display.drawLine(25,18,25,19,WHITE); + display.drawLine(120,18,120,19,WHITE); + display.drawLine(25,29,120,29,WHITE); + display.drawLine(25,27,25,28,WHITE); + display.drawLine(120,27,120,28,WHITE); + display.setCursor(0,35); + display.println("SNS"); + //display.drawLine(25,38,120,38,WHITE); + display.drawLine(25,36,25,40,WHITE); + display.drawLine(120,36,120,40,WHITE); + display.setCursor(0,50); + display.println("MAX"); + display.drawLine(25,47,120,47,WHITE); + display.drawLine(25,48,25,49,WHITE); + display.drawLine(120,48,120,49,WHITE); + display.drawLine(25,60,120,60,WHITE); + display.drawLine(25,58,25,59,WHITE); + display.drawLine(120,58,120,59,WHITE); + + //display.drawLine(38,20,38,26,WHITE); // indikation thr + pos1 = map(extracThrVal, extracLoLimit, extracHiLimit, 27, 119); + display.drawLine(pos1,20,pos1,26,WHITE); + cursorNow = WHITE; + //display.drawLine(115,50,115,57,WHITE); // indikation max + pos2 = map(extracMaxVal, extracLoLimit, extracHiLimit, 27, 119); + display.drawLine(pos2,50,pos2,57,WHITE); + //display.drawPixel(34, 38, WHITE); + drawAdjCursor(WHITE); + display.display(); +} + + +void drawCtouchScreen(){ + // Clear the buffer. + display.clearDisplay(); + + display.setTextSize(1); + display.setTextColor(WHITE); + display.setCursor(25,2); + display.println("TOUCH SENSE"); + //display.drawLine(0,10,127,10,WHITE); + display.setCursor(0,20); + display.println("THR"); + display.drawLine(25,17,120,17,WHITE); + display.drawLine(25,18,25,19,WHITE); + display.drawLine(120,18,120,19,WHITE); + display.drawLine(25,29,120,29,WHITE); + display.drawLine(25,27,25,28,WHITE); + display.drawLine(120,27,120,28,WHITE); + display.setCursor(0,35); + display.println("SNS"); + //display.drawLine(25,38,120,38,WHITE); + display.drawLine(25,36,25,40,WHITE); + display.drawLine(120,36,120,40,WHITE); + + //display.drawLine(38,20,38,26,WHITE); // indikation thr + pos1 = map(ctouchThrVal, ctouchLoLimit, ctouchHiLimit, 27, 119); + display.drawLine(pos1,20,pos1,26,WHITE); + cursorNow = WHITE; + + //display.drawPixel(34, 38, WHITE); + drawAdjCursor(WHITE); + display.display(); +} + +/* + * Draw a regular list of text menu items + * header - first header line + * selectedItem - the currently selected item (draw a triangle next to it). -1 for none. 1..nItems (1-based, 0 is header row) + * nItems - number of menu items + * ... - a list (nItems long) of text items to show + */ +static void drawMenu(const char* header, byte selected, byte nItems, ...) { + va_list valist; + + //Initialize display and draw menu header + line + display.clearDisplay(); + display.setTextSize(1); + display.setTextColor(WHITE); + display.setCursor(0,0); + display.println(header); + display.drawLine(0,MENU_ROW_HEIGHT,127,MENU_ROW_HEIGHT, WHITE); + + va_start(valist, nItems); + for(byte row=0; row=0) drawMenuCursor(selected, WHITE); + + va_end(valist); + + display.display(); +} + + +void drawMenuCursor(byte itemNo, byte color){ + byte xmid = 6 + 9 * itemNo; + display.drawTriangle(57,xmid,61,xmid+2,61,xmid-2,color); +} + +void drawAdjCursor(byte color){ + display.drawTriangle(16,4,20,4,18,1,color); + display.drawTriangle(16,6,20,6,18,9,color); +} + +void drawMenuScreen(){ + + //Construct the title including voltage reading. + //Involves intricate splicing of the title string with battery voltage + char menuTitle[] = "MENU XXX Y.Y "; //Allocate string buffer of appropriate size with some placeholders + char* splice1 = menuTitle + 13; + char* splice2 = menuTitle + 17; + + int vMeterReading = analogRead(vMeterPin); + memcpy(splice1, (vMeterReading > 3000) ? "USB" : "BAT", 3); + if (vMeterReading < 2294) { + memcpy(splice2, "LOW ", 3); + } else { + double voltage = map(vMeterReading,0,3030,0,50)*0.1; + dtostrf(voltage, 3, 1, splice2); + splice2[3]='V'; //Put the V at the end (last char of buffer before \0) + } + + drawMenu(menuTitle, mainMenuCursor, 6, + "TRANSPOSE", + "OCTAVE", + "MIDI CH", + "ADJUST", + "SETUP BR", + "SETUP CTL"); +} + +static void drawRotatorMenuScreen(){ + drawMenu("ROTATOR SETUP", rotatorMenuCursor, 6, + "PARALLEL", + "ROTATE 1", + "ROTATE 2", + "ROTATE 3", + "ROTATE 4", + "PRIORITY"); +} + +static void drawPatchView(){ + display.clearDisplay(); + if (FPD){ + drawTrills(); + } + if (FPD < 2){ + display.setTextColor(WHITE); + display.setTextSize(6); + if (patch < 10){ + // 1-9 + display.setCursor(48,10); + } else if (patch < 100){ + // 10-99 + display.setCursor(31,10); + } else { + // 99-128 + display.setCursor(10,10); + } + display.println(patch); + } else if (FPD == 2){ + display.setTextColor(WHITE); + display.setTextSize(6); + display.setCursor(10,10); + display.println("SET"); + } else { + display.setTextColor(WHITE); + display.setTextSize(6); + display.setCursor(10,10); + display.println("CLR"); + } + display.display(); +} + +static void drawTrills(){ + if (K5) display.fillRect(0,0,5,5,WHITE); else display.drawRect(0,0,5,5,WHITE); + if (K6) display.fillRect(10,0,5,5,WHITE); else display.drawRect(10,0,5,5,WHITE); + if (K7) display.fillRect(20,0,5,5,WHITE); else display.drawRect(20,0,5,5,WHITE); +} + +static void clearSub(){ + display.fillRect(63,11,64,52,BLACK); +} + +static void drawSubTranspose(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("TRANSPOSE"); + plotTranspose(WHITE); + display.display(); +} + +static void plotTranspose(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(80,33); + if ((transpose-12) > -1){ + display.println("+"); + display.setCursor(93,33); + display.println(transpose-12); + } else { + display.println("-"); + display.setCursor(93,33); + display.println(abs(transpose-12)); + } +} + +static void drawSubRotator(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("SEMITONES"); + //plotRotator(WHITE,value); + forceRedraw = 1; + display.display(); +} + +static void plotRotator(int color,int value){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(80,33); + if ((value) > -1){ + display.println("+"); + display.setCursor(93,33); + display.println(value); + } else { + display.println("-"); + display.setCursor(93,33); + display.println(abs(value)); + } +} + +static void drawSubPriority(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("MONO PRIO"); + plotPriority(WHITE); + display.display(); +} + +static void plotPriority(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(79,33); + if (priority){ + display.println("ROT"); + } else { + display.println("MEL"); + } +} + + +static void drawSubOctave(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(77,15); + display.println("OCTAVE"); + plotOctave(WHITE); + display.display(); +} + +static void plotOctave(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(80,33); + if ((octave-3) > -1){ + display.println("+"); + display.setCursor(93,33); + display.println(octave-3); + } else { + display.println("-"); + display.setCursor(93,33); + display.println(abs(octave-3)); + } +} + +static void drawSubMIDI(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("MIDI CHNL"); + plotMIDI(WHITE); + display.display(); +} + +static void plotMIDI(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(90,33); + display.println(MIDIchannel); + if (slowMidi){ + display.setTextColor(WHITE); + } else { + display.setTextColor(BLACK); + } + display.setTextSize(1); + display.setCursor(116,51); + display.print("S"); +} + +static void drawSubBreathCC(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("BREATH CC"); + plotBreathCC(WHITE); + display.display(); +} + +static void plotBreathCC(int color){ + display.setTextColor(color); + display.setTextSize(2); + if (breathCC){ + switch (breathCC){ + case 1: + display.setCursor(83,33); + display.println("MW"); + break; + case 2: + display.setCursor(83,33); + display.println("BR"); + break; + case 3: + display.setCursor(83,33); + display.println("VL"); + break; + case 4: + display.setCursor(83,33); + display.println("EX"); + break; + case 5: + display.setCursor(79,33); + display.println("MW+"); + break; + case 6: + display.setCursor(79,33); + display.println("BR+"); + break; + case 7: + display.setCursor(79,33); + display.println("VL+"); + break; + case 8: + display.setCursor(79,33); + display.println("EX+"); + break; + case 9: + display.setCursor(83,33); + display.println("CF"); + break; + case 10: + display.setCursor(83,33); + display.println("20"); + break; + } + } else { + display.setCursor(79,33); + display.println("OFF"); + } +} + +static void drawSubBreathAT(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("BREATH AT"); + plotBreathAT(WHITE); + display.display(); +} + +static void plotBreathAT(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(79,33); + if (breathAT){ + display.println("ON"); + } else { + display.println("OFF"); + } +} + +static void drawSubVelocity(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(71,15); + display.println("VELOCITY"); + plotVelocity(WHITE); + display.display(); +} + +static void plotVelocity(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(79,33); + if (velocity){ + display.println(velocity); + } else { + display.println("DYN"); + } +} + + +static void drawSubCurve(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(80,15); + display.println("CURVE"); + plotCurve(WHITE); + display.display(); +} + +static void plotCurve(int color){ + display.setTextColor(color); + display.setTextSize(2); + switch (curve){ + case 0: + display.setCursor(83,33); + display.println("-4"); + break; + case 1: + display.setCursor(83,33); + display.println("-3"); + break; + case 2: + display.setCursor(83,33); + display.println("-2"); + break; + case 3: + display.setCursor(83,33); + display.println("-1"); + break; + case 4: + display.setCursor(79,33); + display.println("LIN"); + break; + case 5: + display.setCursor(83,33); + display.println("+1"); + break; + case 6: + display.setCursor(83,33); + display.println("+2"); + break; + case 7: + display.setCursor(83,33); + display.println("+3"); + break; + case 8: + display.setCursor(83,33); + display.println("+4"); + break; + case 9: + display.setCursor(83,33); + display.println("S1"); + break; + case 10: + display.setCursor(83,33); + display.println("S2"); + break; + case 11: + display.setCursor(83,33); + display.println("Z1"); + break; + case 12: + display.setCursor(83,33); + display.println("Z2"); + break; + } +} + + +static void drawSubPort(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(71,15); + display.println("PORT/GLD"); + plotPort(WHITE); + display.display(); +} + +static void plotPort(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(79,33); + if (portamento == 1){ + display.println("ON"); + } else if (portamento == 2){ + display.println("SW"); + } else { + display.println("OFF"); + } +} + +static void drawSubPB(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("PITCHBEND"); + plotPB(WHITE); + display.display(); +} + +static void plotPB(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(76,33); + if (PBdepth){ + display.println("1/"); + display.setCursor(101,33); + display.println(PBdepth); + } else { + display.println("OFF"); + } +} + +static void drawSubExtra(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("EXTRA CTR"); + plotExtra(WHITE); + display.display(); +} + +static void plotExtra(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(79,33); + switch (extraCT){ + case 0: + display.setCursor(79,33); + display.println("OFF"); + break; + case 1: + display.setCursor(83,33); + display.println("MW"); + break; + case 2: + display.setCursor(83,33); + display.println("FP"); + break; + case 3: + display.setCursor(83,33); + display.println("CF"); + break; + case 4: + display.setCursor(83,33); + display.println("SP"); + break; + } +} + +static void drawSubVibrato(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(81,15); + display.println("LEVEL"); + plotVibrato(WHITE); + display.display(); +} + +static void plotVibrato(int color){ + display.setTextColor(color); + display.setTextSize(2); + if (vibrato){ + display.setCursor(90,33); + display.println(vibrato); + } else { + display.setCursor(79,33); + display.println("OFF"); + } +} + +static void drawSubVibSens(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(81,15); + display.println("LEVEL"); + plotVibSens(WHITE); + display.display(); +} + +static void plotVibSens(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(90,33); + display.println(vibSens); +} + +static void drawSubVibRetn(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(81,15); + display.println("LEVEL"); + plotVibRetn(WHITE); + display.display(); +} + +static void plotVibRetn(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(90,33); + display.println(vibRetn); +} + +static void drawSubVibSquelch(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(81,15); + display.println("LEVEL"); + plotVibSquelch(WHITE); + display.display(); +} + +static void plotVibSquelch(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(83,33); + display.println(vibSquelch); +} + + + +static void drawSubVibDirection(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("DIRECTION"); + plotVibDirection(WHITE); + display.display(); +} + +static void plotVibDirection(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(79,33); + if (DNWD == vibDirection){ + display.println("NRM"); + } else { + display.println("REV"); + } +} + + + + + + +static void drawSubDeglitch(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(71,15); + display.println("DEGLITCH"); + plotDeglitch(WHITE); + display.display(); +} + +static void plotDeglitch(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(79,33); + if (deglitch){ + display.println(deglitch); + display.setCursor(105,40); + display.setTextSize(1); + display.println("ms"); + } else { + display.println("OFF"); + } +} + +static void drawSubPinkyKey(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(68,15); + display.println("PINKY KEY"); + plotPinkyKey(WHITE); + display.display(); +} + +static void plotPinkyKey(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(79,33); + if (pinkySetting < 12){ + display.println(pinkySetting - 12); + } else if (pinkySetting == PBD) { + display.println("PBD"); + } else { + display.print("+"); + display.println(pinkySetting - 12); + } +} + +static void drawSubVelSmpDl(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(69,15); + display.println("VEL DELAY"); + plotVelSmpDl(WHITE); + display.display(); +} + +static void plotVelSmpDl(int color){ + display.setTextColor(color); + display.setTextSize(2); + display.setCursor(79,33); + if (velSmpDl){ + display.println(velSmpDl); + display.setCursor(105,40); + display.setTextSize(1); + display.println("ms"); + } else { + display.println("OFF"); + } +} + +static void drawSubVelBias(){ + display.fillRect(63,11,64,52,BLACK); + display.drawRect(63,11,64,52,WHITE); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(72,15); + display.println("VEL BIAS"); + plotVelBias(WHITE); + display.display(); +} + +static void plotVelBias(int color){ + display.setTextColor(color); + display.setTextSize(2); + if (velBias){ + display.setCursor(90,33); + display.println(velBias); + } else { + display.setCursor(79,33); + display.println("OFF"); + } +} + +static void drawSetupBrMenuScreen(){ + drawMenu("SETUP BREATH", -1, 6, "BREATH CC", "BREATH AT", "VELOCITY", "CURVE", "VEL DELAY", "VEL BIAS"); +} + +static void drawSetupCtMenuScreen(){ + drawMenu("SETUP CTRLS", -1, 6, "PORT/GLD", "PITCHBEND", "EXTRA CTR", "VIBRATO", "DEGLITCH", "PINKY KEY"); +} + +static void drawVibratoMenuScreen(){ + drawMenu("VIBRATO", -1, 5, "DEPTH","SENSE","RETURN", "SQUELCH", "DIRECTION"); +} + +void drawSensorPixels(){ + int pos,oldpos; + int redraw=0; + if ((state == BREATH_ADJ_IDL) || (state == BREATH_ADJ_THR) || (state == BREATH_ADJ_MAX)){ + pos = map(constrain(pressureSensor, breathLoLimit, breathHiLimit), breathLoLimit, breathHiLimit, 28, 118); + oldpos = map(constrain(lastPressure, breathLoLimit, breathHiLimit), breathLoLimit, breathHiLimit, 28, 118); + if (pos!=oldpos){ + display.drawPixel(oldpos, 38, BLACK); + display.drawPixel(pos, 38, WHITE); + display.display(); + } else if (forcePix) { + display.drawPixel(pos, 38, WHITE); + display.display(); + } + lastPressure=pressureSensor; + } + if ((state == PORTAM_ADJ_IDL) || (state == PORTAM_ADJ_THR) || (state == PORTAM_ADJ_MAX)){ + pos = map(constrain(biteSensor,portamLoLimit,portamHiLimit), portamLoLimit, portamHiLimit, 28, 118); + oldpos = map(constrain(lastBite,portamLoLimit,portamHiLimit), portamLoLimit, portamHiLimit, 28, 118); + if (pos!=oldpos){ + display.drawPixel(oldpos, 38, BLACK); + display.drawPixel(pos, 38, WHITE); + display.display(); + } else if (forcePix) { + display.drawPixel(pos, 38, WHITE); + display.display(); + } + lastBite=biteSensor; + /*if (biteJumper){ + pos = map(constrain(analogRead(bitePin),900,1400), 900, 1400, 28, 118); + display.drawPixel(pos, 40, WHITE); + }*/ + } + if ((state == PITCHB_ADJ_IDL) || (state == PITCHB_ADJ_THR) || (state == PITCHB_ADJ_MAX)){ + pos = map(constrain(pbUp, pitchbLoLimit, pitchbHiLimit), pitchbLoLimit, pitchbHiLimit, 28, 118); + oldpos = map(constrain(lastPbUp, pitchbLoLimit, pitchbHiLimit), pitchbLoLimit, pitchbHiLimit, 28, 118); + if (pos!=oldpos){ + display.drawPixel(oldpos, 38, BLACK); + display.drawPixel(pos, 38, WHITE); + redraw=1; + } else if (forcePix) { + display.drawPixel(pos, 38, WHITE); + redraw=1; + } + pos = map(constrain(pbDn, pitchbLoLimit, pitchbHiLimit), pitchbLoLimit, pitchbHiLimit, 28, 118); + oldpos = map(constrain(lastPbDn, pitchbLoLimit, pitchbHiLimit), pitchbLoLimit, pitchbHiLimit, 28, 118); + if (pos!=oldpos){ + display.drawPixel(oldpos, 38, BLACK); + display.drawPixel(pos, 38, WHITE); + redraw=1; + } else if (forcePix) { + display.drawPixel(pos, 38, WHITE); + redraw=1; + } + if (redraw){ + display.display(); + redraw=0; + } + lastPbUp=pbUp; + lastPbDn=pbDn; + } + if ((state == EXTRAC_ADJ_IDL) || (state == EXTRAC_ADJ_THR) || (state == EXTRAC_ADJ_MAX)){ + pos = map(constrain(exSensor, extracLoLimit, extracHiLimit), extracLoLimit, extracHiLimit, 28, 118); + oldpos = map(constrain(lastEx, extracLoLimit, extracHiLimit), extracLoLimit, extracHiLimit, 28, 118); + if (pos!=oldpos){ + display.drawPixel(oldpos, 38, BLACK); + display.drawPixel(pos, 38, WHITE); + display.display(); + } else if (forcePix) { + display.drawPixel(pos, 38, WHITE); + display.display(); + } + lastEx=exSensor; + } + if ((state == CTOUCH_ADJ_IDL) || (state == CTOUCH_ADJ_THR)){ + display.drawLine(28,38,118,38,BLACK); + for (byte i=0; i<12; i++){ + pos = map(constrain(touchSensor.filteredData(i), ctouchLoLimit, ctouchHiLimit), ctouchLoLimit, ctouchHiLimit, 28, 118); + display.drawPixel(pos, 38, WHITE); + } + int posRead = map(touchRead(halfPitchBendKeyPin),ttouchLoLimit,ttouchHiLimit,ctouchHiLimit,ctouchLoLimit); + pos = map(constrain(posRead, ctouchLoLimit, ctouchHiLimit), ctouchLoLimit, ctouchHiLimit, 28, 118); + display.drawPixel(pos, 38, WHITE); + posRead = map(touchRead(specialKeyPin),ttouchLoLimit,ttouchHiLimit,ctouchHiLimit,ctouchLoLimit); + pos = map(constrain(posRead, ctouchLoLimit, ctouchHiLimit), ctouchLoLimit, ctouchHiLimit, 28, 118); + display.drawPixel(pos, 38, WHITE); + display.display(); + } + forcePix = 0; +} + +void writeSetting(byte address, unsigned short value){ + union { + byte v[2]; + unsigned short val; + } data; + data.val = value; + EEPROM.write(address, data.v[0]); + EEPROM.write(address+1, data.v[1]); +} + +unsigned short readSetting(byte address){ + union { + byte v[2]; + unsigned short val; + } data; + data.v[0] = EEPROM.read(address); + data.v[1] = EEPROM.read(address+1); + return data.val; +} + + +//*********************************************************** + +static int readTrills() { + readSwitches(); + return K5+2*K6+4*K7; +} + +//*********************************************************** + +static void setFPS(int trills) { + fastPatch[trills-1] = patch; + writeSetting(FP1_ADDR+2*(trills-1),patch); + FPD = 2; +} + +//*********************************************************** + +static void clearFPS(int trills) { + fastPatch[trills-1] = 0; + writeSetting(FP1_ADDR+2*(trills-1),0); + FPD = 3; +} + +static void selectMainMenu(){ + switch (mainMenuCursor){ + case 1: + subTranspose = 1; + drawMenuCursor(mainMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubTranspose(); + break; + case 2: + subOctave = 1; + drawMenuCursor(mainMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubOctave(); + break; + case 3: + subMIDI = 1; + drawMenuCursor(mainMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubMIDI(); + break; + case 4: + state = BREATH_ADJ_IDL; + stateFirstRun = 1; + break; + case 5: + state = SETUP_BR_MENU; + stateFirstRun = 1; + break; + case 6: + state = SETUP_CT_MENU; + stateFirstRun = 1; + break; + } +} + +static void selectRotatorMenu(){ + switch (rotatorMenuCursor){ + case 1: + subParallel = 1; + drawMenuCursor(rotatorMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubRotator(); + break; + case 2: + subRotator = 1; + drawMenuCursor(rotatorMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubRotator(); + break; + case 3: + subRotator = 2; + drawMenuCursor(rotatorMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubRotator(); + break; + case 4: + subRotator = 3; + drawMenuCursor(rotatorMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubRotator(); + break; + case 5: + subRotator = 4; + drawMenuCursor(rotatorMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubRotator(); + break; + case 6: + subPriority = 1; + drawMenuCursor(rotatorMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubPriority(); + break; + } +} + +static void selectSetupBrMenu(){ + switch (setupBrMenuCursor){ + case 1: + subBreathCC = 1; + drawMenuCursor(setupBrMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubBreathCC(); + break; + case 2: + subBreathAT = 1; + drawMenuCursor(setupBrMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubBreathAT(); + break; + case 3: + subVelocity = 1; + drawMenuCursor(setupBrMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubVelocity(); + break; + case 4: + subCurve = 1; + drawMenuCursor(setupBrMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubCurve(); + break; + case 5: + subVelSmpDl = 1; + drawMenuCursor(setupBrMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubVelSmpDl(); + break; + case 6: + subVelBias = 1; + drawMenuCursor(setupBrMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubVelBias(); + break; + } +} + +static void selectSetupCtMenu(){ + switch (setupCtMenuCursor){ + case 1: + subPort = 1; + drawMenuCursor(setupCtMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubPort(); + break; + case 2: + subPB = 1; + drawMenuCursor(setupCtMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubPB(); + break; + case 3: + subExtra = 1; + drawMenuCursor(setupCtMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubExtra(); + break; + case 4: + //subVibrato = 1; + //drawMenuCursor(setupCtMenuCursor, WHITE); + //display.display(); + //cursorBlinkTime = millis(); + //drawSubVibrato(); + state = VIBRATO_MENU; + stateFirstRun = 1; + break; + case 5: + subDeglitch = 1; + drawMenuCursor(setupCtMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubDeglitch(); + break; + case 6: + subPinky = 1; + drawMenuCursor(setupCtMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubPinkyKey(); + } +} + +static void selectVibratoMenu(){ + switch (vibratoMenuCursor){ + case 1: + subVibrato = 1; + drawMenuCursor(vibratoMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubVibrato(); + break; + case 2: + subVibSens = 1; + drawMenuCursor(vibratoMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubVibSens(); + break; + case 3: + subVibRetn = 1; + drawMenuCursor(vibratoMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubVibRetn(); + break; + case 4: + subVibSquelch = 1; + drawMenuCursor(vibratoMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubVibSquelch(); + break; + case 5: + subVibDirection = 1; + drawMenuCursor(vibratoMenuCursor, WHITE); + display.display(); + cursorBlinkTime = millis(); + drawSubVibDirection(); + break; + } +} + void menu() { // read the state of the switches @@ -2481,1301 +3853,4 @@ void menu() { } } } - - - -} - -void selectMainMenu(){ - switch (mainMenuCursor){ - case 1: - subTranspose = 1; - drawMenuCursor(mainMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubTranspose(); - break; - case 2: - subOctave = 1; - drawMenuCursor(mainMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubOctave(); - break; - case 3: - subMIDI = 1; - drawMenuCursor(mainMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubMIDI(); - break; - case 4: - state = BREATH_ADJ_IDL; - stateFirstRun = 1; - break; - case 5: - state = SETUP_BR_MENU; - stateFirstRun = 1; - break; - case 6: - state = SETUP_CT_MENU; - stateFirstRun = 1; - break; - } -} - -void selectRotatorMenu(){ - switch (rotatorMenuCursor){ - case 1: - subParallel = 1; - drawMenuCursor(rotatorMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubRotator(); - break; - case 2: - subRotator = 1; - drawMenuCursor(rotatorMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubRotator(); - break; - case 3: - subRotator = 2; - drawMenuCursor(rotatorMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubRotator(); - break; - case 4: - subRotator = 3; - drawMenuCursor(rotatorMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubRotator(); - break; - case 5: - subRotator = 4; - drawMenuCursor(rotatorMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubRotator(); - break; - case 6: - subPriority = 1; - drawMenuCursor(rotatorMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubPriority(); - break; - } -} - -void selectSetupBrMenu(){ - switch (setupBrMenuCursor){ - case 1: - subBreathCC = 1; - drawMenuCursor(setupBrMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubBreathCC(); - break; - case 2: - subBreathAT = 1; - drawMenuCursor(setupBrMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubBreathAT(); - break; - case 3: - subVelocity = 1; - drawMenuCursor(setupBrMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubVelocity(); - break; - case 4: - subCurve = 1; - drawMenuCursor(setupBrMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubCurve(); - break; - case 5: - subVelSmpDl = 1; - drawMenuCursor(setupBrMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubVelSmpDl(); - break; - case 6: - subVelBias = 1; - drawMenuCursor(setupBrMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubVelBias(); - break; - } -} - -void selectSetupCtMenu(){ - switch (setupCtMenuCursor){ - case 1: - subPort = 1; - drawMenuCursor(setupCtMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubPort(); - break; - case 2: - subPB = 1; - drawMenuCursor(setupCtMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubPB(); - break; - case 3: - subExtra = 1; - drawMenuCursor(setupCtMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubExtra(); - break; - case 4: - //subVibrato = 1; - //drawMenuCursor(setupCtMenuCursor, WHITE); - //display.display(); - //cursorBlinkTime = millis(); - //drawSubVibrato(); - state = VIBRATO_MENU; - stateFirstRun = 1; - break; - case 5: - subDeglitch = 1; - drawMenuCursor(setupCtMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubDeglitch(); - break; - case 6: - subPinky = 1; - drawMenuCursor(setupCtMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubPinkyKey(); - } -} - -void selectVibratoMenu(){ - switch (vibratoMenuCursor){ - case 1: - subVibrato = 1; - drawMenuCursor(vibratoMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubVibrato(); - break; - case 2: - subVibSens = 1; - drawMenuCursor(vibratoMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubVibSens(); - break; - case 3: - subVibRetn = 1; - drawMenuCursor(vibratoMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubVibRetn(); - break; - case 4: - subVibSquelch = 1; - drawMenuCursor(vibratoMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubVibSquelch(); - break; - case 5: - subVibDirection = 1; - drawMenuCursor(vibratoMenuCursor, WHITE); - display.display(); - cursorBlinkTime = millis(); - drawSubVibDirection(); - break; - } -} - - -void drawBreathScreen(){ - // Clear the buffer. - display.clearDisplay(); - - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(25,2); - display.println("BREATH"); - //display.drawLine(0,10,127,10,WHITE); - display.setCursor(0,20); - display.println("THR"); - display.drawLine(25,17,120,17,WHITE); - display.drawLine(25,18,25,19,WHITE); - display.drawLine(120,18,120,19,WHITE); - display.drawLine(25,29,120,29,WHITE); - display.drawLine(25,27,25,28,WHITE); - display.drawLine(120,27,120,28,WHITE); - display.setCursor(0,35); - display.println("SNS"); - //display.drawLine(25,38,120,38,WHITE); - display.drawLine(25,36,25,40,WHITE); - display.drawLine(120,36,120,40,WHITE); - display.setCursor(0,50); - display.println("MAX"); - display.drawLine(25,47,120,47,WHITE); - display.drawLine(25,48,25,49,WHITE); - display.drawLine(120,48,120,49,WHITE); - display.drawLine(25,60,120,60,WHITE); - display.drawLine(25,58,25,59,WHITE); - display.drawLine(120,58,120,59,WHITE); - - //display.drawLine(38,20,38,26,WHITE); // indikation thr - pos1 = map(breathThrVal, breathLoLimit, breathHiLimit, 27, 119); - display.drawLine(pos1,20,pos1,26,WHITE); - cursorNow = WHITE; - //display.drawLine(115,50,115,57,WHITE); // indikation max - pos2 = map(breathMaxVal, breathLoLimit, breathHiLimit, 27, 119); - display.drawLine(pos2,50,pos2,57,WHITE); - //display.drawPixel(34, 38, WHITE); - drawAdjCursor(WHITE); - display.display(); -} - -void drawPortamScreen(){ - // Clear the buffer. - display.clearDisplay(); - - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(25,2); - display.println("PORTAMENTO"); - //display.drawLine(0,10,127,10,WHITE); - display.setCursor(0,20); - display.println("THR"); - display.drawLine(25,17,120,17,WHITE); - display.drawLine(25,18,25,19,WHITE); - display.drawLine(120,18,120,19,WHITE); - display.drawLine(25,29,120,29,WHITE); - display.drawLine(25,27,25,28,WHITE); - display.drawLine(120,27,120,28,WHITE); - display.setCursor(0,35); - display.println("SNS"); - //display.drawLine(25,38,120,38,WHITE); - display.drawLine(25,36,25,40,WHITE); - display.drawLine(120,36,120,40,WHITE); - display.setCursor(0,50); - display.println("MAX"); - display.drawLine(25,47,120,47,WHITE); - display.drawLine(25,48,25,49,WHITE); - display.drawLine(120,48,120,49,WHITE); - display.drawLine(25,60,120,60,WHITE); - display.drawLine(25,58,25,59,WHITE); - display.drawLine(120,58,120,59,WHITE); - - //display.drawLine(38,20,38,26,WHITE); // indikation thr - pos1 = map(portamThrVal, portamLoLimit, portamHiLimit, 27, 119); - display.drawLine(pos1,20,pos1,26,WHITE); - cursorNow = WHITE; - //display.drawLine(115,50,115,57,WHITE); // indikation max - pos2 = map(portamMaxVal, portamLoLimit, portamHiLimit, 27, 119); - display.drawLine(pos2,50,pos2,57,WHITE); - //display.drawPixel(34, 38, WHITE); - drawAdjCursor(WHITE); - display.display(); -} - -void drawPitchbScreen(){ - // Clear the buffer. - display.clearDisplay(); - - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(25,2); - display.println("PITCH BEND"); - //display.drawLine(0,10,127,10,WHITE); - display.setCursor(0,20); - display.println("THR"); - display.drawLine(25,17,120,17,WHITE); - display.drawLine(25,18,25,19,WHITE); - display.drawLine(120,18,120,19,WHITE); - display.drawLine(25,29,120,29,WHITE); - display.drawLine(25,27,25,28,WHITE); - display.drawLine(120,27,120,28,WHITE); - display.setCursor(0,35); - display.println("SNS"); - //display.drawLine(25,38,120,38,WHITE); - display.drawLine(25,36,25,40,WHITE); - display.drawLine(120,36,120,40,WHITE); - display.setCursor(0,50); - display.println("MAX"); - display.drawLine(25,47,120,47,WHITE); - display.drawLine(25,48,25,49,WHITE); - display.drawLine(120,48,120,49,WHITE); - display.drawLine(25,60,120,60,WHITE); - display.drawLine(25,58,25,59,WHITE); - display.drawLine(120,58,120,59,WHITE); - - //display.drawLine(38,20,38,26,WHITE); // indikation thr - pos1 = map(pitchbThrVal, pitchbLoLimit, pitchbHiLimit, 27, 119); - display.drawLine(pos1,20,pos1,26,WHITE); - cursorNow = WHITE; - //display.drawLine(115,50,115,57,WHITE); // indikation max - pos2 = map(pitchbMaxVal, pitchbLoLimit, pitchbHiLimit, 27, 119); - display.drawLine(pos2,50,pos2,57,WHITE); - //display.drawPixel(34, 38, WHITE); - drawAdjCursor(WHITE); - display.display(); -} - -void drawExtracScreen(){ - // Clear the buffer. - display.clearDisplay(); - - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(25,2); - display.println("EXTRA CONTROLLER"); - //display.drawLine(0,10,127,10,WHITE); - display.setCursor(0,20); - display.println("THR"); - display.drawLine(25,17,120,17,WHITE); - display.drawLine(25,18,25,19,WHITE); - display.drawLine(120,18,120,19,WHITE); - display.drawLine(25,29,120,29,WHITE); - display.drawLine(25,27,25,28,WHITE); - display.drawLine(120,27,120,28,WHITE); - display.setCursor(0,35); - display.println("SNS"); - //display.drawLine(25,38,120,38,WHITE); - display.drawLine(25,36,25,40,WHITE); - display.drawLine(120,36,120,40,WHITE); - display.setCursor(0,50); - display.println("MAX"); - display.drawLine(25,47,120,47,WHITE); - display.drawLine(25,48,25,49,WHITE); - display.drawLine(120,48,120,49,WHITE); - display.drawLine(25,60,120,60,WHITE); - display.drawLine(25,58,25,59,WHITE); - display.drawLine(120,58,120,59,WHITE); - - //display.drawLine(38,20,38,26,WHITE); // indikation thr - pos1 = map(extracThrVal, extracLoLimit, extracHiLimit, 27, 119); - display.drawLine(pos1,20,pos1,26,WHITE); - cursorNow = WHITE; - //display.drawLine(115,50,115,57,WHITE); // indikation max - pos2 = map(extracMaxVal, extracLoLimit, extracHiLimit, 27, 119); - display.drawLine(pos2,50,pos2,57,WHITE); - //display.drawPixel(34, 38, WHITE); - drawAdjCursor(WHITE); - display.display(); -} - - -void drawCtouchScreen(){ - // Clear the buffer. - display.clearDisplay(); - - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(25,2); - display.println("TOUCH SENSE"); - //display.drawLine(0,10,127,10,WHITE); - display.setCursor(0,20); - display.println("THR"); - display.drawLine(25,17,120,17,WHITE); - display.drawLine(25,18,25,19,WHITE); - display.drawLine(120,18,120,19,WHITE); - display.drawLine(25,29,120,29,WHITE); - display.drawLine(25,27,25,28,WHITE); - display.drawLine(120,27,120,28,WHITE); - display.setCursor(0,35); - display.println("SNS"); - //display.drawLine(25,38,120,38,WHITE); - display.drawLine(25,36,25,40,WHITE); - display.drawLine(120,36,120,40,WHITE); - - //display.drawLine(38,20,38,26,WHITE); // indikation thr - pos1 = map(ctouchThrVal, ctouchLoLimit, ctouchHiLimit, 27, 119); - display.drawLine(pos1,20,pos1,26,WHITE); - cursorNow = WHITE; - - //display.drawPixel(34, 38, WHITE); - drawAdjCursor(WHITE); - display.display(); -} - -void drawMenuCursor(byte itemNo, byte color){ - byte xmid = 6 + 9 * itemNo; - display.drawTriangle(57,xmid,61,xmid+2,61,xmid-2,color); -} - -void drawAdjCursor(byte color){ - display.drawTriangle(16,4,20,4,18,1,color); - display.drawTriangle(16,6,20,6,18,9,color); -} - -void drawMenuScreen(){ - - //Construct the title including voltage reading. - //Involves intricate splicing of the title string with battery voltage - char menuTitle[] = "MENU XXX Y.Y "; //Allocate string buffer of appropriate size with some placeholders - char* splice1 = menuTitle + 13; - char* splice2 = menuTitle + 17; - - int vMeterReading = analogRead(vMeterPin); - memcpy(splice1, (vMeterReading > 3000) ? "USB" : "BAT", 3); - if (vMeterReading < 2294) { - memcpy(splice2, "LOW ", 3); - } else { - double voltage = map(vMeterReading,0,3030,0,50)*0.1; - dtostrf(voltage, 3, 1, splice2); - splice2[3]='V'; //Put the V at the end (last char of buffer before \0) - } - - drawMenu(menuTitle, mainMenuCursor, 6, - "TRANSPOSE", - "OCTAVE", - "MIDI CH", - "ADJUST", - "SETUP BR", - "SETUP CTL"); -} - -void drawRotatorMenuScreen(){ - drawMenu("ROTATOR SETUP", rotatorMenuCursor, 6, - "PARALLEL", - "ROTATE 1", - "ROTATE 2", - "ROTATE 3", - "ROTATE 4", - "PRIORITY"); -} - -void drawPatchView(){ - display.clearDisplay(); - if (FPD){ - drawTrills(); - } - if (FPD < 2){ - display.setTextColor(WHITE); - display.setTextSize(6); - if (patch < 10){ - // 1-9 - display.setCursor(48,10); - } else if (patch < 100){ - // 10-99 - display.setCursor(31,10); - } else { - // 99-128 - display.setCursor(10,10); - } - display.println(patch); - } else if (FPD == 2){ - display.setTextColor(WHITE); - display.setTextSize(6); - display.setCursor(10,10); - display.println("SET"); - } else { - display.setTextColor(WHITE); - display.setTextSize(6); - display.setCursor(10,10); - display.println("CLR"); - } - display.display(); -} - -void drawTrills(){ - if (K5) display.fillRect(0,0,5,5,WHITE); else display.drawRect(0,0,5,5,WHITE); - if (K6) display.fillRect(10,0,5,5,WHITE); else display.drawRect(10,0,5,5,WHITE); - if (K7) display.fillRect(20,0,5,5,WHITE); else display.drawRect(20,0,5,5,WHITE); -} - -void clearSub(){ - display.fillRect(63,11,64,52,BLACK); -} - -void drawSubTranspose(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("TRANSPOSE"); - plotTranspose(WHITE); - display.display(); -} - -void plotTranspose(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(80,33); - if ((transpose-12) > -1){ - display.println("+"); - display.setCursor(93,33); - display.println(transpose-12); - } else { - display.println("-"); - display.setCursor(93,33); - display.println(abs(transpose-12)); - } -} -void drawSubRotator(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("SEMITONES"); - //plotRotator(WHITE,value); - forceRedraw = 1; - display.display(); -} - -void plotRotator(int color,int value){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(80,33); - if ((value) > -1){ - display.println("+"); - display.setCursor(93,33); - display.println(value); - } else { - display.println("-"); - display.setCursor(93,33); - display.println(abs(value)); - } -} - -void drawSubPriority(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("MONO PRIO"); - plotPriority(WHITE); - display.display(); -} - -void plotPriority(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(79,33); - if (priority){ - display.println("ROT"); - } else { - display.println("MEL"); - } -} - - -void drawSubOctave(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(77,15); - display.println("OCTAVE"); - plotOctave(WHITE); - display.display(); -} - -void plotOctave(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(80,33); - if ((octave-3) > -1){ - display.println("+"); - display.setCursor(93,33); - display.println(octave-3); - } else { - display.println("-"); - display.setCursor(93,33); - display.println(abs(octave-3)); - } -} - -void drawSubMIDI(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("MIDI CHNL"); - plotMIDI(WHITE); - display.display(); -} - -void plotMIDI(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(90,33); - display.println(MIDIchannel); - if (slowMidi){ - display.setTextColor(WHITE); - } else { - display.setTextColor(BLACK); - } - display.setTextSize(1); - display.setCursor(116,51); - display.print("S"); -} - -void drawSubBreathCC(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("BREATH CC"); - plotBreathCC(WHITE); - display.display(); -} - -void plotBreathCC(int color){ - display.setTextColor(color); - display.setTextSize(2); - if (breathCC){ - switch (breathCC){ - case 1: - display.setCursor(83,33); - display.println("MW"); - break; - case 2: - display.setCursor(83,33); - display.println("BR"); - break; - case 3: - display.setCursor(83,33); - display.println("VL"); - break; - case 4: - display.setCursor(83,33); - display.println("EX"); - break; - case 5: - display.setCursor(79,33); - display.println("MW+"); - break; - case 6: - display.setCursor(79,33); - display.println("BR+"); - break; - case 7: - display.setCursor(79,33); - display.println("VL+"); - break; - case 8: - display.setCursor(79,33); - display.println("EX+"); - break; - case 9: - display.setCursor(83,33); - display.println("CF"); - break; - case 10: - display.setCursor(83,33); - display.println("20"); - break; - } - } else { - display.setCursor(79,33); - display.println("OFF"); - } -} - -void drawSubBreathAT(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("BREATH AT"); - plotBreathAT(WHITE); - display.display(); -} - -void plotBreathAT(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(79,33); - if (breathAT){ - display.println("ON"); - } else { - display.println("OFF"); - } -} - -void drawSubVelocity(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(71,15); - display.println("VELOCITY"); - plotVelocity(WHITE); - display.display(); -} - -void plotVelocity(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(79,33); - if (velocity){ - display.println(velocity); - } else { - display.println("DYN"); - } -} - - -void drawSubCurve(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(80,15); - display.println("CURVE"); - plotCurve(WHITE); - display.display(); -} - -void plotCurve(int color){ - display.setTextColor(color); - display.setTextSize(2); - switch (curve){ - case 0: - display.setCursor(83,33); - display.println("-4"); - break; - case 1: - display.setCursor(83,33); - display.println("-3"); - break; - case 2: - display.setCursor(83,33); - display.println("-2"); - break; - case 3: - display.setCursor(83,33); - display.println("-1"); - break; - case 4: - display.setCursor(79,33); - display.println("LIN"); - break; - case 5: - display.setCursor(83,33); - display.println("+1"); - break; - case 6: - display.setCursor(83,33); - display.println("+2"); - break; - case 7: - display.setCursor(83,33); - display.println("+3"); - break; - case 8: - display.setCursor(83,33); - display.println("+4"); - break; - case 9: - display.setCursor(83,33); - display.println("S1"); - break; - case 10: - display.setCursor(83,33); - display.println("S2"); - break; - case 11: - display.setCursor(83,33); - display.println("Z1"); - break; - case 12: - display.setCursor(83,33); - display.println("Z2"); - break; - } -} - - -void drawSubPort(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(71,15); - display.println("PORT/GLD"); - plotPort(WHITE); - display.display(); -} - -void plotPort(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(79,33); - if (portamento == 1){ - display.println("ON"); - } else if (portamento == 2){ - display.println("SW"); - } else { - display.println("OFF"); - } -} - -void drawSubPB(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("PITCHBEND"); - plotPB(WHITE); - display.display(); -} - -void plotPB(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(76,33); - if (PBdepth){ - display.println("1/"); - display.setCursor(101,33); - display.println(PBdepth); - } else { - display.println("OFF"); - } -} - -void drawSubExtra(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("EXTRA CTR"); - plotExtra(WHITE); - display.display(); -} - -void plotExtra(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(79,33); - switch (extraCT){ - case 0: - display.setCursor(79,33); - display.println("OFF"); - break; - case 1: - display.setCursor(83,33); - display.println("MW"); - break; - case 2: - display.setCursor(83,33); - display.println("FP"); - break; - case 3: - display.setCursor(83,33); - display.println("CF"); - break; - case 4: - display.setCursor(83,33); - display.println("SP"); - break; - } -} - -void drawSubVibrato(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(81,15); - display.println("LEVEL"); - plotVibrato(WHITE); - display.display(); -} - -void plotVibrato(int color){ - display.setTextColor(color); - display.setTextSize(2); - if (vibrato){ - display.setCursor(90,33); - display.println(vibrato); - } else { - display.setCursor(79,33); - display.println("OFF"); - } -} - -void drawSubVibSens(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(81,15); - display.println("LEVEL"); - plotVibSens(WHITE); - display.display(); -} - -void plotVibSens(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(90,33); - display.println(vibSens); -} - -void drawSubVibRetn(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(81,15); - display.println("LEVEL"); - plotVibRetn(WHITE); - display.display(); -} - -void plotVibRetn(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(90,33); - display.println(vibRetn); -} - -void drawSubVibSquelch(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(81,15); - display.println("LEVEL"); - plotVibSquelch(WHITE); - display.display(); -} - -void plotVibSquelch(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(83,33); - display.println(vibSquelch); -} - - - -void drawSubVibDirection(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("DIRECTION"); - plotVibDirection(WHITE); - display.display(); -} - -void plotVibDirection(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(79,33); - if (DNWD == vibDirection){ - display.println("NRM"); - } else { - display.println("REV"); - } -} - - - - - - -void drawSubDeglitch(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(71,15); - display.println("DEGLITCH"); - plotDeglitch(WHITE); - display.display(); -} - -void plotDeglitch(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(79,33); - if (deglitch){ - display.println(deglitch); - display.setCursor(105,40); - display.setTextSize(1); - display.println("ms"); - } else { - display.println("OFF"); - } -} -void drawSubPinkyKey(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(68,15); - display.println("PINKY KEY"); - plotPinkyKey(WHITE); - display.display(); -} - -void plotPinkyKey(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(79,33); - if (pinkySetting < 12){ - display.println(pinkySetting - 12); - } else if (pinkySetting == PBD) { - display.println("PBD"); - } else { - display.print("+"); - display.println(pinkySetting - 12); - } -} -void drawSubVelSmpDl(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(69,15); - display.println("VEL DELAY"); - plotVelSmpDl(WHITE); - display.display(); -} - -void plotVelSmpDl(int color){ - display.setTextColor(color); - display.setTextSize(2); - display.setCursor(79,33); - if (velSmpDl){ - display.println(velSmpDl); - display.setCursor(105,40); - display.setTextSize(1); - display.println("ms"); - } else { - display.println("OFF"); - } -} - -void drawSubVelBias(){ - display.fillRect(63,11,64,52,BLACK); - display.drawRect(63,11,64,52,WHITE); - display.setTextColor(WHITE); - display.setTextSize(1); - display.setCursor(72,15); - display.println("VEL BIAS"); - plotVelBias(WHITE); - display.display(); -} - -void plotVelBias(int color){ - display.setTextColor(color); - display.setTextSize(2); - if (velBias){ - display.setCursor(90,33); - display.println(velBias); - } else { - display.setCursor(79,33); - display.println("OFF"); - } -} - -void drawSetupBrMenuScreen(){ - drawMenu("SETUP BREATH", -1, 6, "BREATH CC", "BREATH AT", "VELOCITY", "CURVE", "VEL DELAY", "VEL BIAS"); -} - -void drawSetupCtMenuScreen(){ - drawMenu("SETUP CTRLS", -1, 6, "PORT/GLD", "PITCHBEND", "EXTRA CTR", "VIBRATO", "DEGLITCH", "PINKY KEY"); -} - -void drawVibratoMenuScreen(){ - drawMenu("VIBRATO", -1, 5, "DEPTH","SENSE","RETURN", "SQUELCH", "DIRECTION"); -} - -void drawSensorPixels(){ - int pos,oldpos; - int redraw=0; - if ((state == BREATH_ADJ_IDL) || (state == BREATH_ADJ_THR) || (state == BREATH_ADJ_MAX)){ - pos = map(constrain(pressureSensor, breathLoLimit, breathHiLimit), breathLoLimit, breathHiLimit, 28, 118); - oldpos = map(constrain(lastPressure, breathLoLimit, breathHiLimit), breathLoLimit, breathHiLimit, 28, 118); - if (pos!=oldpos){ - display.drawPixel(oldpos, 38, BLACK); - display.drawPixel(pos, 38, WHITE); - display.display(); - } else if (forcePix) { - display.drawPixel(pos, 38, WHITE); - display.display(); - } - lastPressure=pressureSensor; - } - if ((state == PORTAM_ADJ_IDL) || (state == PORTAM_ADJ_THR) || (state == PORTAM_ADJ_MAX)){ - pos = map(constrain(biteSensor,portamLoLimit,portamHiLimit), portamLoLimit, portamHiLimit, 28, 118); - oldpos = map(constrain(lastBite,portamLoLimit,portamHiLimit), portamLoLimit, portamHiLimit, 28, 118); - if (pos!=oldpos){ - display.drawPixel(oldpos, 38, BLACK); - display.drawPixel(pos, 38, WHITE); - display.display(); - } else if (forcePix) { - display.drawPixel(pos, 38, WHITE); - display.display(); - } - lastBite=biteSensor; - /*if (biteJumper){ - pos = map(constrain(analogRead(bitePin),900,1400), 900, 1400, 28, 118); - display.drawPixel(pos, 40, WHITE); - }*/ - } - if ((state == PITCHB_ADJ_IDL) || (state == PITCHB_ADJ_THR) || (state == PITCHB_ADJ_MAX)){ - pos = map(constrain(pbUp, pitchbLoLimit, pitchbHiLimit), pitchbLoLimit, pitchbHiLimit, 28, 118); - oldpos = map(constrain(lastPbUp, pitchbLoLimit, pitchbHiLimit), pitchbLoLimit, pitchbHiLimit, 28, 118); - if (pos!=oldpos){ - display.drawPixel(oldpos, 38, BLACK); - display.drawPixel(pos, 38, WHITE); - redraw=1; - } else if (forcePix) { - display.drawPixel(pos, 38, WHITE); - redraw=1; - } - pos = map(constrain(pbDn, pitchbLoLimit, pitchbHiLimit), pitchbLoLimit, pitchbHiLimit, 28, 118); - oldpos = map(constrain(lastPbDn, pitchbLoLimit, pitchbHiLimit), pitchbLoLimit, pitchbHiLimit, 28, 118); - if (pos!=oldpos){ - display.drawPixel(oldpos, 38, BLACK); - display.drawPixel(pos, 38, WHITE); - redraw=1; - } else if (forcePix) { - display.drawPixel(pos, 38, WHITE); - redraw=1; - } - if (redraw){ - display.display(); - redraw=0; - } - lastPbUp=pbUp; - lastPbDn=pbDn; - } - if ((state == EXTRAC_ADJ_IDL) || (state == EXTRAC_ADJ_THR) || (state == EXTRAC_ADJ_MAX)){ - pos = map(constrain(exSensor, extracLoLimit, extracHiLimit), extracLoLimit, extracHiLimit, 28, 118); - oldpos = map(constrain(lastEx, extracLoLimit, extracHiLimit), extracLoLimit, extracHiLimit, 28, 118); - if (pos!=oldpos){ - display.drawPixel(oldpos, 38, BLACK); - display.drawPixel(pos, 38, WHITE); - display.display(); - } else if (forcePix) { - display.drawPixel(pos, 38, WHITE); - display.display(); - } - lastEx=exSensor; - } - if ((state == CTOUCH_ADJ_IDL) || (state == CTOUCH_ADJ_THR)){ - display.drawLine(28,38,118,38,BLACK); - for (byte i=0; i<12; i++){ - pos = map(constrain(touchSensor.filteredData(i), ctouchLoLimit, ctouchHiLimit), ctouchLoLimit, ctouchHiLimit, 28, 118); - display.drawPixel(pos, 38, WHITE); - } - int posRead = map(touchRead(halfPitchBendKeyPin),ttouchLoLimit,ttouchHiLimit,ctouchHiLimit,ctouchLoLimit); - pos = map(constrain(posRead, ctouchLoLimit, ctouchHiLimit), ctouchLoLimit, ctouchHiLimit, 28, 118); - display.drawPixel(pos, 38, WHITE); - posRead = map(touchRead(specialKeyPin),ttouchLoLimit,ttouchHiLimit,ctouchHiLimit,ctouchLoLimit); - pos = map(constrain(posRead, ctouchLoLimit, ctouchHiLimit), ctouchLoLimit, ctouchHiLimit, 28, 118); - display.drawPixel(pos, 38, WHITE); - display.display(); - } - forcePix = 0; -} - -void writeSetting(byte address, unsigned short value){ - union { - byte v[2]; - unsigned short val; - } data; - data.val = value; - EEPROM.write(address, data.v[0]); - EEPROM.write(address+1, data.v[1]); -} - -unsigned short readSetting(byte address){ - union { - byte v[2]; - unsigned short val; - } data; - data.v[0] = EEPROM.read(address); - data.v[1] = EEPROM.read(address+1); - return data.val; -} - - -//*********************************************************** - -int readTrills() { - readSwitches(); - return K5+2*K6+4*K7; -} - -//*********************************************************** - -void setFPS(int trills) { - fastPatch[trills-1] = patch; - writeSetting(FP1_ADDR+2*(trills-1),patch); - FPD = 2; -} - -//*********************************************************** - -void clearFPS(int trills) { - fastPatch[trills-1] = 0; - writeSetting(FP1_ADDR+2*(trills-1),0); - FPD = 3; -} - - - -/* - * Draw a regular list of text menu items - * header - first header line - * selectedItem - the currently selected item (draw a triangle next to it). -1 for none. 1..nItems (1-based, 0 is header row) - * nItems - number of menu items - * ... - a list (nItems long) of text items to show - */ -void drawMenu(const char* header, byte selected, byte nItems, ...) { - - //Initialize display and draw menu header + line - display.clearDisplay(); - display.setTextSize(1); - display.setTextColor(WHITE); - display.setCursor(0,0); - display.println(header); - display.drawLine(0,MENU_ROW_HEIGHT,127,MENU_ROW_HEIGHT, WHITE); - - va_list valist; - va_start(valist, nItems); - for(byte row=0; row=0) drawMenuCursor(selected, WHITE); - - va_end(valist); - - display.display(); } diff --git a/NuEVI/menu.h b/NuEVI/menu.h index 3af87f8..79a2030 100644 --- a/NuEVI/menu.h +++ b/NuEVI/menu.h @@ -1,6 +1,7 @@ #ifndef __MENU_H #define __MENU_H +#include "Wiring.h" #define MENU_ROW_HEIGHT 9 #define MENU_HEADER_OFFSET 3 @@ -34,10 +35,11 @@ extern byte subVibSquelch; - void initDisplay(); void showVersion(); void menu(); void drawSensorPixels(); +unsigned short readSetting(byte address); +void writeSetting(byte address, unsigned short value); #endif diff --git a/NuEVI/settings.h b/NuEVI/settings.h new file mode 100644 index 0000000..112cad3 --- /dev/null +++ b/NuEVI/settings.h @@ -0,0 +1,94 @@ + +#ifndef __SETTINGS_H +#define __SETTINGS_H + + + +// EEPROM addresses for settings +#define VERSION_ADDR 0 +#define BREATH_THR_ADDR 2 +#define BREATH_MAX_ADDR 4 +#define PORTAM_THR_ADDR 6 +#define PORTAM_MAX_ADDR 8 +#define PITCHB_THR_ADDR 10 +#define PITCHB_MAX_ADDR 12 +#define TRANSP_ADDR 14 +#define MIDI_ADDR 16 +#define BREATH_CC_ADDR 18 +#define BREATH_AT_ADDR 20 +#define VELOCITY_ADDR 22 +#define PORTAM_ADDR 24 +#define PB_ADDR 26 +#define EXTRA_ADDR 28 +#define VIBRATO_ADDR 30 +#define DEGLITCH_ADDR 32 +#define EXTRAC_THR_ADDR 34 +#define EXTRAC_MAX_ADDR 36 +#define PATCH_ADDR 38 +#define OCTAVE_ADDR 40 +#define CTOUCH_THR_ADDR 42 +#define BREATHCURVE_ADDR 44 +#define VEL_SMP_DL_ADDR 46 +#define VEL_BIAS_ADDR 48 +#define PINKY_KEY_ADDR 50 +#define FP1_ADDR 52 +#define FP2_ADDR 54 +#define FP3_ADDR 56 +#define FP4_ADDR 58 +#define FP5_ADDR 60 +#define FP6_ADDR 62 +#define FP7_ADDR 64 +#define DIPSW_BITS_ADDR 66 +#define PARAL_ADDR 68 +#define ROTN1_ADDR 70 +#define ROTN2_ADDR 72 +#define ROTN3_ADDR 74 +#define ROTN4_ADDR 76 +#define PRIO_ADDR 78 +#define VIB_SENS_ADDR 80 +#define VIB_RETN_ADDR 82 +#define VIB_SQUELCH_ADDR 84 +#define VIB_DIRECTION_ADDR 86 + +//"factory" values for settings +#define VERSION 31 +#define BREATH_THR_FACTORY 1400 +#define BREATH_MAX_FACTORY 4000 +#define PORTAM_THR_FACTORY 2600 +#define PORTAM_MAX_FACTORY 3300 +#define PORTPR_THR_FACTORY 1200 +#define PORTPR_MAX_FACTORY 2000 +#define PITCHB_THR_FACTORY 1400 +#define PITCHB_MAX_FACTORY 2300 +#define EXTRAC_THR_FACTORY 1200 +#define EXTRAC_MAX_FACTORY 2400 +#define TRANSP_FACTORY 12 // 12 is 0 transpose +#define MIDI_FACTORY 1 // 1-16 +#define BREATH_CC_FACTORY 2 //thats CC#2, see ccList +#define BREATH_AT_FACTORY 0 //aftertouch default off +#define VELOCITY_FACTORY 0 // 0 is dynamic/breath controlled velocity +#define PORTAM_FACTORY 2 // 0 - OFF, 1 - ON, 2 - SW +#define PB_FACTORY 1 // 0 - OFF, 1 - 12 +#define EXTRA_FACTORY 2 // 0 - OFF, 1 - Modulation wheel, 2 - Foot pedal, 3 - Filter Cutoff, 4 - Sustain pedal +#define VIBRATO_FACTORY 4 // 0 - OFF, 1 - 9 depth +#define DEGLITCH_FACTORY 20 // 0 - OFF, 5 to 70 ms in steps of 5 +#define PATCH_FACTORY 1 // MIDI program change 1-128 +#define OCTAVE_FACTORY 3 // 3 is 0 octave change +#define CTOUCH_THR_FACTORY 125 // MPR121 touch threshold +#define BREATHCURVE_FACTORY 4 // 0 to 12 (-4 to +4, S1 to S4) +#define VEL_SMP_DL_FACTORY 15 // 0 to 30 +#define VEL_BIAS_FACTORY 0 // 0 to 9 +#define PINKY_KEY_FACTORY 12 // 0 - 11 (QuickTranspose -12 to -1), 12 (pb/2), 13 - 22 (QuickTranspose +1 to +12) +#define DIPSW_BITS_FACTORY 0 // virtual dip switch settings for special modes (work in progress) +#define PARAL_FACTORY 31 // 7 (+ 24) Rotator parallel +#define ROTN1_FACTORY 19 // -5 (+24) Rotation 1 +#define ROTN2_FACTORY 14 // -10 (+24) Rotation 2 +#define ROTN3_FACTORY 17 // -7 (+24) Rotation 3 +#define ROTN4_FACTORY 10 // -14 (+24) Rotation 4 +#define PRIO_FACTORY 0 // Mono priority 0 - BAS(e note), 1 - ROT(ating note) +#define VIB_SENS_FACTORY 6 // 1 least sensitive, higher more sensitive +#define VIB_RETN_FACTORY 2 // 0, no return, 1 slow return, higher faster return +#define VIB_SQUELCH_FACTORY 15 // 0 to 30, vib signal squelch +#define VIB_DIRECTION_FACTORY 0 + +#endif