Fixed sequence player
This commit is contained in:
@ -124,28 +124,6 @@ bool encPressRegistered;
|
||||
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);
|
||||
|
||||
const unsigned char splash_logo[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x07, 0xf8, 0x03, 0xff, 0xc0, 0x03, 0xf8, 0x1f, 0x00, 0x7c, 0x7c, 0x3f, 0xff, 0xc7, 0xc0, 0x3e,
|
||||
0x0f, 0xfe, 0x03, 0xff, 0xe0, 0x07, 0xf8, 0x0f, 0x00, 0x78, 0x7c, 0x3f, 0xff, 0xc3, 0xe0, 0x7c,
|
||||
0x1f, 0xff, 0x03, 0xff, 0xf0, 0x07, 0xf8, 0x0f, 0x80, 0xf8, 0x7c, 0x3f, 0xff, 0xc3, 0xe0, 0x78,
|
||||
0x3f, 0xff, 0x03, 0xff, 0xf8, 0x07, 0xfc, 0x0f, 0x80, 0xf8, 0x7c, 0x3f, 0xff, 0xc1, 0xf0, 0xf8,
|
||||
0x7e, 0x0f, 0x83, 0xe0, 0xf8, 0x0f, 0x3c, 0x07, 0x80, 0xf0, 0x7c, 0x00, 0xf8, 0x00, 0xf8, 0xf0,
|
||||
0x7c, 0x07, 0x83, 0xe0, 0x78, 0x0f, 0x3c, 0x07, 0xc0, 0xf0, 0x7c, 0x00, 0xf0, 0x00, 0xf9, 0xf0,
|
||||
0x7c, 0x00, 0x03, 0xe0, 0xf8, 0x0f, 0x3e, 0x07, 0xc1, 0xf0, 0x7c, 0x00, 0xf0, 0x00, 0x7d, 0xe0,
|
||||
0x78, 0x00, 0x03, 0xe0, 0xf8, 0x1e, 0x1e, 0x03, 0xc1, 0xe0, 0x7c, 0x00, 0xf0, 0x00, 0x7f, 0xc0,
|
||||
0x78, 0x3f, 0xc3, 0xff, 0xf0, 0x1e, 0x1e, 0x03, 0xe1, 0xe0, 0x7c, 0x00, 0xf0, 0x00, 0x3f, 0xc0,
|
||||
0x78, 0x3f, 0xc3, 0xff, 0xe0, 0x1e, 0x1f, 0x01, 0xe3, 0xe0, 0x7c, 0x00, 0xf0, 0x00, 0x1f, 0x80,
|
||||
0x78, 0x3f, 0xc3, 0xff, 0xc0, 0x3e, 0x1f, 0x01, 0xe3, 0xc0, 0x7c, 0x00, 0xf0, 0x00, 0x1f, 0x80,
|
||||
0x7c, 0x3f, 0xc3, 0xe7, 0xc0, 0x3f, 0xff, 0x01, 0xf3, 0xc0, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x7e, 0x07, 0xc3, 0xe3, 0xe0, 0x3f, 0xff, 0x80, 0xf7, 0xc0, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x3f, 0x1f, 0xc3, 0xe1, 0xe0, 0x7f, 0xff, 0x80, 0xff, 0x80, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x1f, 0xff, 0xc3, 0xe1, 0xf0, 0x78, 0x07, 0x80, 0xff, 0x80, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x0f, 0xff, 0xc3, 0xe0, 0xf8, 0xf8, 0x07, 0xc0, 0x7f, 0x00, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x07, 0xf3, 0xc3, 0xe0, 0xf8, 0xf8, 0x07, 0xc0, 0x7f, 0x00, 0x7c, 0x00, 0xf0, 0x00, 0x0f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t velvetscreen[597] U8G2_FONT_SECTION("velvetscreen") =
|
||||
"I\0\2\2\3\3\3\3\4\5\5\0\0\5\0\5\0\0\363\0\0\2\70!\6)\251\254\0\42\6\23"
|
||||
"\317$\25#\12-\351UC\345\241*\0$\11,\331\215\24e\32\11%\12-\351\250\244r\245\222\0"
|
||||
@ -169,7 +147,7 @@ const uint8_t velvetscreen[597] U8G2_FONT_SECTION("velvetscreen") =
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
//Serial.begin(9600);
|
||||
|
||||
//check last bit in eeprom to know if the correct settings were stored
|
||||
if (EEPROM.read(1023) == memCode) {
|
||||
@ -198,21 +176,6 @@ void setup() {
|
||||
pinMode(outsPins[i], OUTPUT);
|
||||
}
|
||||
|
||||
/*display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
|
||||
display.setRotation(2);
|
||||
display.clearDisplay();
|
||||
|
||||
//Splash screen
|
||||
display.drawBitmap(0, 16, splash_logo, 128, 19, 1);
|
||||
|
||||
display.setCursor(0, 56);
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.print(F("V:"));
|
||||
display.print(F(VERSION));
|
||||
display.display();
|
||||
delay(800);*/
|
||||
//u8g2.setI2CAddress(SCREEN_ADDRESS);
|
||||
u8g2.begin();
|
||||
|
||||
updateScreen();
|
||||
@ -303,6 +266,39 @@ void sendTriggers() {
|
||||
//16th notes for sequencer
|
||||
if (sixteenthPulseCount == 0) {
|
||||
for (byte i = 0; i < 6; i++) {
|
||||
if (channels[i].seqPattern == 0) {
|
||||
currentSeq = seqA1;
|
||||
} else if (channels[i].seqPattern == 1) {
|
||||
currentSeq = seqA2;
|
||||
} else if (channels[i].seqPattern == 2) {
|
||||
currentSeq = seqA3;
|
||||
} else if (channels[i].seqPattern == 3) {
|
||||
currentSeq = seqA4;
|
||||
} else if (channels[i].seqPattern == 4) {
|
||||
currentSeq = seqA5;
|
||||
} else if (channels[i].seqPattern == 5) {
|
||||
currentSeq = seqA6;
|
||||
} else if (channels[i].seqPattern == 6) {
|
||||
currentSeq = seqA7;
|
||||
} else if (channels[i].seqPattern == 7) {
|
||||
currentSeq = seqA8;
|
||||
} else if (channels[i].seqPattern == 8) {
|
||||
currentSeq = seqB1;
|
||||
} else if (channels[i].seqPattern == 9) {
|
||||
currentSeq = seqB2;
|
||||
} else if (channels[i].seqPattern == 10) {
|
||||
currentSeq = seqB3;
|
||||
} else if (channels[i].seqPattern == 11) {
|
||||
currentSeq = seqB4;
|
||||
} else if (channels[i].seqPattern == 12) {
|
||||
currentSeq = seqB5;
|
||||
} else if (channels[i].seqPattern == 13) {
|
||||
currentSeq = seqB6;
|
||||
} else if (channels[i].seqPattern == 14) {
|
||||
currentSeq = seqB7;
|
||||
} else if (channels[i].seqPattern == 15) {
|
||||
currentSeq = seqB8;
|
||||
}
|
||||
if (channels[i].mode == 2 && channelPulseCount[i] == 0 && currentSeq[currentStep]) {
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
@ -354,7 +350,6 @@ void sendTriggers() {
|
||||
|
||||
if ((channels[i].mode == 0 && channelPulseCount[i] == channels[i].offset) //CLK with offset
|
||||
|| (channels[i].mode == 1 && channelPulseCount[i] == 0 && (random(10) + 1) > randAmount) //RND
|
||||
//|| (channels[i].mode == 2 && channelPulseCount[i] == 0 && currentSeq[currentStep])
|
||||
) {
|
||||
digitalWrite(outsPins[i], HIGH);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ void checkInputs() {
|
||||
bpm = MINBPM;
|
||||
}
|
||||
calculateBPMTiming();
|
||||
} else if (!insideTab && shiftBtnPushed && displayTab != 0) { //Change Subdiv
|
||||
} else if (!insideTab && shiftBtnPushed && displayTab != 0 && channels[displayTab - 1].mode == 0) { //Change Subdiv
|
||||
channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change;
|
||||
if (channels[displayTab - 1].subDiv > 200) {
|
||||
channels[displayTab - 1].subDiv = 0;
|
||||
@ -52,7 +52,23 @@ void checkInputs() {
|
||||
if (!isPlaying) {
|
||||
calculateCycles();
|
||||
}
|
||||
} else if (insideTab && !shiftBtnPushed) {
|
||||
} else if (!insideTab && shiftBtnPushed && displayTab != 0 && channels[displayTab - 1].mode == 1) { //Change Random
|
||||
channels[displayTab - 1].random = channels[displayTab - 1].random + change;
|
||||
if (channels[displayTab - 1].random > 100) {
|
||||
channels[displayTab - 1].random = 0;
|
||||
} else if (channels[displayTab - 1].random > 9) {
|
||||
channels[displayTab - 1].random = 9;
|
||||
}
|
||||
} else if (!insideTab && shiftBtnPushed && displayTab != 0 && channels[displayTab - 1].mode == 2) { //Change SEQ pattern
|
||||
channels[displayTab - 1].seqPattern = channels[displayTab - 1].seqPattern + change;
|
||||
if (channels[displayTab - 1].seqPattern > 100) {
|
||||
channels[displayTab - 1].seqPattern = 0;
|
||||
} else if (channels[displayTab - 1].seqPattern > 16) {
|
||||
channels[displayTab - 1].seqPattern = 16;
|
||||
}
|
||||
|
||||
}
|
||||
else if (insideTab && !shiftBtnPushed) {
|
||||
menuItem = menuItem + change;
|
||||
if (menuItem > 100) { //for "negative" values
|
||||
menuItem = 0;
|
||||
@ -99,29 +115,15 @@ void checkInputs() {
|
||||
} else if (channels[displayTab - 1].offset > channelPulsesPerCycle[displayTab-1]) {
|
||||
channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab-1];
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1 && channels[displayTab - 1].mode == 1) { //RANDOM
|
||||
channels[displayTab - 1].random = channels[displayTab - 1].random + change;
|
||||
if (channels[displayTab - 1].random > 100) {
|
||||
channels[displayTab - 1].random = 0;
|
||||
} else if (channels[displayTab - 1].random > 9) {
|
||||
channels[displayTab - 1].random = 9;
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1 && channels[displayTab - 1].mode == 1) { //SUBDIV for RANDOM
|
||||
channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change;
|
||||
if (channels[displayTab - 1].subDiv > 200) {
|
||||
channels[displayTab - 1].subDiv = 0;
|
||||
} else if (channels[displayTab - 1].subDiv > (sizeof(subDivs) / sizeof(byte)) - 1) {
|
||||
channels[displayTab - 1].subDiv = (sizeof(subDivs) / sizeof(byte)) - 1;
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1 && channels[displayTab - 1].mode == 2) { //Seq PAttern
|
||||
channels[displayTab - 1].seqPattern = channels[displayTab - 1].seqPattern + change;
|
||||
if (channels[displayTab - 1].seqPattern > 100) {
|
||||
channels[displayTab - 1].seqPattern = 0;
|
||||
} else if (channels[displayTab - 1].seqPattern > 8) {
|
||||
channels[displayTab - 1].seqPattern = 8;
|
||||
}
|
||||
|
||||
if (channels[displayTab - 1].seqPattern == 0) {
|
||||
currentSeq = seqA1;
|
||||
} else if (channels[displayTab - 1].seqPattern == 1) {
|
||||
currentSeq = seqA2;
|
||||
} else if (channels[displayTab - 1].seqPattern == 2) {
|
||||
currentSeq = seqA3;
|
||||
} else if (channels[displayTab - 1].seqPattern == 3) {
|
||||
currentSeq = seqA4;
|
||||
if (!isPlaying) {
|
||||
calculateCycles();
|
||||
}
|
||||
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 0) { //CV1 for CLK
|
||||
channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change;
|
||||
@ -176,13 +178,9 @@ void checkInputs() {
|
||||
//shift button
|
||||
if (!digitalRead(SHIFT_BTN_PIN) && !shiftBtnPushed) {
|
||||
shiftBtnPushed = true;
|
||||
//display.fillRoundRect(120, 52, 8, 8, 3, SSD1306_WHITE);
|
||||
//display.display();
|
||||
updateScreen();
|
||||
} else if (digitalRead(SHIFT_BTN_PIN) && shiftBtnPushed) {
|
||||
shiftBtnPushed = false;
|
||||
//display.fillRoundRect(120, 52, 8, 8, 3, SSD1306_BLACK);
|
||||
//display.display();
|
||||
updateScreen();
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@ void updateScreen() {
|
||||
|
||||
u8g2.firstPage();
|
||||
do {
|
||||
//u8g2.clearBuffer();
|
||||
|
||||
//BPM Tab
|
||||
if (displayTab == 0) { //BPM
|
||||
@ -145,6 +144,7 @@ void updateScreen() {
|
||||
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "SEQ" );
|
||||
}
|
||||
|
||||
//Main Param
|
||||
if (channels[displayTab - 1].mode == 0) {
|
||||
valueStr = String(channels[displayTab - 1].offset) + "/";
|
||||
valueStr = valueStr + String(channelPulsesPerCycle[displayTab-1]+1);
|
||||
@ -155,9 +155,9 @@ void updateScreen() {
|
||||
}
|
||||
valueStr.toCharArray(valueChar, 8);
|
||||
|
||||
if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 0) {
|
||||
if (menuItem == 1 && insideTab) {
|
||||
u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, valueChar );
|
||||
} else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 0) {
|
||||
} else if ((menuItem != 1 || !insideTab)) {
|
||||
u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0, valueWidth, 3, 2, valueChar );
|
||||
}
|
||||
|
||||
@ -167,8 +167,10 @@ void updateScreen() {
|
||||
valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv]));
|
||||
} else if (channels[displayTab - 1].mode == 1) {
|
||||
valueStr = String(channels[displayTab - 1].random) + "0%";
|
||||
} else if (channels[displayTab - 1].mode == 2) {
|
||||
valueStr = "A" + String(channels[displayTab - 1].random + 1);
|
||||
} else if (channels[displayTab - 1].mode == 2 && channels[displayTab - 1].seqPattern < 8) {
|
||||
valueStr = "A" + String(channels[displayTab - 1].seqPattern + 1);
|
||||
} else if (channels[displayTab - 1].mode == 2 && channels[displayTab - 1].seqPattern >= 8) {
|
||||
valueStr = "B" + String(channels[displayTab - 1].seqPattern - 7);
|
||||
}
|
||||
valueStr.toCharArray(valueChar, 8);
|
||||
|
||||
@ -361,6 +363,5 @@ void updateScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
//u8g2.sendBuffer();
|
||||
} while ( u8g2.nextPage() );
|
||||
}
|
||||
Reference in New Issue
Block a user