void updateScreen() { u8g2.firstPage(); do { if (displayScreen == 0) { //BPM Tab if (displayTab == 0) { //BPM u8g2.setFont(velvetscreen); //Menu items byte menuItemWidth = 32; if (masterClockMode == 0 && bpmModulationRange == 0) { lastMenuItem = 1; } else if (masterClockMode == 0 && bpmModulationRange != 0) { lastMenuItem = 2; } else if (masterClockMode == 1) { lastMenuItem = 0; } if (menuItem == 0 && insideTab) { u8g2.drawButtonUTF8(62, 6, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MODE:" ); } else { u8g2.drawButtonUTF8(62, 6, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MODE:" ); } if (masterClockMode == 0) { if (menuItem == 1) { u8g2.drawButtonUTF8(62, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MOD:" ); } else { u8g2.drawButtonUTF8(62, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MOD:" ); } if (bpmModulationRange != 0) { if (menuItem == 2) { u8g2.drawButtonUTF8(62, 26, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "RANGE:" ); } else { u8g2.drawButtonUTF8(62, 26, U8G2_BTN_BW0, menuItemWidth, 2, 2, "RANGE:" ); } } } //Values byte valueWidth = 28; if (menuItem == 0 && insideTab && masterClockMode == 0) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "INT" ); } else if ((menuItem != 0 || !insideTab) && masterClockMode == 0) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0, valueWidth, 2, 2, "INT" ); } if (menuItem == 0 && masterClockMode == 1) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 2, 2, "EXT" ); } else if (menuItem != 0 && masterClockMode == 1) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0, valueWidth, 2, 2, "EXT" ); } if (masterClockMode == 0) { if (menuItem == 1 && bpmModulationRange != 0 && bpmModulationChannel == 0) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CV1" ); } else if (menuItem != 1 && bpmModulationRange != 0 && bpmModulationChannel == 0) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 3, 2, "CV1" ); } if (menuItem == 1 && bpmModulationRange != 0 && bpmModulationChannel == 1) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CV2" ); } else if (menuItem != 1 && bpmModulationRange != 0 && bpmModulationChannel == 1){ u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 2, 2, "CV2" ); } if (menuItem == 1 && bpmModulationRange == 0) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "OFF" ); } else if (menuItem != 1 && bpmModulationRange == 0) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" ); } String bpmModStr = String(bpmModulationRange * 10); char bpmModChar[3]; bpmModStr.toCharArray(bpmModChar, 3); if (menuItem == 2 && bpmModulationRange != 0) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 4, 2, bpmModChar ); } else if (menuItem != 2 && bpmModulationRange != 0) { u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 26, U8G2_BTN_BW0, valueWidth, 4, 2, bpmModChar ); } } String bpmStr = String(bpm); char bpmChar[5]; bpmStr.toCharArray(bpmChar, 5); u8g2.setFont(u8g2_font_logisoso24_tn); if (!insideTab && shiftBtnPushed) { u8g2.drawButtonUTF8(28, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 0, bpmChar ); u8g2.setFont(velvetscreen); u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 55, 0, 2, "BPM" ); } else { u8g2.drawButtonUTF8(28, 26, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 56, 0, 0, bpmChar ); u8g2.setFont(velvetscreen); u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 55, 0, 2, "BPM" ); } } //Channel Tabs else { //Menu items lastMenuItem = 3; byte menuItemWidth = 32; if (menuItem == 0 && insideTab) { u8g2.drawButtonUTF8(2, 6, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MODE:" ); } else { u8g2.drawButtonUTF8(2, 6, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MODE:" ); } if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 0) { u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "OFFSET:" ); } else if ((menuItem != 1 || insideTab) && channels[displayTab - 1].mode == 0) { u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "OFFSET:" ); } if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 1) { u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "SUBDIV:" ); } else if ((menuItem != 1 || insideTab) && channels[displayTab - 1].mode == 1) { u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "SUBDIV:" ); } if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 2) { 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) { u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "EDIT PATTERN" ); } if (menuItem == 2 && insideTab) { u8g2.drawButtonUTF8(2, 26, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "CV1:" ); } else { u8g2.drawButtonUTF8(2, 26, U8G2_BTN_BW0, menuItemWidth, 2, 2, "CV1:" ); } if (menuItem == 3 && insideTab) { u8g2.drawButtonUTF8(2, 36, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "CV2:" ); } else { u8g2.drawButtonUTF8(2, 36, U8G2_BTN_BW0, menuItemWidth, 2, 2, "CV2:" ); } String valueStr; char valueChar[8]; //Values byte valueWidth = 28; if (menuItem == 0 && insideTab && channels[displayTab - 1].mode == 0) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "CLOCK" ); } else if (menuItem == 0 && insideTab && channels[displayTab - 1].mode == 1) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "RAND" ); } else if (menuItem == 0 && insideTab && channels[displayTab - 1].mode == 2) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "SEQ" ); } //SubDiv and offset if (channels[displayTab - 1].mode == 0) { valueStr = String(channels[displayTab - 1].offset) + "/"; valueStr = valueStr + String(channelPulsesPerCycle[displayTab-1]+1); } else if (channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] > 0) { valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]); } else if (channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] < 0) { valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv])); } valueStr.toCharArray(valueChar, 8); if (menuItem == 1 && insideTab && channels[displayTab - 1].mode != 2) { u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, valueChar ); } else if ((menuItem != 1 || !insideTab)) { u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0, valueWidth, 3, 2, valueChar ); } //CV1 if (menuItem == 2 && insideTab && channels[displayTab - 1].CV1Target == 1) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "SUBDIV" ); } else if (menuItem == 2 && insideTab && channels[displayTab - 1].CV1Target == 2) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "RAND" ); } else if (menuItem == 2 && !insideTab && channels[displayTab - 1].CV1Target == 3) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "PATT" ); } else if (menuItem == 2 && insideTab && channels[displayTab - 1].CV1Target == 0) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" ); } //CV2 if (menuItem == 3 && insideTab && channels[displayTab - 1].CV2Target == 1) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "SUBDIV" ); } else if (menuItem == 3 && insideTab && channels[displayTab - 1].CV2Target == 2) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "RANDOM" ); } else if (menuItem == 3 && !insideTab && channels[displayTab - 1].CV2Target == 3) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "PATTERN" ); } else if (menuItem == 3 && insideTab && channels[displayTab - 1].CV2Target == 0) { 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) { u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" ); } //Main Param if (channels[displayTab - 1].mode == 0 && subDivs[channels[displayTab - 1].subDiv] > 0) { valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]); } else if (channels[displayTab - 1].mode == 0 && subDivs[channels[displayTab - 1].subDiv] < 0) { 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 && 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); u8g2.setFont(u8g2_font_logisoso24_tr); if (!insideTab && shiftBtnPushed) { u8g2.drawButtonUTF8(96, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 0, valueChar ); } else { u8g2.drawButtonUTF8(96, 26, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 56, 0, 0, valueChar ); } } //Tabs u8g2.drawHLine(0, 53, 128); u8g2.setFont(velvetscreen); byte yPos = 61; byte xWidth = 12; if (displayTab == 0) { if (insideTab == true || shiftBtnPushed == true) { u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW1|U8G2_BTN_HCENTER, xWidth-2, 0, 2, "w" ); } else { u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, xWidth-2, 0, 2, "w" ); } } else { u8g2.drawButtonUTF8(xWidth/2, yPos, U8G2_BTN_BW0|U8G2_BTN_HCENTER, xWidth, 0, 2, "w" ); } for (int i = 1; i <= 6; i++) { String tabNameStr = String(i); char tabNameChar[3]; tabNameStr.toCharArray(tabNameChar, 3); if (displayTab == i) { if (insideTab == true || shiftBtnPushed == true) { u8g2.drawButtonUTF8(i*xWidth + xWidth/2, yPos, U8G2_BTN_BW1|U8G2_BTN_HCENTER, xWidth-2, 0, 2, tabNameChar); } else { u8g2.drawButtonUTF8(i*xWidth + xWidth/2, yPos, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, xWidth-2, 0, 2, tabNameChar); } } else { u8g2.drawButtonUTF8(i*xWidth + xWidth/2, yPos, U8G2_BTN_BW0|U8G2_BTN_HCENTER, xWidth, 0, 2, tabNameChar); } } if (!isPlaying) { u8g2.drawUTF8(121, yPos, "t"); } else { u8g2.drawUTF8(122, yPos, "r"); } } } while ( u8g2.nextPage() ); }