Merge pull request #6 from blind/made-to-c

Renamed menu.ino to menu.cpp
This commit is contained in:
John Stäck 2019-06-06 23:00:42 +02:00 committed by GitHub
commit 5a3ccec2e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 1638 additions and 1436 deletions

View file

@ -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;

24
NuEVI/config.h Normal file
View file

@ -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

125
NuEVI/globals.h Normal file
View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -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

94
NuEVI/settings.h Normal file
View file

@ -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