Extra Channel setting WIP

This commit is contained in:
Oleksiy
2025-03-04 22:05:51 +02:00
parent d04e7b0dbb
commit 1201d206a0
4 changed files with 29 additions and 18 deletions

View File

@ -17,7 +17,7 @@ uint16_t CV1Calibration = 512;
uint16_t CV2Calibration = 512;
bool showDone = false;
const int subDivs[20] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 24, 32, 64, 128 }; //positive - divide, negative - multiply, 0 - off
const int subDivs[] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 24, 32, 64, 128 }; //positive - divide, negative - multiply, 0 - off
byte bpm = 130;
byte bpmModulationChannel = 200; //0 - CV1, 1 - CV2, 255 - OFF
@ -36,7 +36,8 @@ struct channel {
bool isMute : 1;
};
channel channels[6] = { //array of channel settings
channel channels[7] = { //array of channel settings
{ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0 },
@ -82,11 +83,12 @@ unsigned int pulseCount = 0;
byte masterClockMode = 0; // 0 - internal, 1 - external 24ppqn, 2 - MIDI
byte extClockPPQN = 0; // 0 - 24, 1 - 4 (1/16)
byte extraChannel = 0; // 0 - off, 1 - pulse out = 7th channel
unsigned long lastExtPulseTime = 0;
unsigned long newExtPulseTime = 0;
bool needPulseReset[6] = { true, true, true, true, true, true };
int gatePulseCount[6] = {0,0,0,0,0,0};
bool needPulseReset[] = { true, true, true, true, true, true, true };
int gatePulseCount[] = {0,0,0,0,0,0,0};
bool stepIsOdd = 1;
byte displayTab = 0;
@ -193,7 +195,9 @@ void clock() {
// Action on each pulse
if (tickCount == 0) {
sendTriggers();
digitalWrite(clockOutPin, HIGH);
if (!extraChannel) {
digitalWrite(clockOutPin, HIGH);
}
sendMIDIClock();
}
@ -232,12 +236,14 @@ void clock() {
// pull low all outputs after set pulse length
if (tickCount >= PULSE_LENGTH) {
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
if (channels[i].mode != 4) { //everything but gate mode
digitalWrite(outsPins[i], LOW);
}
}
digitalWrite(clockOutPin, LOW);
if (!extraChannel) {
digitalWrite(clockOutPin, LOW);
}
}
}
}
@ -293,7 +299,7 @@ void externalClock() {
void sendTriggers() { //rename to onPulse or something
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
if (playingModes[i] != subDivs[channels[i].subDiv] && playingModesOld[i] != playingModes[i]) {
needPulseReset[i] = true;
playingModesOld[i] = playingModes[i];
@ -303,7 +309,7 @@ void sendTriggers() { //rename to onPulse or something
if (sixteenthPulseCount == 0) {
bool *currentSeq;
stepIsOdd = !stepIsOdd;
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
//pattern modulation
int seqMod = 0;
@ -381,7 +387,7 @@ void sendTriggers() { //rename to onPulse or something
//switching modes on the beat and resetting channel clock
if (pulseCount == 0) {
calculateCycles();
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
if (needPulseReset[i] == true) {
channelPulseCount[i] = 0;
needPulseReset[i] = false;
@ -390,7 +396,7 @@ void sendTriggers() { //rename to onPulse or something
}
//multiplier
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
//RND modulation
byte randMod = 0;
@ -441,7 +447,7 @@ void sendTriggers() { //rename to onPulse or something
void calculateCycles() {
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
int mod = 0; //subdiv modulation happens here
if (channels[i].CV1Target == 1) {
mod = map(CV1Input, -1, 1024, -5, 5);
@ -479,7 +485,7 @@ void calculateBPMTiming() {
}
void resetClocks() {
for (byte i = 0; i < 6; i++) {
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
channelPulseCount[i] = 0;
digitalWrite(outsPins[i], LOW); //to avoid stuck leds
}

View File

@ -67,6 +67,8 @@ void checkInputs() {
showDone = true;
updateScreen();
} else if (displayScreen == 2 && menuItem == 3) {
extraChannel = !extraChannel;
} else if (displayScreen == 2 && menuItem == 4) {
EEPROM.put(1023, memCode - 1);
reboot();
}
@ -111,8 +113,8 @@ void checkInputs() {
displayTab = displayTab + change;
if (displayTab > 100) { //to address "negative" numbers
displayTab = 0;
} else if (displayTab > 6) {
displayTab = 6;
} else if (displayTab > (extraChannel ? 7 : 6)) {
displayTab = (extraChannel ? 7 : 6);
}
} else if (((!insideTab && shiftBtnPushed)
|| (insideTab && menuItem == 0

View File

@ -266,7 +266,7 @@ void updateScreen() {
u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW0|U8G2_BTN_HCENTER, xWidth, 0, 2, valueStr.c_str() );
}
for (int i = 1; i <= 6; i++) {
for (int i = 1; i <= (extraChannel ? 7 : 6); i++) {
valueStr = String(i);
if (displayTab == i) {
if (insideTab == true || shiftBtnPushed == true) {
@ -334,7 +334,7 @@ void updateScreen() {
u8g2.drawStr(8, 5, valueStr.c_str() );
u8g2.drawStr(122 - (u8g2.getStrWidth(version.c_str())), 5, version.c_str() );
u8g2.drawHLine(0, 8, 128);
lastMenuItem = 3;
lastMenuItem = 4;
byte width = 112;
for (byte i = 0; i <= lastMenuItem; i++) {
switch(i) {
@ -348,6 +348,9 @@ void updateScreen() {
valueStr = F("REVERSE ENCODER");
break;
case 3:
valueStr = F("7TH CHANNEL");
break;
case 4:
valueStr = F("FACTORY RESET");
break;
};

View File

@ -16,8 +16,8 @@
#define EXT_INPUT_PIN 2 //needs to be an interrupt pin
#define ANALOGUE_INPUT_1_PIN A7
#define ANALOGUE_INPUT_2_PIN A6
const byte outsPins[6] = { 7, 8, 10, 6, 9, 11 };
const byte clockOutPin = 3;
const byte outsPins[] = { 7, 8, 10, 6, 9, 11, clockOutPin };
bool rotateScreen = false;
bool reverseEnc = false;
//