Made the sensor adjust menu driven by data

* Moved menu titles and option names into data structures.
 * Unified select menu option code
 * Also unified handling of menu selection, although main and rotator menus are still handled the old way.
 * Moved struct definitions to numenu.h
 * Grouped functions and variables together based on usage.
This commit is contained in:
Mikael Degerfält 2019-06-16 14:36:03 +02:00
parent 9a0bb369ac
commit 0d0ea5051d
6 changed files with 663 additions and 1033 deletions

View file

@ -87,19 +87,19 @@ int parallel = 7; // semitones
byte gateOpen = 0; // setting for gate always open, note on sent for every time fingering changes, no matter the breath status
// MAybe move these to config.h (as defines?)
const int breathLoLimit = 0;
const int breathHiLimit = 4095;
const int portamLoLimit = 700;
const int portamHiLimit = 4700;
const int pitchbLoLimit = 500;
const int pitchbHiLimit = 4000;
const int extracLoLimit = 500;
const int extracHiLimit = 4000;
const int ctouchLoLimit = 50;
const int ctouchHiLimit = 350;
const int ttouchLoLimit = 50;
const int ttouchHiLimit = 1900;
// // MAybe move these to config.h (as defines?)
// const uint16_t breathLoLimit = 0;
// const uint16_t breathHiLimit = 4095;
// const uint16_t portamLoLimit = 700;
// const uint16_t portamHiLimit = 4700;
// const uint16_t pitchbLoLimit = 500;
// const uint16_t pitchbHiLimit = 4000;
// const uint16_t extracLoLimit = 500;
// const uint16_t extracHiLimit = 4000;
// const uint16_t ctouchLoLimit = 50;
// const uint16_t ctouchHiLimit = 350;
// const uint16_t ttouchLoLimit = 50;
// const uint16_t ttouchHiLimit = 1900;
int touch_Thr = 1300;
@ -1214,9 +1214,9 @@ void extraController() {
void portamento_() {
// Portamento is controlled with the bite sensor (variable capacitor) in the mouthpiece
if (biteJumper){ //PBITE (if pulled low with jumper, use pressure sensor on A7)
biteSensor=analogRead(A7); // alternative kind bite sensor (air pressure tube and sensor) PBITE
biteSensor = analogRead(A7); // alternative kind bite sensor (air pressure tube and sensor) PBITE
} else {
biteSensor=touchRead(bitePin); // get sensor data, do some smoothing - SENSOR PIN 17 - PCB PINS LABELED "BITE" (GND left, sensor pin right)
biteSensor = touchRead(bitePin); // get sensor data, do some smoothing - SENSOR PIN 17 - PCB PINS LABELED "BITE" (GND left, sensor pin right)
}
if (portamento && (biteSensor >= portamThrVal)) { // if we are enabled and over the threshold, send portamento
if (!portIsOn) {

View file

@ -21,4 +21,19 @@
#define CC_INTERVAL 2
// MAybe move these to config.h (as defines?)
#define breathLoLimit 0
#define breathHiLimit 4095
#define portamLoLimit 700
#define portamHiLimit 4700
#define pitchbLoLimit 500
#define pitchbHiLimit 4000
#define extracLoLimit 500
#define extracHiLimit 4000
#define ctouchLoLimit 50
#define ctouchHiLimit 350
#define ttouchLoLimit 50
#define ttouchHiLimit 1900
#endif

View file

@ -40,19 +40,6 @@ extern byte currentRotation;
extern int rotations[4];
extern int parallel; // semitones
extern const int breathLoLimit;
extern const int breathHiLimit;
extern const int portamLoLimit;
extern const int portamHiLimit;
extern const int pitchbLoLimit;
extern const int pitchbHiLimit;
extern const int extracLoLimit;
extern const int extracHiLimit;
extern const int ctouchLoLimit;
extern const int ctouchHiLimit;
extern const int ttouchLoLimit;
extern const int ttouchHiLimit;
extern int touch_Thr;
extern unsigned long cursorBlinkTime; // the last time the cursor was toggled

File diff suppressed because it is too large Load diff

View file

@ -11,28 +11,13 @@
#define DISPLAYOFF_IDL 0
#define MAIN_MENU 1
#define PATCH_VIEW 2
#define BREATH_ADJ_IDL 10
#define BREATH_ADJ_THR 11
#define BREATH_ADJ_MAX 12
#define PORTAM_ADJ_IDL 20
#define PORTAM_ADJ_THR 21
#define PORTAM_ADJ_MAX 22
#define PITCHB_ADJ_IDL 30
#define PITCHB_ADJ_THR 31
#define PITCHB_ADJ_MAX 32
#define EXTRAC_ADJ_IDL 40
#define EXTRAC_ADJ_THR 41
#define EXTRAC_ADJ_MAX 42
#define VIBRAT_ADJ_IDL 50
#define VIBRAT_ADJ_THR 51
#define VIBRAT_ADJ_DPT 52
#define CTOUCH_ADJ_IDL 60
#define CTOUCH_ADJ_THR 61
#define ADJUST_MENU 70
#define SETUP_BR_MENU 80
#define SETUP_CT_MENU 90
#define ROTATOR_MENU 100
#define VIBRATO_MENU 110
extern byte subVibSquelch;
void initDisplay();

View file

@ -1,31 +1,66 @@
#ifndef __NUMENU_H
#define __NUMENU_H
#include <cstdint>
#include <functional>
//***********************************************************
#define MAX_DEPTH 16
class Adafruit_SSD1306;
class NuMenu
{
public:
NuMenu(Adafruit_SSD1306 &gfx);
bool init();
void update(uint16_t buttonState);
void setEnabled(bool state) { _enabled = state; }
static void drawMenuItems(const char* title, const char* entries[], int count, int selection, int offset = 0);
private:
bool _enabled;
// MenuPageState _rootMenu;
// MenuPageState _pageStack[MAX_DEPTH];
Adafruit_SSD1306 &_display;
enum MenuType {
ESub,
ESubRotator,
EStateChange,
};
struct MenuEntry {
enum MenuType type;
const char* title;
};
struct MenuEntrySub {
enum MenuType type;
const char* title;
const char* subTitle;
byte* flag;
void (*subMenuFunc)(int color);
};
struct MenuEntrySubRotator {
enum MenuType type;
const char* title;
const char* subTitle;
byte flagValue;
byte* flag;
void (*subMenuFunc)(int color);
};
struct MenuEntryStateCh {
enum MenuType type;
const char* title;
byte state;
};
struct MenuPage {
const char* title;
byte cursor;
byte parentPage;
byte numEntries;
const MenuEntry** entries;
};
//***********************************************************
struct AdjustValue {
uint16_t *value;
uint16_t limitLow;
uint16_t limitHigh;
};
struct AdjustMenuEntry {
const char* title;
AdjustValue entries[2];
void (*saveFunc)(const AdjustMenuEntry&);
};
#endif