Add settings for fast boot, bcas mode, 3rd trill, dac out

This commit is contained in:
John Stäck 2019-07-25 00:51:34 +02:00
parent c38adcd56c
commit 7b179d4343
6 changed files with 99 additions and 76 deletions

View file

@ -80,6 +80,11 @@ unsigned short vibControl = 0;
unsigned short fastPatch[7] = {0,0,0,0,0,0,0};
uint16_t bcasMode; //Legacy CASSIDY compile flag
uint16_t trill3_interval;
uint16_t fastBoot;
uint16_t dacMode;
byte rotatorOn = 0;
byte currentRotation = 0;
uint16_t rotations[4]; // semitones { -5, -10, -7, -14 };
@ -262,14 +267,16 @@ void setup() {
//Read eeprom data into global vars
readEEPROM(factoryReset);
readEEPROM();
//Parse out flags from bit field
fastBoot = dipSwBits & (1<<0);
legacy = dipSwBits & (1<<1);
legacyBrAct = dipSwBits & (1<<2);
slowMidi = dipSwBits & (1<<3);
gateOpenEnable = dipSwBits & (1<<4);
specialKeyEnable = dipSwBits & (1<<5);
bcasMode = dipSwBits & (1<<6);
activePatch = patch;
touch_Thr = map(ctouchThrVal,ctouchHiLimit,ctouchLoLimit,ttouchLoLimit,ttouchHiLimit);
@ -295,8 +302,9 @@ void setup() {
breathCalZero += analogRead(breathSensorPin);
if (biteJumper) vibZeroBite += analogRead(A7); else vibZeroBite += touchRead(bitePin);
digitalWrite( statusLedPin, i&1 );
delay(250);
delay(fastBoot?75:250); //Shorter delay for fastboot
}
vibZero /= sampleCount;
breathCalZero /= sampleCount;
vibZeroBite /= sampleCount;
@ -306,6 +314,7 @@ void setup() {
vibThrBite = vibZeroBite - vibSquelchBite;
vibThrBiteLo = vibZeroBite + vibSquelchBite;
if(!fastBoot) {
digitalWrite(statusLedPin, LOW);
delay(250);
digitalWrite(statusLedPin,HIGH);
@ -315,6 +324,7 @@ void setup() {
showVersion();
delay(1500);
}
mainState = NOTE_OFF; // initialize main state machine
@ -359,54 +369,37 @@ void loop() {
mainState = RISE_WAIT; // Go to next state
}
if (legacy || legacyBrAct) {
#if defined(CASSIDY)
if (((pbUp > ((pitchbMaxVal + pitchbThrVal) / 2)) && (pbDn > ((pitchbMaxVal + pitchbThrVal) / 2)) && legacy) ||
((analogRead(breathSensorPin) < breathCalZero - 900) && legacyBrAct)) { // both pb pads touched or br suck
#else
if (((pbUp > ((pitchbMaxVal + pitchbThrVal) / 2)) && (pbDn > ((pitchbMaxVal + pitchbThrVal) / 2)) && legacy) ||
((analogRead(breathSensorPin) < breathCalZero - 800) && legacyBrAct && (pbUp > (pitchbMaxVal + pitchbThrVal) / 2) && (pbDn < (pitchbMaxVal + pitchbThrVal) / 2))) { // both pb pads touched or br suck
#endif
bool bothPB = (pbUp > ((pitchbMaxVal + pitchbThrVal) / 2)) && (pbDn > ((pitchbMaxVal + pitchbThrVal) / 2));
bool brSuck = analogRead(breathSensorPin) < (breathCalZero - (bcasMode?900:800));
if (
(bothPB && legacy) ||
(brSuck && legacyBrAct && (bothPB || bcasMode))
) { // both pb pads touched or br suck
fingeredNoteUntransposed = patchLimit(fingeredNoteUntransposed + 1);
if (exSensor >= ((extracThrVal + extracMaxVal) / 2)) { // instant midi setting
if ((fingeredNoteUntransposed >= 73) && (fingeredNoteUntransposed <= 88)) {
MIDIchannel = fingeredNoteUntransposed - 72; // Mid C and up
#if !defined(CASSIDY)
digitalWrite(statusLedPin, LOW);
delay(150);
digitalWrite(statusLedPin, HIGH);
#endif
}
} else {
if (!pinkyKey) { // note number to patch number
if (patch != fingeredNoteUntransposed) {
patch = fingeredNoteUntransposed;
doPatchUpdate = 1;
#if !defined(CASSIDY)
digitalWrite(statusLedPin, LOW);
delay(150);
digitalWrite(statusLedPin, HIGH);
#endif
}
} else { // hi and lo patch numbers
if (fingeredNoteUntransposed > 75) {
if (patch != patchLimit(fingeredNoteUntransposed + 24)) {
patch = patchLimit(fingeredNoteUntransposed + 24); // add 24 to get high numbers 108 to 127
doPatchUpdate = 1;
#if !defined(CASSIDY)
digitalWrite(statusLedPin, LOW);
delay(150);
digitalWrite(statusLedPin, HIGH);
#endif
}
} else {
if (patch != patchLimit(fingeredNoteUntransposed - 36)) {
patch = patchLimit(fingeredNoteUntransposed - 36); // subtract 36 to get low numbers 0 to 36
doPatchUpdate = 1;
#if !defined(CASSIDY)
digitalWrite(statusLedPin, LOW);
delay(150);
digitalWrite(statusLedPin, HIGH);
#endif
}
}
}
@ -1186,24 +1179,13 @@ void readSwitches() {
}
// Calculate midi note number from pressed keys
#if defined(CASSIDY)
fingeredNoteUntransposed = startNote
- 2*K1 - K2 - 3*K3 //"Trumpet valves"
- 5*K4 //Fifth key
+ 2*K5 + K6 + 3*K7 //Trill keys (different from standard)
+ 2*K5 + K6 + trill3_interval*K7 //Trill keys. 3rd trill key interval controlled by setting
+ octaveR*12; //Octave rollers
#else
fingeredNoteUntransposed = startNote
- 2*K1 - K2 - 3*K3 //"Trumpet valves"
- 5*K4 //Fifth key
+ 2*K5 + K6 + 4*K7 //Trill keys
+ octaveR*12; //Octave rollers
#endif
int fingeredNoteRead = fingeredNoteUntransposed + transpose - 12 + qTransp;
if (pinkyKey) pitchlatch = fingeredNoteUntransposed; //use pitchlatch to make settings based on note fingered

View file

@ -73,6 +73,11 @@ extern byte currentRotation;
extern uint16_t rotations[4];
extern uint16_t parallel; // semitones
extern uint16_t bcasMode; //Legacy CASSIDY compile flag
extern uint16_t trill3_interval;
extern uint16_t fastBoot;
extern uint16_t dacMode;
extern uint16_t wlPower;
extern int touch_Thr;

View file

@ -156,10 +156,6 @@ void initDisplay() {
void showVersion() {
display.setTextColor(WHITE);
display.setTextSize(1);
#if defined(CASSIDY)
display.setCursor(0,0);
display.print("BC");
#endif
#if defined(CVSCALEBOARD)
display.setCursor(15,0);
display.print("CV");
@ -450,6 +446,10 @@ static void midiCustomDrawFunc(SubMenuRef __unused, char* __unused, const char**
}
}
//Poke at a certain bit in a bit field
void setBit(uint16_t &bitfield, const uint8_t pos, const uint8_t value) {
bitfield = (bitfield & ~(1<<pos)) | ((value?1:0)<<pos);
}
//***********************************************************
@ -458,8 +458,7 @@ const MenuEntrySub legacyPBMenu = {
[](SubMenuRef __unused, char* out, const char ** __unused unit) {
strncpy(out, legacy?"ON":"OFF", 4);
}, [](const MenuEntrySub & __unused sub) {
dipSwBits = dipSwBits & ~(1<<1);
dipSwBits |= (legacy <<1);
setBit(dipSwBits, 1, legacy);
writeSetting(DIPSW_BITS_ADDR,dipSwBits);
}
, nullptr
@ -470,8 +469,7 @@ const MenuEntrySub legacyBRMenu = {
[](SubMenuRef __unused, char* out, const char ** __unused unit) {
strncpy(out, legacyBrAct?"ON":"OFF", 4);
}, [](const MenuEntrySub & __unused sub) {
dipSwBits = dipSwBits & ~(1<<2);
dipSwBits |= (legacyBrAct <<2);
setBit(dipSwBits, 2, legacyBrAct);
writeSetting(DIPSW_BITS_ADDR, dipSwBits);
}
, nullptr
@ -482,8 +480,7 @@ const MenuEntrySub gateOpenMenu = {
[](SubMenuRef __unused, char* out, const char ** __unused unit) {
strncpy(out, gateOpenEnable?"ON":"OFF", 4);
}, [](const MenuEntrySub & __unused sub) {
dipSwBits = dipSwBits & ~(1<<4);
dipSwBits |= (gateOpenEnable <<4);
setBit(dipSwBits, 4, gateOpenEnable);
writeSetting(DIPSW_BITS_ADDR, dipSwBits);
}
, nullptr
@ -494,8 +491,50 @@ const MenuEntrySub specialKeyMenu = {
[](SubMenuRef __unused, char* out, const char ** __unused unit) {
strncpy(out, specialKeyEnable?"ON":"OFF", 4);
}, [](const MenuEntrySub & __unused sub) {
dipSwBits = dipSwBits & ~(1<<5);
dipSwBits |= (specialKeyEnable <<5);
setBit(dipSwBits, 5, specialKeyEnable);
writeSetting(DIPSW_BITS_ADDR, dipSwBits);
}
, nullptr
};
const MenuEntrySub trill3Menu = {
MenuType::ESub, "3RD TRILL", "3RD TRILL", &trill3_interval, 3, 4, MenuEntryFlags::ENone,
[](SubMenuRef __unused, char* out, const char** __unused unit) {
numToString(trill3_interval, out, true);
},
[](SubMenuRef __unused) { writeSetting(TRILL3_INTERVAL_ADDR, trill3_interval); }
, nullptr
};
const MenuEntrySub bcasModeMenu = {
MenuType::ESub, "BCAS MODE", "BCAS MODE", &bcasMode, 0, 1, MenuEntryFlags::ENone,
[](SubMenuRef __unused, char* out, const char** __unused unit) {
strncpy(out, bcasMode?"ON":"OFF", 4);
},
[](SubMenuRef __unused) {
setBit(dipSwBits, 6, bcasMode);
writeSetting(DIPSW_BITS_ADDR, dipSwBits);
}
, nullptr
};
const MenuEntrySub dacModeMenu = {
MenuType::ESub, "DAC OUT", "DAC OUT", &dacMode, 0, 1, MenuEntryFlags::ENone,
[](SubMenuRef __unused, char* out, const char** __unused unit) {
const char* dacModeLabels[] = { "BRTH", "PTCH"};
strncpy(out, dacModeLabels[dacMode], 5);
},
[](SubMenuRef __unused) { writeSetting(DAC_MODE_ADDR, dacMode); }
, nullptr
};
const MenuEntrySub fastBootMenu = {
MenuType::ESub, "FAST BOOT", "FAST BOOT", &fastBoot, 0, 1, MenuEntryFlags::ENone,
[](SubMenuRef __unused, char* out, const char** __unused unit) {
strncpy(out, fastBoot?"ON":"OFF", 4);
},
[](SubMenuRef __unused) {
setBit(dipSwBits, 0, fastBoot);
writeSetting(DIPSW_BITS_ADDR, dipSwBits);
}
, nullptr
@ -516,6 +555,10 @@ const MenuEntry* extrasMenuEntries[] = {
(MenuEntry*)&legacyBRMenu,
(MenuEntry*)&gateOpenMenu,
(MenuEntry*)&specialKeyMenu,
(MenuEntry*)&trill3Menu,
(MenuEntry*)&bcasModeMenu,
(MenuEntry*)&dacModeMenu,
(MenuEntry*)&fastBootMenu,
(MenuEntry*)&wlPowerMenu,
};

View file

@ -1,6 +1,9 @@
#include "settings.h"
#include "globals.h"
#include "menu.h"
#include "hardware.h"
#include <Arduino.h>
//Read settings from eeprom. Returns wether or not anything was written (due to factory reset or upgrade)
bool readEEPROM() {
@ -88,11 +91,8 @@ bool readEEPROM() {
writeSetting(VIB_SENS_BITE_ADDR, VIB_SENS_BITE_FACTORY);
writeSetting(VIB_SQUELCH_BITE_ADDR, VIB_SQUELCH_BITE_FACTORY);
writeSetting(VIB_CONTROL_ADDR, VIB_CONTROL_FACTORY);
writeSetting(TRILL3_INTERVAL_ADDR, TRILL3_INTERVAL_FACTORY);
writeSetting(BCAS_MODE_ADDR, BCAS_MODE_FACTORY);
writeSetting(DAC_MODE_ADDR, DAC_MODE_FACTORY);
writeSetting(FASTBOOT_ADDR, FASTBOOT_FACTORY);
}
writeSetting(VERSION_ADDR, EEPROM_VERSION);
@ -150,12 +150,8 @@ bool readEEPROM() {
vibSquelchBite = readSetting(VIB_SQUELCH_BITE_ADDR);
vibControl = readSetting(VIB_CONTROL_ADDR);
bcasMode = readSetting(BCAS_MODE_ADDR);
trill3_interval = readSetting(TRILL3_INTERVAL_ADDR);
if(trill3_interval<3 || trill3_interval > 4) trill3_interval = TRILL3_INTERVAL_FACTORY; //Deal with possible bad values
fastBoot = readSetting(FASTBOOT_ADDR);
dacMode = readSetting(DAC_MODE_ADDR);
return hasWritten;

View file

@ -53,9 +53,7 @@
#define VIB_SQUELCH_BITE_ADDR 94
#define VIB_CONTROL_ADDR 96
#define TRILL3_INTERVAL_ADDR 98
#define BCAS_MODE_ADDR 100
#define DAC_MODE_ADDR 102
#define FASTBOOT_ADDR 104
#define DAC_MODE_ADDR 100
@ -110,9 +108,7 @@
#define VIB_CONTROL_FACTORY 0
#define TRILL3_INTERVAL_FACTORY 4
#define BCAS_MODE_FACTORY 0
#define DAC_MODE_FACTORY DAC_MODE_BREATH
#define FASTBOOT_FACTORY 0
bool readEEPROM();

View file

@ -36,6 +36,7 @@ CXXFILES= ../NuEVI/menu.cpp \
src/simusbmidi.cpp \
src/filters.cpp \
../NuEVI/midi.cpp \
../NuEVI/settings.cpp \
src/Adafruit_GFX_sim.cpp \
src/Adafruit_SSD1306_sim.cpp \
src/Adafruit_MPR121_sim.cpp \