Started reworking menu to include main param

This commit is contained in:
2023-08-06 22:02:42 +03:00
parent fc622a1663
commit aec68332e4
3 changed files with 108 additions and 78 deletions

View File

@ -100,6 +100,7 @@ bool needPulseReset[6] = { true, true, true, true, true, true };
byte displayTab = 0; byte displayTab = 0;
bool insideTab = false; bool insideTab = false;
byte menuItem = 0; byte menuItem = 0;
bool menuItemSelected = false;
byte lastMenuItem = 3; byte lastMenuItem = 3;
byte displayScreen = 0; //0 - main, 1 - sequencer, 2 - settings byte displayScreen = 0; //0 - main, 1 - sequencer, 2 - settings
@ -508,14 +509,16 @@ void loadState() {
} }
} }
void resetFunc() { void reboot() {
wdt_enable(WDTO_15MS); // 8 ms watchdog wdt_enable(WDTO_15MS); //reboot after 15ms
while(true); // infinite loop without feeding the dog, should reset in 8ms while(true);
} }
void calibrateCVs() { void calibrateCVs() {
CV1Calibration = 511 - analogRead(ANALOGUE_INPUT_1_PIN); //CV1Calibration = 511 - analogRead(ANALOGUE_INPUT_1_PIN);
CV2Calibration = 511 - analogRead(ANALOGUE_INPUT_2_PIN); //CV2Calibration = 511 - analogRead(ANALOGUE_INPUT_2_PIN);
CV1Calibration = 255 - (analogRead(ANALOGUE_INPUT_1_PIN) / 2);
CV2Calibration = 255 - (analogRead(ANALOGUE_INPUT_2_PIN) / 2);
} }
void checkScreenRotation() { void checkScreenRotation() {

View File

@ -11,7 +11,7 @@ void checkInputs() {
if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s is for entering the submenu if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s is for entering the submenu
if (!insideTab && displayScreen == 0) { if (!insideTab && displayScreen == 0) {
insideTab = true; insideTab = true;
} else if (insideTab && channels[displayTab - 1].mode == 2 && menuItem == 1 && displayScreen == 0) { //enter the pattern editor } else if (insideTab && channels[displayTab - 1].mode == 2 && menuItem == 2 && displayScreen == 0) { //enter the pattern editor
if (channels[displayTab - 1].seqPattern == 0) { if (channels[displayTab - 1].seqPattern == 0) {
patternToEdit = seqA1; patternToEdit = seqA1;
} else if (channels[displayTab - 1].seqPattern == 1) { } else if (channels[displayTab - 1].seqPattern == 1) {
@ -58,11 +58,9 @@ void checkInputs() {
rotateScreen = !rotateScreen; rotateScreen = !rotateScreen;
saveState(); saveState();
checkScreenRotation(); checkScreenRotation();
//setup();
//resetFunc();
} else if (displayScreen == 2 && menuItem == 2) { } else if (displayScreen == 2 && menuItem == 2) {
EEPROM.put(1023, memCode - 1); EEPROM.put(1023, memCode - 1);
resetFunc(); reboot();
} }
updateScreen(); updateScreen();
} else if (encReleasedTime - encPressedTime < 2000) { // longer press (<2s) is for navigating back. longer than 2s presses are ignored } else if (encReleasedTime - encPressedTime < 2000) { // longer press (<2s) is for navigating back. longer than 2s presses are ignored
@ -137,7 +135,7 @@ void checkInputs() {
} else if (menuItem > lastMenuItem) { } else if (menuItem > lastMenuItem) {
menuItem = lastMenuItem; menuItem = lastMenuItem;
} }
} else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 0) { //Master Clock Mode } else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 1) { //Master Clock Mode
masterClockMode = masterClockMode + change; masterClockMode = masterClockMode + change;
if (masterClockMode > 100) { if (masterClockMode > 100) {
masterClockMode = 0; masterClockMode = 0;
@ -145,7 +143,7 @@ void checkInputs() {
masterClockMode = 1; masterClockMode = 1;
} }
saveState(); saveState();
} else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 1) { //Modulation channel } else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 2) { //Modulation channel
bpmModulationChannel = bpmModulationChannel + change; bpmModulationChannel = bpmModulationChannel + change;
if (bpmModulationChannel == 0 || bpmModulationChannel == 1) { if (bpmModulationChannel == 0 || bpmModulationChannel == 1) {
bpmModulationRange = 1; bpmModulationRange = 1;
@ -156,7 +154,7 @@ void checkInputs() {
bpmModulationChannel = 1; bpmModulationChannel = 1;
} }
saveState(); saveState();
} else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 2) { //Modulation range } else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 3) { //Modulation range
bpmModulationRange = bpmModulationRange + change; bpmModulationRange = bpmModulationRange + change;
if (bpmModulationRange == 0) { if (bpmModulationRange == 0) {
bpmModulationRange = 1; bpmModulationRange = 1;
@ -166,7 +164,7 @@ void checkInputs() {
bpmModulationRange = 5; bpmModulationRange = 5;
} }
saveState(); saveState();
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 0) { //Channel Mode } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1) { //Channel Mode
channels[displayTab - 1].mode = channels[displayTab - 1].mode + change; channels[displayTab - 1].mode = channels[displayTab - 1].mode + change;
if (channels[displayTab - 1].mode > 100) { if (channels[displayTab - 1].mode > 100) {
channels[displayTab - 1].mode = 0; channels[displayTab - 1].mode = 0;
@ -176,7 +174,7 @@ void checkInputs() {
channels[displayTab - 1].CV1Target = 0; channels[displayTab - 1].CV1Target = 0;
channels[displayTab - 1].CV2Target = 0; channels[displayTab - 1].CV2Target = 0;
saveState(); saveState();
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1 && channels[displayTab - 1].mode == 0) { //Offset } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 0) { //Offset
channels[displayTab - 1].offset = channels[displayTab - 1].offset + change; channels[displayTab - 1].offset = channels[displayTab - 1].offset + change;
if (channels[displayTab - 1].offset > 100) { if (channels[displayTab - 1].offset > 100) {
channels[displayTab - 1].offset = 0; channels[displayTab - 1].offset = 0;
@ -184,7 +182,7 @@ void checkInputs() {
channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab-1]; channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab-1];
} }
saveState(); saveState();
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1 && channels[displayTab - 1].mode == 1) { //SUBDIV for RANDOM } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 1) { //SUBDIV for RANDOM
channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change; channels[displayTab - 1].subDiv = channels[displayTab - 1].subDiv - change;
if (channels[displayTab - 1].subDiv > 200) { if (channels[displayTab - 1].subDiv > 200) {
channels[displayTab - 1].subDiv = 0; channels[displayTab - 1].subDiv = 0;
@ -195,7 +193,7 @@ void checkInputs() {
calculateCycles(); calculateCycles();
} }
saveState(); saveState();
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 0) { //CV1 for CLK } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 0) { //CV1 for CLK
channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change; channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change;
if (channels[displayTab - 1].CV1Target > 100) { if (channels[displayTab - 1].CV1Target > 100) {
channels[displayTab - 1].CV1Target = 0; channels[displayTab - 1].CV1Target = 0;
@ -204,7 +202,7 @@ void checkInputs() {
} }
saveState(); saveState();
} }
else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 0) { //CV2 for CLK else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 4 && channels[displayTab - 1].mode == 0) { //CV2 for CLK
channels[displayTab - 1].CV2Target = channels[displayTab - 1].CV2Target + change; channels[displayTab - 1].CV2Target = channels[displayTab - 1].CV2Target + change;
if (channels[displayTab - 1].CV2Target > 100) { if (channels[displayTab - 1].CV2Target > 100) {
channels[displayTab - 1].CV2Target = 0; channels[displayTab - 1].CV2Target = 0;
@ -212,7 +210,7 @@ void checkInputs() {
channels[displayTab - 1].CV2Target = 1; channels[displayTab - 1].CV2Target = 1;
} }
saveState(); saveState();
} else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 1) { //CV1 for RND } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 1) { //CV1 for RND
channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change; channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change;
if (channels[displayTab - 1].CV1Target > 100) { if (channels[displayTab - 1].CV1Target > 100) {
channels[displayTab - 1].CV1Target = 0; channels[displayTab - 1].CV1Target = 0;
@ -221,7 +219,7 @@ void checkInputs() {
} }
saveState(); saveState();
} }
else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 1) { //CV2 for RND else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 4 && channels[displayTab - 1].mode == 1) { //CV2 for RND
channels[displayTab - 1].CV2Target = channels[displayTab - 1].CV2Target + change; channels[displayTab - 1].CV2Target = channels[displayTab - 1].CV2Target + change;
if (channels[displayTab - 1].CV2Target > 100) { if (channels[displayTab - 1].CV2Target > 100) {
channels[displayTab - 1].CV2Target = 0; channels[displayTab - 1].CV2Target = 0;

View File

@ -12,25 +12,25 @@ void updateScreen() {
//Menu items //Menu items
byte menuItemWidth = 32; byte menuItemWidth = 32;
if (masterClockMode == 0 && bpmModulationRange == 0) { if (masterClockMode == 0 && bpmModulationRange == 0) {
lastMenuItem = 1;
} else if (masterClockMode == 0 && bpmModulationRange != 0) {
lastMenuItem = 2; lastMenuItem = 2;
} else if (masterClockMode == 0 && bpmModulationRange != 0) {
lastMenuItem = 3;
} else if (masterClockMode == 1) { } else if (masterClockMode == 1) {
lastMenuItem = 0; lastMenuItem = 0;
} }
if (menuItem == 0 && insideTab) { if ((menuItem == 1 && insideTab) || (insideTab && masterClockMode == 1 && menuItem == 0)) {
u8g2.drawButtonUTF8(62, 6, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MODE:" ); u8g2.drawButtonUTF8(62, 6, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MODE:" );
} else { } else {
u8g2.drawButtonUTF8(62, 6, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MODE:" ); u8g2.drawButtonUTF8(62, 6, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MODE:" );
} }
if (masterClockMode == 0) { if (masterClockMode == 0) {
if (menuItem == 1) { if (menuItem == 2) {
u8g2.drawButtonUTF8(62, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MOD:" ); u8g2.drawButtonUTF8(62, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MOD:" );
} else { } else {
u8g2.drawButtonUTF8(62, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MOD:" ); u8g2.drawButtonUTF8(62, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MOD:" );
} }
if (bpmModulationRange != 0) { if (bpmModulationRange != 0) {
if (menuItem == 2) { if (menuItem == 3) {
u8g2.drawButtonUTF8(62, 26, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "RANGE:" ); u8g2.drawButtonUTF8(62, 26, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "RANGE:" );
} else { } else {
u8g2.drawButtonUTF8(62, 26, U8G2_BTN_BW0, menuItemWidth, 2, 2, "RANGE:" ); u8g2.drawButtonUTF8(62, 26, U8G2_BTN_BW0, menuItemWidth, 2, 2, "RANGE:" );
@ -39,39 +39,39 @@ void updateScreen() {
} }
//Values //Values
byte valueWidth = 28; byte valueWidth = 28;
if (menuItem == 0 && insideTab && masterClockMode == 0) { if (menuItem == 1 && insideTab && masterClockMode == 0) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "INT" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "INT" );
} else if ((menuItem != 0 || !insideTab) && masterClockMode == 0) { } else if ((menuItem != 1 || !insideTab) && masterClockMode == 0) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0, valueWidth, 2, 2, "INT" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0, valueWidth, 2, 2, "INT" );
} }
if (menuItem == 0 && insideTab && masterClockMode == 1) { if (menuItem == 1 && insideTab && masterClockMode == 1) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 2, 2, "EXT" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 2, 2, "EXT" );
} else if ((menuItem != 0 || !insideTab) && masterClockMode == 1) { } else if ((menuItem != 1 || !insideTab) && masterClockMode == 1) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0, valueWidth, 2, 2, "EXT" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0, valueWidth, 2, 2, "EXT" );
} }
if (masterClockMode == 0) { if (masterClockMode == 0) {
if (menuItem == 1 && bpmModulationRange != 0 && bpmModulationChannel == 0) { if (menuItem == 2 && bpmModulationRange != 0 && bpmModulationChannel == 0) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CV1" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CV1" );
} else if (menuItem != 1 && bpmModulationRange != 0 && bpmModulationChannel == 0) { } else if (menuItem != 2 && bpmModulationRange != 0 && bpmModulationChannel == 0) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 3, 2, "CV1" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 3, 2, "CV1" );
} }
if (menuItem == 1 && bpmModulationRange != 0 && bpmModulationChannel == 1) { if (menuItem == 2 && bpmModulationRange != 0 && bpmModulationChannel == 1) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CV2" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CV2" );
} else if (menuItem != 1 && bpmModulationRange != 0 && bpmModulationChannel == 1){ } else if (menuItem != 2 && bpmModulationRange != 0 && bpmModulationChannel == 1){
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 2, 2, "CV2" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 2, 2, "CV2" );
} }
if (menuItem == 1 && bpmModulationRange == 0) { if (menuItem == 2 && bpmModulationRange == 0) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "OFF" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "OFF" );
} else if (menuItem != 1 && bpmModulationRange == 0) { } else if (menuItem != 2 && bpmModulationRange == 0) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" );
} }
String bpmModStr = String(bpmModulationRange * 10); String bpmModStr = String(bpmModulationRange * 10);
char bpmModChar[3]; char bpmModChar[3];
bpmModStr.toCharArray(bpmModChar, 3); bpmModStr.toCharArray(bpmModChar, 3);
if (menuItem == 2 && bpmModulationRange != 0) { if (menuItem == 3 && bpmModulationRange != 0) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 4, 2, bpmModChar ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 4, 2, bpmModChar );
} else if (menuItem != 2 && bpmModulationRange != 0) { } else if (menuItem != 3 && bpmModulationRange != 0) {
u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 26, U8G2_BTN_BW0, valueWidth, 4, 2, bpmModChar ); u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 26, U8G2_BTN_BW0, valueWidth, 4, 2, bpmModChar );
} }
} }
@ -85,11 +85,15 @@ void updateScreen() {
char bpmChar[5]; char bpmChar[5];
bpmStr.toCharArray(bpmChar, 5); bpmStr.toCharArray(bpmChar, 5);
u8g2.setFont(u8g2_font_logisoso24_tn); u8g2.setFont(u8g2_font_logisoso24_tn);
if (!insideTab && shiftBtnPushed && masterClockMode == 0) { if (((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) && masterClockMode == 0) {
u8g2.drawButtonUTF8(28, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 0, bpmChar ); u8g2.drawButtonUTF8(28, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 0, bpmChar );
u8g2.setFont(velvetscreen); u8g2.setFont(velvetscreen);
if (masterClockMode == 0) { if (masterClockMode == 0) {
if (insideTab && menuItem == 0 && !menuItemSelected && !shiftBtnPushed) {
u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 55, 0, 2, "BPM" );
} else {
u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 55, 0, 2, "BPM" ); u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 55, 0, 2, "BPM" );
}
} else { } else {
u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 55, 0, 2, "PPQN" ); u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 55, 0, 2, "PPQN" );
} }
@ -107,34 +111,34 @@ void updateScreen() {
//Channel Tabs //Channel Tabs
else { else {
//Menu items //Menu items
lastMenuItem = 3; lastMenuItem = 4;
byte menuItemWidth = 32; byte menuItemWidth = 32;
if (menuItem == 0 && insideTab) { if (menuItem == 1 && insideTab) {
u8g2.drawButtonUTF8(2, 6, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MODE:" ); u8g2.drawButtonUTF8(2, 6, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MODE:" );
} else { } else {
u8g2.drawButtonUTF8(2, 6, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MODE:" ); u8g2.drawButtonUTF8(2, 6, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MODE:" );
} }
if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 0) { if (menuItem == 2 && insideTab && channels[displayTab - 1].mode == 0) {
u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "OFFSET:" ); u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "OFFSET:" );
} else if ((menuItem != 1 || insideTab) && channels[displayTab - 1].mode == 0) { } else if ((menuItem != 1 || insideTab) && channels[displayTab - 1].mode == 0) {
u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "OFFSET:" ); u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "OFFSET:" );
} }
if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 1) { if (menuItem == 2 && insideTab && channels[displayTab - 1].mode == 1) {
u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "SUBDIV:" ); u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "SUBDIV:" );
} else if ((menuItem != 1 || insideTab) && channels[displayTab - 1].mode == 1) { } else if ((menuItem != 1 || insideTab) && channels[displayTab - 1].mode == 1) {
u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "SUBDIV:" ); u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "SUBDIV:" );
} }
if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 2) { if (menuItem == 2 && insideTab && channels[displayTab - 1].mode == 2) {
u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "EDIT PATTERN" ); u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "EDIT PATTERN" );
} else if ((menuItem != 1 || insideTab) && channels[displayTab - 1].mode == 2) { } else if ((menuItem != 1 || insideTab) && channels[displayTab - 1].mode == 2) {
u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "EDIT PATTERN" ); u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "EDIT PATTERN" );
} }
if (menuItem == 2 && insideTab) { if (menuItem == 3 && insideTab) {
u8g2.drawButtonUTF8(2, 26, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "CV1:" ); u8g2.drawButtonUTF8(2, 26, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "CV1:" );
} else { } else {
u8g2.drawButtonUTF8(2, 26, U8G2_BTN_BW0, menuItemWidth, 2, 2, "CV1:" ); u8g2.drawButtonUTF8(2, 26, U8G2_BTN_BW0, menuItemWidth, 2, 2, "CV1:" );
} }
if (menuItem == 3 && insideTab) { if (menuItem == 4 && insideTab) {
u8g2.drawButtonUTF8(2, 36, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "CV2:" ); u8g2.drawButtonUTF8(2, 36, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "CV2:" );
} else { } else {
u8g2.drawButtonUTF8(2, 36, U8G2_BTN_BW0, menuItemWidth, 2, 2, "CV2:" ); u8g2.drawButtonUTF8(2, 36, U8G2_BTN_BW0, menuItemWidth, 2, 2, "CV2:" );
@ -145,17 +149,17 @@ void updateScreen() {
//Values //Values
byte valueWidth = 28; byte valueWidth = 28;
if (menuItem == 0 && insideTab && channels[displayTab - 1].mode == 0) { if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 0) {
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CLOCK" ); u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CLOCK" );
} else if ((menuItem != 0 || !insideTab) && channels[displayTab - 1].mode == 0) { } else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 0) {
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "CLOCK" ); u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "CLOCK" );
} else if (menuItem == 0 && insideTab && channels[displayTab - 1].mode == 1) { } else if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 1) {
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "RAND" ); u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "RAND" );
} else if ((menuItem != 0 || !insideTab) && channels[displayTab - 1].mode == 1) { } else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 1) {
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "RAND" ); u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "RAND" );
} else if (menuItem == 0 && insideTab && channels[displayTab - 1].mode == 2) { } else if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 2) {
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "SEQ" ); u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "SEQ" );
} else if ((menuItem != 0 || !insideTab) && channels[displayTab - 1].mode == 2) { } else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 2) {
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "SEQ" ); u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "SEQ" );
} }
@ -169,65 +173,90 @@ void updateScreen() {
valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv])); valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv]));
} }
valueStr.toCharArray(valueChar, 8); valueStr.toCharArray(valueChar, 8);
if (menuItem == 1 && insideTab && channels[displayTab - 1].mode != 2) { if (menuItem == 2 && insideTab && channels[displayTab - 1].mode != 2) {
u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, valueChar ); u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, valueChar );
} else if ((menuItem != 1 || !insideTab)) { } else if ((menuItem != 2 || !insideTab)) {
u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0, valueWidth, 3, 2, valueChar ); u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0, valueWidth, 3, 2, valueChar );
} }
//CV1 //CV1
if (menuItem == 2 && insideTab && channels[displayTab - 1].CV1Target == 1) { if (menuItem == 3 && insideTab && channels[displayTab - 1].CV1Target == 1) {
u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "SUBDIV" ); u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "SUBDIV" );
} else if ((menuItem != 2 || !insideTab) && channels[displayTab - 1].CV1Target == 1) { } else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV1Target == 1) {
u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "SUBDIV" ); u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "SUBDIV" );
} else if (menuItem == 2 && insideTab && channels[displayTab - 1].CV1Target == 2) { } else if (menuItem == 3 && insideTab && channels[displayTab - 1].CV1Target == 2) {
u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "RAND" ); u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "RAND" );
} else if ((menuItem != 2 || !insideTab) && channels[displayTab - 1].CV1Target == 2) { } else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV1Target == 2) {
u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "RAND" ); u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "RAND" );
} else if (menuItem == 2 && !insideTab && channels[displayTab - 1].CV1Target == 3) { } else if (menuItem == 3 && !insideTab && channels[displayTab - 1].CV1Target == 3) {
u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "PATT" ); u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "PATT" );
} else if ((menuItem != 2 || !insideTab) && channels[displayTab - 1].CV1Target == 3) { } else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV1Target == 3) {
u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "PATT" ); u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "PATT" );
} else if (menuItem == 2 && insideTab && channels[displayTab - 1].CV1Target == 0) { } else if (menuItem == 3 && insideTab && channels[displayTab - 1].CV1Target == 0) {
u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "OFF" ); u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "OFF" );
} else if ((menuItem != 2 || !insideTab) && channels[displayTab - 1].CV1Target == 0) { } else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV1Target == 0) {
u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" ); u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" );
} }
//CV2 //CV2
if (menuItem == 3 && insideTab && channels[displayTab - 1].CV2Target == 1) { if (menuItem == 4 && insideTab && channels[displayTab - 1].CV2Target == 1) {
u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "SUBDIV" ); u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "SUBDIV" );
} else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV2Target == 1) { } else if ((menuItem != 4 || !insideTab) && channels[displayTab - 1].CV2Target == 1) {
u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "SUBDIV" ); u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "SUBDIV" );
} else if (menuItem == 3 && insideTab && channels[displayTab - 1].CV2Target == 2) { } else if (menuItem == 4 && insideTab && channels[displayTab - 1].CV2Target == 2) {
u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "RANDOM" ); u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "RANDOM" );
} else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV2Target == 2) { } else if ((menuItem != 4 || !insideTab) && channels[displayTab - 1].CV2Target == 2) {
u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "RANDOM" ); u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "RANDOM" );
} else if (menuItem == 3 && !insideTab && channels[displayTab - 1].CV2Target == 3) { } else if (menuItem == 4 && !insideTab && channels[displayTab - 1].CV2Target == 3) {
u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "PATTERN" ); u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "PATTERN" );
} else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV2Target == 3) { } else if ((menuItem != 4 || !insideTab) && channels[displayTab - 1].CV2Target == 3) {
u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "PATTERN" ); u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "PATTERN" );
} else if (menuItem == 3 && insideTab && channels[displayTab - 1].CV2Target == 0) { } else if (menuItem == 4 && insideTab && channels[displayTab - 1].CV2Target == 0) {
u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "OFF" ); u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "OFF" );
} else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV2Target == 0) { } else if ((menuItem != 4 || !insideTab) && channels[displayTab - 1].CV2Target == 0) {
u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" ); u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" );
} }
//Main Param //Main Param
if (channels[displayTab - 1].mode == 0 && subDivs[channels[displayTab - 1].subDiv] > 0) { if (channels[displayTab - 1].mode == 0) {
if (subDivs[channels[displayTab - 1].subDiv] > 0) {
valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]); valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]);
} else if (channels[displayTab - 1].mode == 0 && subDivs[channels[displayTab - 1].subDiv] < 0) { } else {
valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv])); valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv]));
}
if (insideTab && menuItem == 0 && !menuItemSelected && !shiftBtnPushed) {
u8g2.drawButtonUTF8(96, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 2, "SUBDIVISION" );
} else if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && shiftBtnPushed) || (insideTab && menuItem == 0 && menuItemSelected)) {
u8g2.drawButtonUTF8(96, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 56, 0, 2, "SUBDIVISION" );
} else {
u8g2.drawButtonUTF8(96, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 56, 0, 2, "SUBDIVISION" );
}
} else if (channels[displayTab - 1].mode == 1) { } else if (channels[displayTab - 1].mode == 1) {
valueStr = String(channels[displayTab - 1].random) + "0%"; valueStr = String(channels[displayTab - 1].random) + "0%";
} else if (channels[displayTab - 1].mode == 2 && channels[displayTab - 1].seqPattern < 8) { if (insideTab && menuItem == 0 && !menuItemSelected && !shiftBtnPushed) {
u8g2.drawButtonUTF8(96, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 2, "SKIP CHANCE" );
} else if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && shiftBtnPushed) || (insideTab && menuItem == 0 && menuItemSelected)) {
u8g2.drawButtonUTF8(96, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 56, 0, 2, "SKIP CHANCE" );
} else {
u8g2.drawButtonUTF8(96, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 56, 0, 2, "SKIP CHANCE" );
}
} else if (channels[displayTab - 1].mode == 2) {
if (channels[displayTab - 1].seqPattern < 8) {
valueStr = "A" + String(channels[displayTab - 1].seqPattern + 1); valueStr = "A" + String(channels[displayTab - 1].seqPattern + 1);
} else if (channels[displayTab - 1].mode == 2 && channels[displayTab - 1].seqPattern >= 8) { } else {
valueStr = "B" + String(channels[displayTab - 1].seqPattern - 7); valueStr = "B" + String(channels[displayTab - 1].seqPattern - 7);
} }
if (insideTab && menuItem == 0 && !menuItemSelected && !shiftBtnPushed) {
u8g2.drawButtonUTF8(96, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 2, "PATTERN" );
} else if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && shiftBtnPushed) || (insideTab && menuItem == 0 && menuItemSelected)) {
u8g2.drawButtonUTF8(96, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 56, 0, 2, "PATTERN" );
} else {
u8g2.drawButtonUTF8(96, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 56, 0, 2, "PATTERN" );
}
}
valueStr.toCharArray(valueChar, 8); valueStr.toCharArray(valueChar, 8);
u8g2.setFont(u8g2_font_logisoso24_tr); u8g2.setFont(u8g2_font_logisoso24_tr);
if (!insideTab && shiftBtnPushed) { if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) {
u8g2.drawButtonUTF8(96, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 0, valueChar ); u8g2.drawButtonUTF8(96, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 0, valueChar );
} else { } else {
u8g2.drawButtonUTF8(96, 26, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 56, 0, 0, valueChar ); u8g2.drawButtonUTF8(96, 26, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 56, 0, 0, valueChar );