gate pulsewidth (almost) works for subdivs, but not for multipliers

This commit is contained in:
Oleksiy
2025-03-08 14:57:17 +02:00
parent fd240e0341
commit 9840f23f77
3 changed files with 24 additions and 22 deletions

View File

@ -88,8 +88,8 @@ unsigned long lastExtPulseTime = 0;
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};
uint16_t gateLengthTime[] = {120, 120, 120, 120, 120, 120, 120};
uint16_t gateCountDown[7];
bool stepIsOdd = 1;
byte displayTab = 0;
@ -235,9 +235,13 @@ void clock() {
// pull low all outputs after set pulse length
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
if (channels[i].mode != 4 && tickCount >= PULSE_LENGTH) { //everything but gate mode
digitalWrite(outsPins[i], LOW);
} else if (channels[i].mode == 4 && tickCount >= gateCountDown[i]) { //gate mode gateLengthTime[i] < pulsePeriod
digitalWrite(outsPins[i], LOW);
gateCountDown[i] = gateLengthTime[i];
} else if (channels[i].mode == 4 && gateCountDown[i] > pulsePeriod && tickCount == 0) {
gateCountDown[i] = gateCountDown[i] - pulsePeriod;
}
}
@ -412,12 +416,6 @@ void sendTriggers() { //rename to onPulse or something
randAmount = 10;
}
if (channels[i].mode == 4) { //Gate mode turning off
gatePulseCount[i]++;
if (gatePulseCount[i] > channels[i].gate) {
digitalWrite(outsPins[i], LOW);
}
}
if (!channels[i].isMute) {
if ((channels[i].mode == 3 && channelPulseCount[i] == 0 && stepIsOdd == 0)
|| (channels[i].mode == 3 && channelPulseCount[i] == channels[i].swing && stepIsOdd == 1) //swing
@ -430,7 +428,6 @@ void sendTriggers() { //rename to onPulse or something
|| (channels[i].mode == 4 && channelPulseCount[i] == 0) //Gate
) {
digitalWrite(outsPins[i], HIGH);
gatePulseCount[i] = 0; //reset gate here to avoid length "countdown" effect
}
}
if (channelPulseCount[i] < channelPulsesPerCycle[i]) {
@ -466,8 +463,11 @@ void calculateCycles() {
}
}
void calculateGate(int channel) {
gateLengthTime[channel] = (channelPulsesPerCycle[channel] * pulsePeriod / 100) * channels[channel].gate;
void calculateGate(uint8_t channel) {
//if (subDivs[channels[channel].subDiv] > 0) {
gateLengthTime[channel] = (channelPulsesPerCycle[channel] * pulsePeriod / 100) * channels[channel].gate;
gateCountDown[channel] = gateLengthTime[channel];
//}
}
void calculateBPMTiming() {

View File

@ -11,7 +11,7 @@ void updateScreen() {
//BPM Tab
if (displayTab == 0) { //BPM
u8g2.setFont(velvetscreen);
u8g2.setFont(stkS);
//Menu items
lastMenuItem = 4;
@ -91,19 +91,19 @@ void updateScreen() {
if ((!insideTab && !shiftBtnPushed) || (insideTab && menuItem != 0)) { //default view, nothing is selected or editable
u8g2.setFont(stkL);
u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
u8g2.setFont(velvetscreen);
u8g2.setFont(stkS);
valueStr = F("BPM");
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 2, valueStr.c_str() );
} else if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) { //show value as editable
u8g2.setFont(stkL);
u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW1|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
u8g2.setFont(velvetscreen);
u8g2.setFont(stkS);
valueStr = F("BPM");
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 2, valueStr.c_str() );
} else if (insideTab && menuItem == 0 && !menuItemSelected) { //show as selected menu item
u8g2.setFont(stkL);
u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
u8g2.setFont(velvetscreen);
u8g2.setFont(stkS);
valueStr = F("BPM");
u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 2, valueStr.c_str() );
}
@ -121,7 +121,7 @@ void updateScreen() {
if (channels[displayTab - 1].mode == 3) {
lastMenuItem = 1;
} else if (channels[displayTab - 1].mode == 4) {
lastMenuItem = 2;
lastMenuItem = 3;
} else {
lastMenuItem = 3;
}
@ -136,6 +136,8 @@ void updateScreen() {
valueStr = F("SUBDIV:");
} else if (i == 2 && channels[displayTab - 1].mode == 2) {
valueStr = F("EDIT PATTERN");
} else if (i == 3 && channels[displayTab - 1].mode == 4) {
valueStr = (String(pulsePeriod) + " " + String(channelPulsesPerCycle[displayTab - 1]));
} else if (i == 3) {
valueStr = F("MOD:");
}
@ -208,7 +210,7 @@ void updateScreen() {
} else if (channels[displayTab - 1].mode == 3) {
valueStr = F("SWING");
} else if (channels[displayTab - 1].mode == 4) {
//valueStr = F("PULSES");
valueStr = gateLengthTime[displayTab - 1];
}
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) {
@ -252,7 +254,7 @@ void updateScreen() {
//Tabs
u8g2.drawHLine(0, 53, 128);
u8g2.setFont(velvetscreen);
u8g2.setFont(stkS);
byte yPos = 61;
byte xWidth = 12;
valueStr = F("w");
@ -290,7 +292,7 @@ void updateScreen() {
//Edit Pattern Screen (Sequencer)
else if (displayScreen == 1) {
u8g2.setFont(velvetscreen);
u8g2.setFont(stkS);
byte pattern = channels[displayTab - 1].seqPattern;
if (pattern < 8) {
valueStr = F("PATTERN A");

View File

@ -1,6 +1,6 @@
#pragma once
const PROGMEM uint8_t velvetscreen[437] U8G2_FONT_SECTION("velvetscreen") =
const PROGMEM uint8_t stkS[437] U8G2_FONT_SECTION("stk-s") =
"\64\0\2\2\3\3\2\3\4\5\5\0\0\5\0\5\0\0\221\0\0\1\230 \4\200\134%\11\255tT"
"R\271RI(\6\252\334T\31)\7\252\134bJ\12+\7\233\345\322J\0,\5\221T\4-\5\213"
"f\6.\5\211T\2/\6\244\354c\33\60\10\254\354T\64\223\2\61\7\353\354\222\254\6\62\11\254l"