More inputs and outputs added in simulator
* Set default value for battery sensor input * Show EEPROM values as unsigned. * Simulate K1 to K7 inputs (valve and trills++)
This commit is contained in:
parent
0871b2582d
commit
9357d4b827
4 changed files with 177 additions and 26 deletions
|
@ -102,6 +102,11 @@ class Adafruit_MPR121 {
|
|||
void setThresholds(uint8_t touch, uint8_t release);
|
||||
|
||||
uint8_t _registers[48];
|
||||
|
||||
|
||||
// Simulator specific stuff
|
||||
void mockFilteredData(int register, uint16_t value);
|
||||
|
||||
private:
|
||||
int8_t _i2caddr;
|
||||
};
|
||||
|
|
|
@ -131,15 +131,7 @@ uint16_t Adafruit_MPR121::touched(void) {
|
|||
* @returns the 8 bit value that was read.
|
||||
****************************************************************************************/
|
||||
uint8_t Adafruit_MPR121::readRegister8(uint8_t reg) {
|
||||
|
||||
return this->_registers[reg];
|
||||
// Wire.beginTransmission(_i2caddr);
|
||||
// Wire.write(reg);
|
||||
// Wire.endTransmission(false);
|
||||
// Wire.requestFrom(_i2caddr, 1);
|
||||
// if (Wire.available() < 1)
|
||||
// return 0;
|
||||
// return (Wire.read());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,15 +143,6 @@ uint8_t Adafruit_MPR121::readRegister8(uint8_t reg) {
|
|||
****************************************************************************************/
|
||||
uint16_t Adafruit_MPR121::readRegister16(uint8_t reg) {
|
||||
return _registers[reg] | (_registers[reg+1] << 8);
|
||||
// Wire.beginTransmission(_i2caddr);
|
||||
// Wire.write(reg);
|
||||
// Wire.endTransmission(false);
|
||||
// Wire.requestFrom(_i2caddr, 2);
|
||||
// if (Wire.available() < 2)
|
||||
// return 0;
|
||||
// uint16_t v = Wire.read();
|
||||
// v |= ((uint16_t) Wire.read()) << 8;
|
||||
// return v;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -173,10 +156,6 @@ uint16_t Adafruit_MPR121::readRegister16(uint8_t reg) {
|
|||
void Adafruit_MPR121::writeRegister(uint8_t reg, uint8_t value) {
|
||||
|
||||
_registers[reg] = value;
|
||||
// Wire.beginTransmission(_i2caddr);
|
||||
// Wire.write((uint8_t)reg);
|
||||
// Wire.write((uint8_t)(value));
|
||||
// Wire.endTransmission();
|
||||
}
|
||||
|
||||
|
||||
|
@ -184,3 +163,8 @@ void Adafruit_MPR121::writeRegister(uint8_t reg, uint8_t value) {
|
|||
Simulator specifics code..
|
||||
*/
|
||||
|
||||
|
||||
void Adafruit_MPR121::mockFilteredData(int reg, uint16_t value) {
|
||||
_registers[MPR121_FILTDATA_0L + reg*2] = value & 0xffu;
|
||||
_registers[MPR121_FILTDATA_0L + reg*2+1] = (value>>8) & 0xffu;
|
||||
}
|
||||
|
|
|
@ -178,6 +178,122 @@ static void touchWrite(uint8_t pin, uint16_t value)
|
|||
if( i < 9) touchValues[i] = value;
|
||||
}
|
||||
|
||||
static void doGlobalsWindow()
|
||||
{
|
||||
if( ImGui::Begin("Globals" ) ) {
|
||||
|
||||
|
||||
if(ImGui::TreeNode("Sensor limits") )
|
||||
{
|
||||
ImGui::LabelText("Breath Thr", "%d", breathThrVal);
|
||||
ImGui::LabelText("Breath Max", "%d", breathMaxVal);
|
||||
ImGui::LabelText("Portam Thr", "%d", portamThrVal);
|
||||
ImGui::LabelText("Portam Max", "%d", portamMaxVal);
|
||||
ImGui::LabelText("Pitchb Thr", "%d", pitchbThrVal);
|
||||
ImGui::LabelText("Pitchb Max", "%d", pitchbMaxVal);
|
||||
ImGui::LabelText("Extrac Thr", "%d", extracThrVal);
|
||||
ImGui::LabelText("Extrac Max", "%d", extracMaxVal);
|
||||
ImGui::LabelText("Ctouch Thr", "%d", ctouchThrVal);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if(ImGui::TreeNode("Buttons") )
|
||||
{
|
||||
ImGui::LabelText("Valve 1", "%d", K1);
|
||||
ImGui::LabelText("Valve 2", "%d", K2);
|
||||
ImGui::LabelText("Valve 3", "%d", K3);
|
||||
ImGui::LabelText("Left index", "%d", K4);
|
||||
ImGui::LabelText("Trill 1", "%d", K5);
|
||||
ImGui::LabelText("Trill 2", "%d", K6);
|
||||
ImGui::LabelText("Trill 3", "%d", K7);
|
||||
ImGui::LabelText("half PB", "%d", halfPitchBendKey);
|
||||
ImGui::LabelText("Special", "%d", specialKey);
|
||||
ImGui::LabelText("Pinky", "%d", pinkyKey);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
// unsigned short transpose;
|
||||
// unsigned short MIDIchannel;
|
||||
// unsigned short breathCC; // OFF:MW:BR:VL:EX:MW+:BR+:VL+:EX+:CF
|
||||
// unsigned short breathAT;
|
||||
// unsigned short velocity;
|
||||
// unsigned short portamento;// switching on cc65? just cc5 enabled? SW:ON:OFF
|
||||
// unsigned short PBdepth; // OFF:1-12 divider
|
||||
// unsigned short extraCT; // OFF:MW:FP:CF:SP
|
||||
// unsigned short vibrato; // OFF:1-9
|
||||
// unsigned short deglitch; // 0-70 ms in steps of 5
|
||||
// unsigned short patch; // 1-128
|
||||
// unsigned short octave;
|
||||
// unsigned short curve;
|
||||
// unsigned short velSmpDl; // 0-30 ms
|
||||
// unsigned short velBias; // 0-9
|
||||
// unsigned short pinkySetting; // 0 - 11 (QuickTranspose -12 to -1), 12 (pb/2), 13 - 24 (QuickTranspose +1 to +12)
|
||||
// unsigned short dipSwBits; // virtual dip switch settings for special modes (work in progress)
|
||||
// unsigned short priority; // mono priority for rotator chords
|
||||
// unsigned short vibSens; // vibrato sensitivity
|
||||
// unsigned short vibRetn; // vibrato return speed
|
||||
// unsigned short vibSquelch; //vibrato signal squelch
|
||||
// unsigned short vibDirection; //direction of first vibrato wave UPWD or DNWD
|
||||
// unsigned short fastPatch[7];
|
||||
// byte rotatorOn;
|
||||
// byte currentRotation;
|
||||
// int rotations[4];
|
||||
// int parallel; // semitones
|
||||
|
||||
// int touch_Thr;
|
||||
|
||||
// unsigned long cursorBlinkTime; // the last time the cursor was toggled
|
||||
|
||||
// byte activePatch;
|
||||
// byte doPatchUpdate;
|
||||
|
||||
// byte legacy;
|
||||
// byte legacyBrAct;
|
||||
|
||||
// byte slowMidi;
|
||||
|
||||
// int pressureSensor; // pressure data from breath sensor, for midi breath cc and breath threshold checks
|
||||
// int lastPressure;
|
||||
|
||||
// int biteSensor; // capacitance data from bite sensor, for midi cc and threshold checks
|
||||
// int lastBite;
|
||||
// byte biteJumper;
|
||||
|
||||
// int exSensor;
|
||||
// int lastEx;
|
||||
|
||||
// int pitchBend;
|
||||
|
||||
// int pbUp;
|
||||
// int pbDn;
|
||||
|
||||
// byte vibLedOff;
|
||||
// byte oldpkey;
|
||||
|
||||
// int vibThr; // this gets auto calibrated in setup
|
||||
// int vibThrLo;
|
||||
// int vibZero;
|
||||
|
||||
// // Key variables, TRUE (1) for pressed, FALSE (0) for not pressed
|
||||
// byte K1; // Valve 1 (pitch change -2)
|
||||
// byte K2; // Valve 2 (pitch change -1)
|
||||
// byte K3; // Valve 3 (pitch change -3)
|
||||
// byte K4; // Left Hand index finger (pitch change -5)
|
||||
// byte K5; // Trill key 1 (pitch change +2)
|
||||
// byte K6; // Trill key 2 (pitch change +1)
|
||||
// byte K7; // Trill key 3 (pitch change +4)
|
||||
|
||||
// byte halfPitchBendKey;
|
||||
// byte specialKey;
|
||||
// byte pinkyKey;
|
||||
|
||||
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
//***********************************************************
|
||||
|
||||
static void doInputWindow()
|
||||
|
@ -193,9 +309,14 @@ static void doInputWindow()
|
|||
analogInputs[vMeterPin] = val;
|
||||
}
|
||||
|
||||
val = analogInputs[0];
|
||||
if( ImGui::SliderInt("Unknown", &val, 0, 4095 ) && !animateAnalogs ) {
|
||||
analogInputs[0] = val;
|
||||
// val = analogInputs[0];
|
||||
// if( ImGui::SliderInt("Unknown", &val, 0, 4095 ) && !animateAnalogs ) {
|
||||
// analogInputs[0] = val;
|
||||
// }
|
||||
|
||||
val = touchRead(halfPitchBendKeyPin);
|
||||
if( ImGui::SliderInt("Pinky key", &val, 0, 4095 ) && !animateAnalogs ) {
|
||||
touchWrite(halfPitchBendKeyPin, val);
|
||||
}
|
||||
|
||||
val = analogInputs[A7];
|
||||
|
@ -203,7 +324,43 @@ static void doInputWindow()
|
|||
analogInputs[A7] = val;
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
bool k1 = touchSensor.readRegister16(MPR121_FILTDATA_0L + K1Pin*2) < ctouchThrVal;
|
||||
bool k2 = touchSensor.readRegister16(MPR121_FILTDATA_0L + K2Pin*2) < ctouchThrVal;
|
||||
bool k3 = touchSensor.readRegister16(MPR121_FILTDATA_0L + K3Pin*2) < ctouchThrVal;
|
||||
bool k4 = touchSensor.readRegister16(MPR121_FILTDATA_0L + K4Pin*2) < ctouchThrVal;
|
||||
bool k5 = touchSensor.readRegister16(MPR121_FILTDATA_0L + K5Pin*2) < ctouchThrVal;
|
||||
bool k6 = touchSensor.readRegister16(MPR121_FILTDATA_0L + K6Pin*2) < ctouchThrVal;
|
||||
bool k7 = touchSensor.readRegister16(MPR121_FILTDATA_0L + K7Pin*2) < ctouchThrVal;
|
||||
|
||||
if( ImGui::Checkbox("K1", &k1) )
|
||||
touchSensor.mockFilteredData(K1Pin, ctouchThrVal + (!k1 ? 100 : -100));
|
||||
|
||||
ImGui::SameLine();
|
||||
if( ImGui::Checkbox("K2", &k2) )
|
||||
touchSensor.mockFilteredData(K2Pin, ctouchThrVal + (!k2 ? 100 : -100));
|
||||
|
||||
ImGui::SameLine();
|
||||
if( ImGui::Checkbox("K3", &k3) )
|
||||
touchSensor.mockFilteredData(K3Pin, ctouchThrVal + (!k3 ? 100 : -100));
|
||||
|
||||
ImGui::SameLine();
|
||||
if( ImGui::Checkbox("K4", &k4) )
|
||||
touchSensor.mockFilteredData(K4Pin, ctouchThrVal + (!k4 ? 100 : -100));
|
||||
|
||||
ImGui::SameLine();
|
||||
if( ImGui::Checkbox("K5", &k5) )
|
||||
touchSensor.mockFilteredData(K5Pin, ctouchThrVal + (!k5 ? 100 : -100));
|
||||
|
||||
ImGui::SameLine();
|
||||
if( ImGui::Checkbox("K6", &k6) )
|
||||
touchSensor.mockFilteredData(K6Pin, ctouchThrVal + (!k6 ? 100 : -100));
|
||||
|
||||
ImGui::SameLine();
|
||||
if( ImGui::Checkbox("K7", &k7) )
|
||||
touchSensor.mockFilteredData(K7Pin, ctouchThrVal + (!k7 ? 100 : -100));
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
@ -307,6 +464,8 @@ static void SimLoop(std::function<bool()> continue_predicate, std::function<void
|
|||
|
||||
// Render UI here..
|
||||
doInputWindow();
|
||||
doGlobalsWindow();
|
||||
|
||||
|
||||
ImGui::Begin("NuEVI display");
|
||||
ImVec2 size( 128*scale, 64*scale );
|
||||
|
@ -385,6 +544,9 @@ static int SimInit()
|
|||
|
||||
memset(digitalInputs, 1, sizeof(digitalInputs));
|
||||
|
||||
|
||||
analogInputs[vMeterPin] = 3025;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ EEPROMClass::EEPROMClass() {
|
|||
|
||||
uint8_t EEPROMClass::read( int idx )
|
||||
{
|
||||
printf("Reading EEPROM address %d: %d\n", idx, someFakeEEPROM_memory[idx]);
|
||||
printf("Reading EEPROM address %u: %u\n", idx, 0xff&someFakeEEPROM_memory[idx]);
|
||||
return someFakeEEPROM_memory[idx];
|
||||
}
|
||||
|
||||
|
||||
void EEPROMClass::write( int idx, uint8_t val )
|
||||
{
|
||||
printf("Writing to EEPROM address %d = %d\n", idx, val);
|
||||
printf("Writing to EEPROM address %u = %u\n", idx, val);
|
||||
someFakeEEPROM_memory[idx] = val;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue