Updated CV calibration related stuff

This commit is contained in:
2023-08-26 18:58:36 +03:00
parent 5aaa6e694d
commit 95d07893bc
4 changed files with 72 additions and 51 deletions

View File

@ -26,9 +26,10 @@ const char version[5] = "V:0.9";
const byte outsPins[6] = { 7, 8, 10, 6, 9, 11 };
const byte clockOutPin = 3;
int CV1Calibration = 0;
int CV2Calibration = 0;
int CV1Calibration = 512;
int CV2Calibration = 512;
bool rotateScreen = false;
bool showDone = false;
const int subDivs[17] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32 }; //positive - divide, negative - multiply, 0 - off
@ -108,8 +109,8 @@ byte displayScreen = 0; //0 - main, 1 - sequencer, 2 - settings
bool playBtnPushed = false;
bool shiftBtnPushed = false;
int a1Input = 0;
int a2Input = 0;
int CV1Input = 0;
int CV2Input = 0;
int encPositionOld = 0;
unsigned long encPressedTime;
@ -271,9 +272,9 @@ void sendTriggers() {
int seqMod = 0;
byte seqPattern;
if (channels[i].CV2Target == 3) {
seqMod = map(a2Input, -1, 1024, -8, 8); //-1 and 1024 are to try to make the last step not at max value (should make the range from -7 to +7)
seqMod = map(CV2Input, -1, 1024, -8, 8); //-1 and 1024 are to try to make the last step not at max value (should make the range from -7 to +7)
} else if (channels[i].CV1Target == 3) {
seqMod = map(a1Input, -1, 1024, -8, 8);
seqMod = map(CV1Input, -1, 1024, -8, 8);
}
if (channels[i].seqPattern < 8 && channels[i].seqPattern + seqMod >= 8) {
seqPattern = 7;
@ -357,10 +358,10 @@ void sendTriggers() {
//RND modulation
byte randMod = 0;
if (channels[i].CV1Target == 2) {
randMod = randMod + a1Input;
randMod = randMod + CV1Input;
}
if (channels[i].CV2Target == 2) {
randMod = randMod + a2Input;
randMod = randMod + CV2Input;
}
if (channels[i].CV1Target == 2 || channels[i].CV2Target == 2) {
randMod = map(randMod, 0, 1023, -5, +5);
@ -391,9 +392,9 @@ void calculateCycles() {
for (byte i = 0; i < 6; i++) {
int mod = 0; //subdiv modulation happens here
if (channels[i].CV1Target == 1) {
mod = map(a1Input, -1, 1024, -5, 5); //(channels[i].CV1Value * -1), channels[i].CV1Value)
mod = map(CV1Input, -1, 1024, -5, 5); //(channels[i].CV1Value * -1), channels[i].CV1Value)
} else if (channels[i].CV2Target == 1) {
mod = map(a2Input, -1, 1024, -5, 5);
mod = map(CV2Input, -1, 1024, -5, 5);
}
playingModes[i] = subDivs[channels[i].subDiv - mod]; //subtracting because the innitial array is backwards
@ -414,9 +415,9 @@ void calculateBPMTiming() {
int mod = 0;
if (masterClockMode == 0) { //Internal clock
if (bpmModulationRange != 0 && bpmModulationChannel == 0) {
mod = map(a1Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
mod = map(CV1Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
} else if (bpmModulationRange != 0 && bpmModulationChannel == 1) {
mod = map(a2Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
mod = map(CV2Input, 0, 1023, bpmModulationRange * -10, bpmModulationRange * 10);
}
pulsePeriod = 60000 / ((bpm + mod) * PPQN);
@ -554,10 +555,10 @@ void reboot() {
}
void calibrateCVs() {
//CV1Calibration = 511 - analogRead(ANALOGUE_INPUT_1_PIN);
//CV2Calibration = 511 - analogRead(ANALOGUE_INPUT_2_PIN);
CV1Calibration = 255 - (analogRead(ANALOGUE_INPUT_1_PIN) / 2);
CV2Calibration = 255 - (analogRead(ANALOGUE_INPUT_2_PIN) / 2);
CV1Calibration = analogRead(ANALOGUE_INPUT_1_PIN);
CV2Calibration = analogRead(ANALOGUE_INPUT_2_PIN);
showDone = true;
updateScreen();
}
void checkScreenRotation() {

View File

@ -7,8 +7,9 @@ void checkInputs() {
} else if (digitalRead(ENC_BTN_PIN) && encBtnPushed) {
encBtnPushed = false;
encReleasedTime = millis();
if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s is for entering the submenu
if (showDone) {
showDone = false;
} else if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s is for entering the submenu
if (!insideTab && displayScreen == 0) {
insideTab = true;
} else if (insideTab && channels[displayTab - 1].mode == 2 && menuItem == 2 && displayScreen == 0) { //enter the pattern editor
@ -346,7 +347,21 @@ void checkInputs() {
updateScreen();
}
//modulations map(randMod, 0, 1023, -5, +5)
a1Input = map(analogRead(ANALOGUE_INPUT_1_PIN), 0 - CV1Calibration, 1023 - CV1Calibration, 0, 1023);
a2Input = map(analogRead(ANALOGUE_INPUT_2_PIN), 0 - CV2Calibration, 1023 - CV2Calibration, 0, 1023);
if (analogRead(ANALOGUE_INPUT_1_PIN) > (CV1Calibration)) {
CV1Input = map(analogRead(ANALOGUE_INPUT_1_PIN), CV1Calibration, 1023, 512, 1023);
} else if (analogRead(ANALOGUE_INPUT_1_PIN) < (CV1Calibration-5)) { //-5 is to shift a -1 break point a little lower
CV1Input = map(analogRead(ANALOGUE_INPUT_1_PIN), 0, CV1Calibration-5, 0, 512);
} else {
CV1Input = 512;
}
if (analogRead(ANALOGUE_INPUT_2_PIN) > (CV1Calibration)) {
CV2Input = map(analogRead(ANALOGUE_INPUT_2_PIN), CV1Calibration, 1023, 512, 1023);
} else if (analogRead(ANALOGUE_INPUT_2_PIN) < (CV1Calibration-5)) {
CV2Input = map(analogRead(ANALOGUE_INPUT_2_PIN), 0, CV1Calibration-5, 0, 512);
} else {
CV2Input = 512;
}
}

View File

@ -7,6 +7,7 @@ void updateScreen() {
//String textToShow;
String valueStr;
char valueChar[16];
u8g2.setDrawColor(1);
if (displayScreen == 0) {
//BPM Tab
@ -73,26 +74,6 @@ void updateScreen() {
}
/*
if (masterClockMode == 0) {
if (menuItem == 2 && bpmModulationRange == 0) {
u8g2.drawButtonUTF8(leftOffset + width + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "OFF" );
} else if (menuItem != 2 && bpmModulationRange == 0) {
u8g2.drawButtonUTF8(leftOffset + width + 4, 16, U8G2_BTN_BW0, width, 2, 2, "OFF" );
}
String bpmModStr = String(bpmModulationRange * 10);
char bpmModChar[3];
bpmModStr.toCharArray(bpmModChar, 3);
if (menuItem == 3 && bpmModulationRange != 0) {
u8g2.drawButtonUTF8(leftOffset + width + 4, 26, U8G2_BTN_BW0|U8G2_BTN_INV, width, 4, 2, bpmModChar );
} else if (menuItem != 3 && bpmModulationRange != 0) {
u8g2.drawButtonUTF8(leftOffset + width + 4, 26, U8G2_BTN_BW0, width, 4, 2, bpmModChar );
}
}*/
String bpmStr;
if (masterClockMode == 0) {
bpmStr = String(bpm);
@ -339,5 +320,15 @@ void updateScreen() {
}
if (showDone) {
//u8g2.clear();
u8g2.setDrawColor(0);
u8g2.setFontMode(0);
u8g2.drawBox(18,13,93,32);
u8g2.drawBox(18,16,96,30);
u8g2.setDrawColor(1);
u8g2.drawButtonUTF8(64, 32, U8G2_BTN_BW1|U8G2_BTN_HCENTER|U8G2_BTN_SHADOW2|U8G2_BTN_INV, 64, 12, 12, "DONE" );
}
} while ( u8g2.nextPage() );
}