some progress on gate length in percent (but the calculation is still wrong)
This commit is contained in:
@ -32,18 +32,18 @@ struct channel {
|
||||
byte CV2Target : 3;
|
||||
uint8_t swing : 3;
|
||||
uint8_t offset : 7; //mv: 128
|
||||
uint8_t gate : 6; //mv: 64
|
||||
uint8_t gate : 7;
|
||||
bool isMute : 1;
|
||||
};
|
||||
|
||||
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 },
|
||||
{ 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, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 0, 0, 0, 0, 1, 0 }
|
||||
};
|
||||
|
||||
bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1}; //switch to struct seqs { uint32_t sequence; uint8_t length : 5 ; uint8_t currentStep : 5}. test with lengthOf
|
||||
@ -89,6 +89,7 @@ unsigned long newExtPulseTime = 0;
|
||||
|
||||
bool needPulseReset[] = { true, true, true, true, true, true, true };
|
||||
int gatePulseCount[] = {0,0,0,0,0,0,0};
|
||||
int gateLengthTime[] = {120, 120, 120, 120, 120, 120, 120};
|
||||
bool stepIsOdd = 1;
|
||||
|
||||
byte displayTab = 0;
|
||||
@ -122,8 +123,6 @@ int extTriggerCount;
|
||||
U8G2_SSD1306_128X64_NONAME_2_HW_I2C u8g2(U8G2_R2, SCL, SDA, U8X8_PIN_NONE);
|
||||
RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03);
|
||||
|
||||
|
||||
|
||||
String version;
|
||||
|
||||
void setup() {
|
||||
@ -235,16 +234,13 @@ void clock() {
|
||||
}
|
||||
|
||||
// pull low all outputs after set pulse length
|
||||
if (tickCount >= PULSE_LENGTH) {
|
||||
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
|
||||
if (channels[i].mode != 4) { //everything but gate mode
|
||||
for (byte i = 0; i < 7; i++) {
|
||||
if ((channels[i].mode != 4 && tickCount >= PULSE_LENGTH) ||
|
||||
(channels[i].mode == 4 && tickCount >= gateLengthTime[i])) { //everything but gate mode
|
||||
digitalWrite(outsPins[i], LOW);
|
||||
}
|
||||
}
|
||||
if (!extraChannel) {
|
||||
digitalWrite(clockOutPin, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -464,8 +460,15 @@ void calculateCycles() {
|
||||
channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1;
|
||||
}
|
||||
|
||||
if (channels[i].mode == 4) {
|
||||
calculateGate(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void calculateGate(int channel) {
|
||||
gateLengthTime[channel] = (channelPulsesPerCycle[channel] * pulsePeriod / 100) * channels[channel].gate;
|
||||
}
|
||||
|
||||
void calculateBPMTiming() {
|
||||
int mod = 0;
|
||||
@ -479,9 +482,15 @@ void calculateBPMTiming() {
|
||||
if (calcbpm > MAXBPM) { calcbpm = MAXBPM; };
|
||||
pulsePeriod = 600000 / (calcbpm * PPQN);
|
||||
|
||||
} else if (masterClockMode == 1 && extClockPPQN == 1) { //for ext 1/16 clock (hardcoded)
|
||||
} else if (masterClockMode == 1 && extClockPPQN == 1) { //for ext 1/16 clock
|
||||
pulsePeriod = (newExtPulseTime - lastExtPulseTime) * 10 / 6;
|
||||
}
|
||||
|
||||
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
|
||||
if (channels[i].mode == 4) {
|
||||
calculateGate(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void resetClocks() {
|
||||
|
||||
@ -68,6 +68,7 @@ void checkInputs() {
|
||||
updateScreen();
|
||||
} else if (displayScreen == 2 && menuItem == 3) {
|
||||
extraChannel = !extraChannel;
|
||||
updateScreen();
|
||||
} else if (displayScreen == 2 && menuItem == 4) {
|
||||
EEPROM.put(1023, memCode - 1);
|
||||
reboot();
|
||||
@ -195,11 +196,12 @@ void checkInputs() {
|
||||
&& displayTab != 0
|
||||
&& channels[displayTab - 1].mode == 4) { //Change GATE
|
||||
channels[displayTab - 1].gate = channels[displayTab - 1].gate + change;
|
||||
if (channels[displayTab - 1].gate > 63) {
|
||||
channels[displayTab - 1].gate = 0;
|
||||
} else if (channels[displayTab - 1].gate > 48) {
|
||||
channels[displayTab - 1].gate = 48;
|
||||
if (channels[displayTab - 1].gate > 100 || channels[displayTab - 1].gate == 0) {
|
||||
channels[displayTab - 1].gate = 1;
|
||||
} else if (channels[displayTab - 1].gate > 99) {
|
||||
channels[displayTab - 1].gate = 99;
|
||||
}
|
||||
calculateGate(displayTab - 1);
|
||||
saveState();
|
||||
} else if (insideTab && !shiftBtnPushed && !menuItemSelected) {
|
||||
menuItem = menuItem + change;
|
||||
|
||||
@ -208,7 +208,7 @@ void updateScreen() {
|
||||
} else if (channels[displayTab - 1].mode == 3) {
|
||||
valueStr = F("SWING");
|
||||
} else if (channels[displayTab - 1].mode == 4) {
|
||||
valueStr = F("PULSES");
|
||||
//valueStr = F("PULSES");
|
||||
}
|
||||
|
||||
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) {
|
||||
@ -225,7 +225,7 @@ void updateScreen() {
|
||||
}
|
||||
valueStr = valueStr + String(abs(subDivs[channels[displayTab - 1].subDiv]));
|
||||
} else if (channels[displayTab - 1].mode == 1) {
|
||||
valueStr = String(channels[displayTab - 1].random) + "0%";
|
||||
valueStr = String(channels[displayTab - 1].random) + (channels[displayTab - 1].random == 0 ? "%" : "0%");
|
||||
} else if (channels[displayTab - 1].mode == 2) {
|
||||
if (channels[displayTab - 1].seqPattern < 8) {
|
||||
valueStr = F("A");
|
||||
@ -238,7 +238,7 @@ void updateScreen() {
|
||||
byte swingVals[6] = {50, 58, 66, 75, 83, 92};
|
||||
valueStr = String(swingVals[channels[displayTab - 1].swing]) + "%";
|
||||
} else if (channels[displayTab - 1].mode == 4) {
|
||||
valueStr = String(channels[displayTab - 1].gate);
|
||||
valueStr = String(channels[displayTab - 1].gate) + "%";
|
||||
}
|
||||
u8g2.setFont(stkL);
|
||||
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) {
|
||||
@ -348,7 +348,7 @@ void updateScreen() {
|
||||
valueStr = F("REVERSE ENCODER");
|
||||
break;
|
||||
case 3:
|
||||
valueStr = F("7TH CHANNEL");
|
||||
valueStr = (extraChannel ? F("7TH CHANNEL: ON") : F("7TH CHANNEL: OFF"));
|
||||
break;
|
||||
case 4:
|
||||
valueStr = F("FACTORY RESET");
|
||||
|
||||
Reference in New Issue
Block a user