Changes to accomodate new sensors
PB control -> 2d stick Extra -> cap lip sensor Bite -> force sensitive resistor Lever -> pot 2d Stick added
This commit is contained in:
parent
e8aeb26399
commit
b401b34bb4
8 changed files with 150 additions and 143 deletions
|
@ -23,6 +23,7 @@
|
|||
|
||||
// Statup buttons
|
||||
#define STARTUP_FACTORY_RESET 0x3
|
||||
#define STARTUP_TEST 0x2
|
||||
#define STARTUP_CONFIG 0xC
|
||||
#define TEST_CONFIG 0xA
|
||||
#define DEBUG_CONFIG 0x1
|
||||
|
@ -50,7 +51,7 @@
|
|||
|
||||
#define BREATH_LO_LIMIT 9000
|
||||
#define BREATH_HI_LIMIT 12000
|
||||
#define BITE_LO_LIMIT 500
|
||||
#define BITE_LO_LIMIT 0
|
||||
#define BITE_HI_LIMIT 1000
|
||||
#define PITCHB_LO_LIMIT -2000
|
||||
#define PITCHB_HI_LIMIT 2000
|
||||
|
|
|
@ -101,8 +101,11 @@ struct instrument_state_t {
|
|||
int16_t biteSignal = 0; // capacitance data from bite sensor, for midi cc and threshold checks
|
||||
int16_t leverSignal = 0;
|
||||
int16_t pbSignal = 0;
|
||||
int16_t pbYSignal = 0;
|
||||
int16_t extraSignal = 0;
|
||||
int16_t vibSignal = 0;
|
||||
int16_t stickXSignal = 0;
|
||||
int16_t stickYSignal = 0;
|
||||
int16_t avgCTouchSignal = 0;
|
||||
|
||||
// MIDI values
|
||||
|
@ -112,6 +115,9 @@ struct instrument_state_t {
|
|||
byte extraVal = 0; // keep track and make sure we send CC with 0 value when off threshold
|
||||
byte leverVal = 0; // keep track and make sure we send CC with 0 value when off threshold
|
||||
byte pbVal = 0; // keep track and make sure we send CC with 0 value when off threshold
|
||||
byte pbYVal = 0; // keep track and make sure we send CC with 0 value when off threshold
|
||||
byte stickXVal = 0; // keep track and make sure we send CC with 0 value when off threshold
|
||||
byte stickYVal = 0; // keep track and make sure we send CC with 0 value when off threshold
|
||||
int pitchBend = 8192;
|
||||
int pbSend = 8192; // Pitch bend actually sent, modified by vibrato, etc
|
||||
bool pbActive = false; // extra CC selection
|
||||
|
|
|
@ -20,7 +20,6 @@ float sliderMALever = 0.0;
|
|||
|
||||
Adafruit_MPR121 touchSensorKeys = Adafruit_MPR121();
|
||||
Adafruit_MPR121 touchSensorRoller = Adafruit_MPR121();
|
||||
Adafruit_MPR121 touchSensorUtil = Adafruit_MPR121();
|
||||
Adafruit_MPRLS pressureSensorMain = Adafruit_MPRLS();
|
||||
Adafruit_MPRLS pressureSensorAlt = Adafruit_MPRLS();
|
||||
|
||||
|
@ -56,9 +55,6 @@ void initHardware() {
|
|||
tiltFilter.setFilter(LOWPASS, ICM_FILTER_FREQ, 0.0); // create a one pole (RC) lowpass filter
|
||||
rollFilter.setFilter(LOWPASS, ICM_FILTER_FREQ, 0.0); // create a one pole (RC) lowpass filter
|
||||
icmSensor.begin_I2C(ICM20948_I2CADDR_DEFAULT, &MainI2CBus);
|
||||
sliderFilterExtra.setFilter(INTEGRATOR, 0.75, 0.0);
|
||||
sliderFilterLever.setFilter(INTEGRATOR, 0.75, 0.0);
|
||||
sliderFilterPB.setFilter(INTEGRATOR, 0.75, 0.0);
|
||||
|
||||
ledStrip.begin();
|
||||
|
||||
|
@ -72,13 +68,6 @@ void initHardware() {
|
|||
errorWait();
|
||||
}
|
||||
|
||||
if (!touchSensorUtil.begin(UtilI2CAddr, &MainI2CBus)) {
|
||||
displayError("Util touch error");
|
||||
errorWait();
|
||||
}
|
||||
//touchSensorUtil.writeRegister(MPR121_CONFIG1, 0x3f); // default, 16uA charge current
|
||||
//touchSensorUtil.writeRegister(MPR121_CONFIG2, 0xE0); // 0.5uS encoding, 1ms period
|
||||
|
||||
if (!pressureSensorMain.begin(MPRLS_DEFAULT_ADDR, &AuxI2CBus)) {
|
||||
displayError("Main pressure sensor error");
|
||||
errorWait();
|
||||
|
@ -171,18 +160,10 @@ int readTouchRoller(uint8_t n) {
|
|||
return CAP_SENS_ABSOLUTE_MAX - touchSensorRoller.filteredData(n);
|
||||
}
|
||||
|
||||
int readTouchUtil(uint8_t n) {
|
||||
return CAP_SENS_ABSOLUTE_MAX - touchSensorUtil.filteredData(n);
|
||||
}
|
||||
|
||||
uint16_t keysTouched() {
|
||||
return touchSensorKeys.touched();
|
||||
}
|
||||
|
||||
uint16_t utilTouched() {
|
||||
return touchSensorUtil.touched();
|
||||
}
|
||||
|
||||
int readSpikePressure() {
|
||||
return spikeFilter.output();
|
||||
}
|
||||
|
@ -198,47 +179,12 @@ int readAltPressure() {
|
|||
return breathAltFilter.input(pressureSensorAlt.readPressure()) * PRESSURE_SENS_MULTIPLIER;
|
||||
}
|
||||
|
||||
int16_t readSlider(Slider id, int thr) {
|
||||
float filtered = 0.0;
|
||||
float a = 0, b = 0;
|
||||
FilterOnePole *filter;
|
||||
|
||||
int16_t readAnalog(Control id, int thr) {
|
||||
switch (id) {
|
||||
case SLIDER_PITCH_BEND:
|
||||
a = touchSensorUtil.filteredData(pbSliderPin1);
|
||||
b = touchSensorUtil.filteredData(pbSliderPin2);
|
||||
filter = &sliderFilterPB;
|
||||
break;
|
||||
case SLIDER_EXTRA:
|
||||
a = touchSensorRoller.filteredData(extraSliderPin1);
|
||||
b = touchSensorRoller.filteredData(extraSliderPin2);
|
||||
filter = &sliderFilterExtra;
|
||||
/*
|
||||
Serial.print(">a:");
|
||||
Serial.println(a);
|
||||
Serial.print(">b:");
|
||||
Serial.println(b);
|
||||
Serial.print(">thr:");
|
||||
Serial.println(thr);
|
||||
*/
|
||||
break;
|
||||
case SLIDER_LEVER:
|
||||
a = touchSensorUtil.filteredData(leverSliderPin1);
|
||||
b = touchSensorUtil.filteredData(leverSliderPin2);
|
||||
filter = &sliderFilterLever;
|
||||
break;
|
||||
default:
|
||||
return 0.0;
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((a + b) <= (thr + thr - SLIDER_TOUCH_OFFSET)) {
|
||||
filtered = filter->input(a - b);
|
||||
} else {
|
||||
return INT16_MIN;
|
||||
}
|
||||
|
||||
return filtered * 100;
|
||||
}
|
||||
|
||||
icm_result_t readICM() {
|
||||
|
@ -254,25 +200,34 @@ icm_result_t readICM() {
|
|||
};
|
||||
}
|
||||
|
||||
int readRawSlider(Slider id) {
|
||||
float a, b;
|
||||
int readRawControl(Control id) {
|
||||
int a;
|
||||
switch (id) {
|
||||
case SLIDER_PITCH_BEND:
|
||||
a = touchSensorUtil.filteredData(pbSliderPin1);
|
||||
b = touchSensorUtil.filteredData(pbSliderPin2);
|
||||
case CONTROL_PB:
|
||||
a = analogRead(pbXPin);
|
||||
break;
|
||||
case SLIDER_EXTRA:
|
||||
a = touchSensorRoller.filteredData(extraSliderPin1);
|
||||
b = touchSensorRoller.filteredData(extraSliderPin2);
|
||||
case CONTROL_PB_Y:
|
||||
a = analogRead(pbYPin);
|
||||
break;
|
||||
case SLIDER_LEVER:
|
||||
a = touchSensorUtil.filteredData(leverSliderPin1);
|
||||
b = touchSensorUtil.filteredData(leverSliderPin2);
|
||||
case CONTROL_EXTRA:
|
||||
a = readTouchRoller(extraPin);
|
||||
break;
|
||||
case CONTROL_BITE:
|
||||
a = analogRead(bitePin);
|
||||
break;
|
||||
case CONTROL_LEVER:
|
||||
a = analogRead(leverPin);
|
||||
break;
|
||||
case CONTROL_STICK_X:
|
||||
a = analogRead(stickXPin);
|
||||
break;
|
||||
case CONTROL_STICK_Y:
|
||||
a = analogRead(stickYPin);
|
||||
break;
|
||||
default:
|
||||
return 0.0;
|
||||
break;
|
||||
}
|
||||
|
||||
return (a + b) / 2;
|
||||
return a;
|
||||
}
|
||||
|
|
|
@ -21,10 +21,14 @@ struct icm_result_t {
|
|||
float roll;
|
||||
};
|
||||
|
||||
enum Slider : uint8_t {
|
||||
SLIDER_PITCH_BEND = 0,
|
||||
SLIDER_EXTRA = 1,
|
||||
SLIDER_LEVER = 2,
|
||||
enum Control : uint8_t {
|
||||
CONTROL_PB = 0,
|
||||
CONTROL_PB_Y = 1,
|
||||
CONTROL_EXTRA = 2,
|
||||
CONTROL_LEVER = 3,
|
||||
CONTROL_STICK_X = 4,
|
||||
CONTROL_STICK_Y = 5,
|
||||
CONTROL_BITE = 6,
|
||||
};
|
||||
|
||||
|
||||
|
@ -35,11 +39,9 @@ uint8_t buttonState(); // return true if the given buttons are pressed
|
|||
int readKnob(uint8_t n);
|
||||
int readTouchKey(uint8_t n);
|
||||
int readTouchRoller(uint8_t n);
|
||||
int readTouchUtil(uint8_t n);
|
||||
int readRawSlider(Slider id);
|
||||
int16_t readSlider(Slider id, int thr);
|
||||
int readRawControl(Control id);
|
||||
int16_t readControl(Control id, int thr);
|
||||
uint16_t keysTouched();
|
||||
uint16_t utilTouched();
|
||||
int readPressure();
|
||||
int readAltPressure();
|
||||
int readSpikePressure();
|
||||
|
@ -48,8 +50,8 @@ icm_result_t readICM();
|
|||
// xEVI hardware setup
|
||||
|
||||
// I2C
|
||||
#define MainI2CBus Wire1
|
||||
#define AuxI2CBus Wire
|
||||
#define MainI2CBus Wire
|
||||
#define AuxI2CBus Wire1
|
||||
#define KeysI2CAddr 0x5A
|
||||
#define RollerI2CAddr 0x5B
|
||||
#define UtilI2CAddr 0x5C
|
||||
|
@ -61,15 +63,15 @@ icm_result_t readICM();
|
|||
#define b4Pin 0
|
||||
|
||||
// Digital pins for encoder quadrature
|
||||
#define e1aPin 6
|
||||
#define e2aPin 8
|
||||
#define e3aPin 7
|
||||
#define e1aPin 8
|
||||
#define e2aPin 7
|
||||
#define e3aPin 6
|
||||
#define e4aPin 5
|
||||
|
||||
#define e1bPin 22
|
||||
#define e2bPin 21
|
||||
#define e3bPin 20
|
||||
#define e4bPin 23
|
||||
#define e1bPin 12
|
||||
#define e2bPin 11
|
||||
#define e3bPin 10
|
||||
#define e4bPin 9
|
||||
|
||||
// CV pins
|
||||
#define cvGatePin 9
|
||||
|
@ -107,13 +109,14 @@ icm_result_t readICM();
|
|||
#define R5Pin 10
|
||||
#define R6Pin 11
|
||||
|
||||
// Additional pins
|
||||
#define bitePin 0
|
||||
#define barPin 7
|
||||
#define pbSliderPin1 11
|
||||
#define pbSliderPin2 10
|
||||
#define leverSliderPin1 9
|
||||
#define leverSliderPin2 8
|
||||
#define extraSliderPin1 2
|
||||
#define extraSliderPin2 3
|
||||
// Control pins
|
||||
#define extraPin 0
|
||||
#define bitePin A6
|
||||
#define pbXPin A8
|
||||
#define pbYPin A9
|
||||
#define pbBPin 21
|
||||
#define stickXPin A10
|
||||
#define stickYPin A11
|
||||
#define leverPin A1
|
||||
#define stickBPin 14
|
||||
#endif
|
||||
|
|
|
@ -223,7 +223,7 @@ static const unsigned char PROGMEM nuevi_logo_bmp[] = {
|
|||
};
|
||||
|
||||
#define OLED_RESET 4
|
||||
Adafruit_SSD1306 display(128, 64, &Wire1, OLED_RESET, 1000000, 1000000);
|
||||
Adafruit_SSD1306 display(128, 64, &MainI2CBus, OLED_RESET, 1000000, 1000000);
|
||||
int16_t ctouchVal = 0;
|
||||
|
||||
MenuScreen* currentMenu = NULL;
|
||||
|
@ -936,18 +936,21 @@ private:
|
|||
|
||||
|
||||
|
||||
std::array<AdjustValue, 7> adjustValues = { {
|
||||
std::array<AdjustValue, 10> adjustValues = { {
|
||||
{"BREATH", &instrument_state_t::breathSignal, &calibration_t::breathThrValOffset, &calibration_t::breathMaxValOffset,
|
||||
BREATH_LO_LIMIT, BREATH_HI_LIMIT, &instrument_state_t::breathZero},
|
||||
{"BITE",&instrument_state_t::biteSignal, &calibration_t::biteThrVal, &calibration_t::biteMaxVal, BITE_LO_LIMIT, BITE_HI_LIMIT, NULL},
|
||||
{"PB",&instrument_state_t::pbSignal, &calibration_t::pbMinVal, &calibration_t::pbMaxVal, PITCHB_LO_LIMIT, PITCHB_HI_LIMIT, NULL},
|
||||
{"PB Z/DZ",&instrument_state_t::pbSignal, &calibration_t::pbCenterVal, &calibration_t::pbDeadzone, PITCHB_LO_LIMIT, PITCHB_HI_LIMIT, NULL},
|
||||
{"PB Y",&instrument_state_t::pbYSignal, &calibration_t::pbYMinVal, &calibration_t::pbYMaxVal, PITCHB_LO_LIMIT, PITCHB_HI_LIMIT, NULL},
|
||||
{"EXTRA", &instrument_state_t::extraSignal, &calibration_t::extraMinVal, &calibration_t::extraMaxVal, EXTRA_LO_LIMIT, EXTRA_HI_LIMIT, NULL},
|
||||
{"LEVER", &instrument_state_t::leverSignal, &calibration_t::leverMinVal, &calibration_t::leverMaxVal, LEVER_LO_LIMIT, LEVER_HI_LIMIT, NULL},
|
||||
{"STICK X", &instrument_state_t::stickXSignal, &calibration_t::stickXMinVal, &calibration_t::stickXMaxVal, LEVER_LO_LIMIT, LEVER_HI_LIMIT, NULL},
|
||||
{"STICK Y", &instrument_state_t::stickYSignal, &calibration_t::stickYMinVal, &calibration_t::stickYMaxVal, LEVER_LO_LIMIT, LEVER_HI_LIMIT, NULL},
|
||||
{"TOUCH", &instrument_state_t::avgCTouchSignal, &calibration_t::ctouchThrVal, &calibration_t::ctouchThrVal, CTOUCH_LO_LIMIT, CTOUCH_HI_LIMIT, NULL},
|
||||
}};
|
||||
|
||||
AdjustMenuScreen<7> adjustMenu("ADJUST", adjustValues);
|
||||
AdjustMenuScreen<10> adjustMenu("ADJUST", adjustValues);
|
||||
|
||||
|
||||
//***********************************************************
|
||||
|
@ -1005,6 +1008,9 @@ ChoiceMenu<4, ExtraControl> extraCtlMenu("EXT CTL", &preset_t::extraControl, { {
|
|||
PresetValueMenu<128, uint8_t> extraCCMenu("EXT CC", &preset_t::extraCC, 0, 127, true, CC_NAMES);
|
||||
ChoiceMenu<6, ExtraControl> pbCtlMenu("PB CTL", &preset_t::pbControl, { {OFF, VIBRATO, GLIDE, CC, BEND, VIB_BEND} }, { "OFF", "VIBRATO", "GLIDE", "CC", "BEND", "VIB_BEND" });
|
||||
PresetValueMenu<128, uint8_t> pbCCMenu("PB CC", &preset_t::pbCC, 0, 127, true, CC_NAMES);
|
||||
PresetValueMenu<128, uint8_t> pbYCCMenu("PB Y CC", &preset_t::pbYCC, 0, 127, true, CC_NAMES);
|
||||
PresetValueMenu<128, uint8_t> stickXCCMenu("STICK X CC", &preset_t::stickXCC, 0, 127, true, CC_NAMES);
|
||||
PresetValueMenu<128, uint8_t> stickYCCMenu("STICK Y CC", &preset_t::stickYCC, 0, 127, true, CC_NAMES);
|
||||
ChoiceMenu<4, ExtraControl> tiltModeMenu("TILT MODE", &preset_t::icmTiltMode, { {OFF, VIBRATO, GLIDE, CC} }, { "OFF", "VIBRATO", "GLIDE", "CC" });
|
||||
PresetValueMenu<128, uint8_t> tiltCCMenu("TILT CC", &preset_t::icmTiltCC, 0, 127, true, CC_NAMES);
|
||||
ChoiceMenu<4, ExtraControl> rollModeMenu("ROLL MODE", &preset_t::icmRollMode, { {OFF, VIBRATO, GLIDE, CC} }, { "OFF", "VIBRATO", "GLIDE", "CC" });
|
||||
|
@ -1082,7 +1088,7 @@ std::array<MenuScreen *const, 11> breathMenuEntries = {
|
|||
};
|
||||
SubMenu<11> breathMenu("BR SETUP", breathMenuEntries);
|
||||
|
||||
const std::array<MenuScreen *const, 22> controlMenuEntries = {
|
||||
const std::array<MenuScreen *const, 25> controlMenuEntries = {
|
||||
&fingeringMenu,
|
||||
&polyMenu,
|
||||
&rollerMenu,
|
||||
|
@ -1090,6 +1096,9 @@ const std::array<MenuScreen *const, 22> controlMenuEntries = {
|
|||
&biteCCMenu,
|
||||
&pbCtlMenu,
|
||||
&pbCCMenu,
|
||||
&pbYCCMenu,
|
||||
&stickXCCMenu,
|
||||
&stickYCCMenu,
|
||||
&leverCtlMenu,
|
||||
&leverCCMenu,
|
||||
&extraCtlMenu,
|
||||
|
@ -1106,7 +1115,7 @@ const std::array<MenuScreen *const, 22> controlMenuEntries = {
|
|||
&accelModeMenu,
|
||||
&accelCCMenu,
|
||||
};
|
||||
SubMenu<22> controlMenu("CTL SETUP", controlMenuEntries);
|
||||
SubMenu<25> controlMenu("CTL SETUP", controlMenuEntries);
|
||||
|
||||
const std::array<MenuScreen *const, 5> vibratoMenuEntries = {
|
||||
&vibDepthMenu,
|
||||
|
@ -1249,7 +1258,7 @@ void initDisplay() {
|
|||
// internally, this will display the splashscreen.
|
||||
|
||||
display.clearDisplay();
|
||||
display.setRotation(2);
|
||||
display.setRotation(0);
|
||||
display.drawBitmap(0, 0, nuevi_logo_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT, 1);
|
||||
display.display();
|
||||
currentMenu = &statusMenu;
|
||||
|
|
|
@ -35,7 +35,13 @@ struct calibration_t {
|
|||
int16_t extraMinVal = -1000;
|
||||
int16_t extraMaxVal = 1000;
|
||||
int16_t ctouchThrVal = 900;
|
||||
uint8_t _reserved[24];
|
||||
int16_t pbYMinVal = 0;
|
||||
int16_t pbYMaxVal = 1000;
|
||||
int16_t stickXMinVal = 0;
|
||||
int16_t stickXMaxVal = 1000;
|
||||
int16_t stickYMinVal = 0;
|
||||
int16_t stickYMaxVal = 1000;
|
||||
uint8_t _reserved[12];
|
||||
};
|
||||
|
||||
static_assert(sizeof(calibration_t) == CALIBRATION_MAX_SIZE, "calibration data wrong size");
|
||||
|
@ -97,8 +103,11 @@ struct preset_t {
|
|||
PolySelect polyMode = PolySelect::EHarmonizerOff;
|
||||
ExtraControl pbControl = ExtraControl::VIB_BEND;
|
||||
uint8_t pbCC = 12; // extra CC selection
|
||||
uint8_t pbYCC = 13; // pbY CC selection
|
||||
uint8_t stickXCC = 14; // stickX CC selection
|
||||
uint8_t stickYCC = 15; // stickY CC selection
|
||||
|
||||
uint8_t _reserved[80];
|
||||
uint8_t _reserved[77];
|
||||
};
|
||||
|
||||
static_assert(sizeof(preset_t) == PRESET_MAX_SIZE, "preset_t must be 128 bytes");
|
||||
|
|
|
@ -12,7 +12,25 @@ void handleTestMode(state_t &state) {
|
|||
Serial.print("Buttons:");
|
||||
Serial.println(buttons, HEX);
|
||||
}
|
||||
/*
|
||||
Serial.print(">KnobE1aPin:");
|
||||
Serial.println(digitalRead(e1aPin));
|
||||
Serial.print(">KnobE2aPin:");
|
||||
Serial.println(digitalRead(e2aPin));
|
||||
Serial.print(">KnobE3aPin:");
|
||||
Serial.println(digitalRead(e3aPin));
|
||||
Serial.print(">KnobE4aPin:");
|
||||
Serial.println(digitalRead(e4aPin));
|
||||
|
||||
Serial.print(">KnobE1bPin:");
|
||||
Serial.println(digitalRead(e1bPin));
|
||||
Serial.print(">KnobE2bPin:");
|
||||
Serial.println(digitalRead(e2bPin));
|
||||
Serial.print(">KnobE3bPin:");
|
||||
Serial.println(digitalRead(e3bPin));
|
||||
Serial.print(">KnobE4bPin:");
|
||||
Serial.println(digitalRead(e4bPin));
|
||||
*/
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int k = readKnob(i);
|
||||
if (k != 0) {
|
||||
|
@ -30,13 +48,6 @@ void handleTestMode(state_t &state) {
|
|||
oldKeys = keys;
|
||||
}
|
||||
|
||||
uint16_t util = utilTouched();
|
||||
if (util != oldUtil) {
|
||||
Serial.print("Util:");
|
||||
Serial.println(util, HEX);
|
||||
oldUtil = util;
|
||||
}
|
||||
|
||||
if (buttons == 0x01) {
|
||||
plotCap = !plotCap;
|
||||
}
|
||||
|
@ -46,18 +57,11 @@ void handleTestMode(state_t &state) {
|
|||
}
|
||||
|
||||
if (plotCap) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
Serial.print(">key");
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Serial.print(">control");
|
||||
Serial.print(i);
|
||||
Serial.print(":");
|
||||
Serial.println(readTouchKey(i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
Serial.print(">util");
|
||||
Serial.print(i);
|
||||
Serial.print(":");
|
||||
Serial.println(readTouchRoller(i));
|
||||
Serial.println(readRawControl(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -395,11 +395,8 @@ void portamento_() {
|
|||
//***********************************************************
|
||||
|
||||
void sendCC() {
|
||||
int biteVal = instrument.biteSignal;
|
||||
if (ExtraControl::CC == state.currentPreset->biteControl) {
|
||||
if (instrument.biteSignal >= calibration.biteThrVal) { // we are over the threshold, calculate CC value
|
||||
biteVal = mapConstrain(instrument.biteSignal, calibration.biteThrVal, calibration.biteMaxVal, 0, 127);
|
||||
}
|
||||
int biteVal = mapConstrain(instrument.biteSignal, calibration.biteThrVal, calibration.biteMaxVal, 0, 127);
|
||||
|
||||
if (biteVal != instrument.biteVal) {
|
||||
midiSendControlChange(state.currentPreset->biteCC, biteVal);
|
||||
|
@ -407,11 +404,8 @@ void sendCC() {
|
|||
instrument.biteVal = biteVal;
|
||||
}
|
||||
|
||||
int extraVal = instrument.extraVal;
|
||||
if (ExtraControl::CC == state.currentPreset->extraControl) {
|
||||
if (instrument.extraSignal != INT16_MIN) { // we are over the threshold, calculate CC value
|
||||
extraVal = mapConstrain(instrument.extraSignal, calibration.extraMinVal, calibration.extraMaxVal, 0, 127);
|
||||
}
|
||||
int extraVal = mapConstrain(instrument.extraSignal, calibration.extraMinVal, calibration.extraMaxVal, 0, 127);
|
||||
|
||||
if (extraVal != instrument.extraVal) {
|
||||
midiSendControlChange(state.currentPreset->extraCC, extraVal);
|
||||
|
@ -419,11 +413,8 @@ void sendCC() {
|
|||
instrument.extraVal = extraVal;
|
||||
}
|
||||
|
||||
int leverVal = instrument.leverVal;
|
||||
if (ExtraControl::CC == state.currentPreset->leverControl) {
|
||||
if (instrument.leverSignal != INT16_MIN) { // we are over the threshold, calculate CC value
|
||||
leverVal = mapConstrain(instrument.leverSignal, calibration.leverMinVal, calibration.leverMaxVal, 0, 127);
|
||||
}
|
||||
int leverVal = mapConstrain(instrument.leverSignal, calibration.leverMinVal, calibration.leverMaxVal, 0, 127);
|
||||
|
||||
if (leverVal != instrument.leverVal) {
|
||||
midiSendControlChange(state.currentPreset->leverCC, leverVal);
|
||||
|
@ -431,11 +422,8 @@ void sendCC() {
|
|||
instrument.leverVal = leverVal;
|
||||
}
|
||||
|
||||
int pbVal = instrument.pbVal;
|
||||
if (ExtraControl::CC == state.currentPreset->pbControl) {
|
||||
if (instrument.pbSignal != INT16_MIN) { // we are over the threshold, calculate CC value
|
||||
pbVal = mapConstrain(instrument.pbSignal, calibration.pbMinVal, calibration.pbMaxVal, 0, 127);
|
||||
}
|
||||
int pbVal = mapConstrain(instrument.pbSignal, calibration.pbMinVal, calibration.pbMaxVal, 0, 127);
|
||||
|
||||
if (pbVal != instrument.pbVal) {
|
||||
midiSendControlChange(state.currentPreset->pbCC, pbVal);
|
||||
|
@ -443,6 +431,34 @@ void sendCC() {
|
|||
instrument.pbVal = pbVal;
|
||||
}
|
||||
|
||||
if (state.currentPreset->pbYCC) {
|
||||
int pbYVal = mapConstrain(instrument.pbYSignal, calibration.pbYMinVal, calibration.pbYMaxVal, 0, 127);
|
||||
|
||||
if (pbYVal != instrument.pbYVal) {
|
||||
midiSendControlChange(state.currentPreset->pbYCC, pbYVal);
|
||||
}
|
||||
instrument.pbYVal = pbYVal;
|
||||
}
|
||||
|
||||
if (state.currentPreset->stickXCC) {
|
||||
int stickXVal = mapConstrain(instrument.stickXSignal, calibration.stickXMinVal, calibration.stickXMaxVal, 0, 127);
|
||||
|
||||
if (stickXVal != instrument.stickXVal) {
|
||||
midiSendControlChange(state.currentPreset->stickXCC, stickXVal);
|
||||
}
|
||||
instrument.stickXVal = stickXVal;
|
||||
}
|
||||
|
||||
if (state.currentPreset->stickYCC) {
|
||||
int stickYVal = mapConstrain(instrument.stickYSignal, calibration.stickYMinVal, calibration.stickYMaxVal, 0, 127);
|
||||
|
||||
if (stickYVal != instrument.stickYVal) {
|
||||
midiSendControlChange(state.currentPreset->stickYCC, stickYVal);
|
||||
}
|
||||
instrument.stickYVal = stickYVal;
|
||||
}
|
||||
|
||||
|
||||
if (!inMenu()) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
byte val = constrain((int)state.instrument->knobVals[i] + readKnob(i), 0, 127);
|
||||
|
@ -490,9 +506,6 @@ void autoCal() {
|
|||
for (int i = 1; i <= CALIBRATE_SAMPLE_COUNT; ++i) {
|
||||
bZero += readPressure();
|
||||
bAltZero += readAltPressure();
|
||||
bLeverTouchZero += readRawSlider(Slider::SLIDER_LEVER);
|
||||
bExtraTouchZero += readRawSlider(Slider::SLIDER_EXTRA);
|
||||
bPBTouchZero += readRawSlider(Slider::SLIDER_PITCH_BEND);
|
||||
}
|
||||
|
||||
instrument.breathZero = bZero / CALIBRATE_SAMPLE_COUNT;
|
||||
|
@ -842,10 +855,13 @@ void initState() {
|
|||
* Read all utility sensors
|
||||
*/
|
||||
void readUtil() {
|
||||
instrument.biteSignal = readTouchRoller(bitePin);
|
||||
instrument.pbSignal = readSlider(Slider::SLIDER_PITCH_BEND, instrument.sliderPBThr);
|
||||
instrument.leverSignal = readSlider(Slider::SLIDER_LEVER, instrument.sliderLeverThr);
|
||||
instrument.extraSignal = readSlider(Slider::SLIDER_EXTRA, instrument.sliderExtraThr);
|
||||
instrument.biteSignal = readRawControl(CONTROL_BITE);
|
||||
instrument.pbSignal = readRawControl(CONTROL_PB);
|
||||
instrument.pbYSignal = readRawControl(CONTROL_PB_Y);
|
||||
instrument.extraSignal = readRawControl(CONTROL_EXTRA);
|
||||
instrument.leverSignal = readRawControl(CONTROL_LEVER);
|
||||
instrument.stickXSignal = readRawControl(CONTROL_STICK_X);
|
||||
instrument.stickYSignal = readRawControl(CONTROL_STICK_Y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1029,6 +1045,10 @@ void setup() {
|
|||
initState(); // Set up midi/etc
|
||||
statusLedOn(); // Switch on the onboard LED to indicate power on/ready
|
||||
displayOff(state);
|
||||
|
||||
if (checkButtonState(STARTUP_TEST)) {
|
||||
instrument.mode = MODE_TEST;
|
||||
}
|
||||
}
|
||||
|
||||
//_______________________________________________________________________________________________ MAIN LOOP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue