From adc80bd6260346ddafe22ce5793973b074f1fd86 Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Sat, 12 Aug 2023 23:58:27 +0300 Subject: [PATCH] reworked the menu --- .../GRAVITY REV 3 BOM.csv | 18 + Hardware/gtoe/gtoe.kicad_prl | 4 +- Software/Gravity/Interactions.ino | 19 +- Software/Gravity/UI.ino | 320 ++++++++---------- 4 files changed, 178 insertions(+), 183 deletions(-) create mode 100644 Hardware/gtoe/Production files REV3/GRAVITY REV 3 BOM.csv diff --git a/Hardware/gtoe/Production files REV3/GRAVITY REV 3 BOM.csv b/Hardware/gtoe/Production files REV3/GRAVITY REV 3 BOM.csv new file mode 100644 index 0000000..af0fa87 --- /dev/null +++ b/Hardware/gtoe/Production files REV3/GRAVITY REV 3 BOM.csv @@ -0,0 +1,18 @@ +"Id";"Designator";"Package";"Quantity";"Designation";"Supplier and ref"; +1;"J9,J2,J5,J3,J8,J6,J1,J4,J7";"thonkiconn";9;"AudioJack2_SwitchT";;; +2;"SW3,SW1";"button";2;"SW_DIP_x01";;; +3;"D5,D4,D3,D2,D6,D1";"FlatTopLed";6;"LED";;; +4;"Screen";"I2C SSD1306";1;"SSD1306";;; +5;"SW2";"SwitchEncoder";1;"RotaryEncoder_Switch";;; +6;"D13,D12";"D_SOD-123";2;"1N5819HW";;; +7;"R24,R19,R9,R3,R23,R7,R12,R10,R22,R18,R2,R5,R11,R1,R15,R8,R4,R17,R6,R16";"R_0805_2012Metric";20;"1K";;; +8;"C1,C2";"CP_Radial_D4.0mm_P2.00mm";2;"10uF";;; +9;"D9,D11,D8,D10";"D_SOD-123";4;"BAT43";;; +10;"U2,U1";"SO-14_3.9x8.65mm_P1.27mm";2;"TL074";;; +11;"A1";"Arduino_Nano (adjusted courtyard)";1;"Arduino_Nano_v2.x";;; +12;"R13,R14";"R_0805_2012Metric";2;"10k";;; +13;"J11";"PinHeader_1x06_P2.54mm_Vertical";1;"Conn_01x05";;; +14;"R20,R21";"R_0805_2012Metric";2;"100K";;; +15;"D7";"D_SOD-123";1;"1N4148";;; +16;"Q1";"TO-92_Inline";1;"PN2222A";;; +17;"J10";"PinHeader_2x05_P2.54mm_Vertical";1;"Power";;; diff --git a/Hardware/gtoe/gtoe.kicad_prl b/Hardware/gtoe/gtoe.kicad_prl index e3c55b3..693a188 100644 --- a/Hardware/gtoe/gtoe.kicad_prl +++ b/Hardware/gtoe/gtoe.kicad_prl @@ -1,7 +1,7 @@ { "board": { "active_layer": 31, - "active_layer_preset": "Back Assembly View", + "active_layer_preset": "", "auto_track_width": false, "hidden_nets": [], "high_contrast_mode": 0, @@ -62,7 +62,7 @@ 35, 36 ], - "visible_layers": "0015050_00000000", + "visible_layers": "0015050_80000001", "zone_display_mode": 0 }, "meta": { diff --git a/Software/Gravity/Interactions.ino b/Software/Gravity/Interactions.ino index 58918be..c170d28 100644 --- a/Software/Gravity/Interactions.ino +++ b/Software/Gravity/Interactions.ino @@ -71,6 +71,7 @@ void checkInputs() { insideTab = 0; menuItem = 0; isRecording = 0; + menuItemSelected = 0; } } else if (encReleasedTime - encPressedTime > 2000 && shiftBtnPushed) { //2s+ combo with shift to open the settings displayScreen = 2; @@ -162,7 +163,7 @@ void checkInputs() { masterClockMode = 1; } saveState(); - } else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 2) { //Modulation channel + } else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab == 0 && menuItem == 2) { //Modulation channel bpmModulationChannel = bpmModulationChannel + change; if (bpmModulationChannel == 0 || bpmModulationChannel == 1) { bpmModulationRange = 1; @@ -173,7 +174,7 @@ void checkInputs() { bpmModulationChannel = 1; } saveState(); - } else if (insideTab && shiftBtnPushed && displayTab == 0 && menuItem == 3) { //Modulation range + } else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab == 0 && menuItem == 3) { //Modulation range bpmModulationRange = bpmModulationRange + change; if (bpmModulationRange == 0) { bpmModulationRange = 1; @@ -183,7 +184,7 @@ void checkInputs() { bpmModulationRange = 5; } saveState(); - } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 1) { //Channel Mode + } else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 1) { //Channel Mode channels[displayTab - 1].mode = channels[displayTab - 1].mode + change; if (channels[displayTab - 1].mode > 100) { channels[displayTab - 1].mode = 0; @@ -193,7 +194,7 @@ void checkInputs() { channels[displayTab - 1].CV1Target = 0; channels[displayTab - 1].CV2Target = 0; saveState(); - } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 0) { //Offset + } else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 0) { //Offset channels[displayTab - 1].offset = channels[displayTab - 1].offset + change; if (channels[displayTab - 1].offset > 100) { channels[displayTab - 1].offset = 0; @@ -201,7 +202,7 @@ void checkInputs() { channels[displayTab - 1].offset = channelPulsesPerCycle[displayTab-1]; } saveState(); - } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 2 && channels[displayTab - 1].mode == 1) { //SUBDIV for RANDOM + } else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 2 && 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; @@ -212,7 +213,7 @@ void checkInputs() { calculateCycles(); } saveState(); - } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 0) { //CV1 for CLK + } else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 0) { //CV1 for CLK channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change; if (channels[displayTab - 1].CV1Target > 100) { channels[displayTab - 1].CV1Target = 0; @@ -221,7 +222,7 @@ void checkInputs() { } saveState(); } - else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 4 && channels[displayTab - 1].mode == 0) { //CV2 for CLK + else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 4 && channels[displayTab - 1].mode == 0) { //CV2 for CLK channels[displayTab - 1].CV2Target = channels[displayTab - 1].CV2Target + change; if (channels[displayTab - 1].CV2Target > 100) { channels[displayTab - 1].CV2Target = 0; @@ -229,7 +230,7 @@ void checkInputs() { channels[displayTab - 1].CV2Target = 1; } saveState(); - } else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 1) { //CV1 for RND + } else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 3 && channels[displayTab - 1].mode == 1) { //CV1 for RND channels[displayTab - 1].CV1Target = channels[displayTab - 1].CV1Target + change; if (channels[displayTab - 1].CV1Target > 100) { channels[displayTab - 1].CV1Target = 0; @@ -238,7 +239,7 @@ void checkInputs() { } saveState(); } - else if (insideTab && shiftBtnPushed && displayTab != 0 && menuItem == 4 && channels[displayTab - 1].mode == 1) { //CV2 for RND + else if (insideTab && (menuItemSelected || shiftBtnPushed) && displayTab != 0 && menuItem == 4 && channels[displayTab - 1].mode == 1) { //CV2 for RND channels[displayTab - 1].CV2Target = channels[displayTab - 1].CV2Target + change; if (channels[displayTab - 1].CV2Target > 100) { channels[displayTab - 1].CV2Target = 0; diff --git a/Software/Gravity/UI.ino b/Software/Gravity/UI.ino index 7a1e072..fb56723 100644 --- a/Software/Gravity/UI.ino +++ b/Software/Gravity/UI.ino @@ -2,6 +2,11 @@ void updateScreen() { u8g2.firstPage(); do { + byte leftOffset; + byte width; + //String textToShow; + String valueStr; + char valueChar[16]; if (displayScreen == 0) { //BPM Tab @@ -10,7 +15,8 @@ void updateScreen() { u8g2.setFont(velvetscreen); //Menu items - byte menuItemWidth = 32; + width = 32; + leftOffset = 62; if (masterClockMode == 0 && bpmModulationRange == 0) { lastMenuItem = 2; } else if (masterClockMode == 0 && bpmModulationRange != 0) { @@ -19,60 +25,60 @@ void updateScreen() { lastMenuItem = 0; } 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(leftOffset, 6, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "MODE:" ); } else { - u8g2.drawButtonUTF8(62, 6, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MODE:" ); + u8g2.drawButtonUTF8(leftOffset, 6, U8G2_BTN_BW0, width, 2, 2, "MODE:" ); } if (masterClockMode == 0) { if (menuItem == 2) { - u8g2.drawButtonUTF8(62, 16, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MOD:" ); + u8g2.drawButtonUTF8(leftOffset, 16, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "MOD:" ); } else { - u8g2.drawButtonUTF8(62, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MOD:" ); + u8g2.drawButtonUTF8(leftOffset, 16, U8G2_BTN_BW0, width, 2, 2, "MOD:" ); } if (bpmModulationRange != 0) { if (menuItem == 3) { - u8g2.drawButtonUTF8(62, 26, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "RANGE:" ); + u8g2.drawButtonUTF8(leftOffset, 26, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "RANGE:" ); } else { - u8g2.drawButtonUTF8(62, 26, U8G2_BTN_BW0, menuItemWidth, 2, 2, "RANGE:" ); + u8g2.drawButtonUTF8(leftOffset, 26, U8G2_BTN_BW0, width, 2, 2, "RANGE:" ); } } } //Values - byte valueWidth = 28; + width = 28; if (menuItem == 1 && insideTab && masterClockMode == 0) { - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "INT" ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "INT" ); } else if ((menuItem != 1 || !insideTab) && masterClockMode == 0) { - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0, valueWidth, 2, 2, "INT" ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 6, U8G2_BTN_BW0, width, 2, 2, "INT" ); } if (menuItem == 1 && insideTab && masterClockMode == 1) { - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 2, 2, "EXT" ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 2, 2, "EXT" ); } else if ((menuItem != 1 || !insideTab) && masterClockMode == 1) { - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 6, U8G2_BTN_BW0, valueWidth, 2, 2, "EXT" ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 6, U8G2_BTN_BW0, width, 2, 2, "EXT" ); } if (masterClockMode == 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(leftOffset + width + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "CV1" ); } else if (menuItem != 2 && bpmModulationRange != 0 && bpmModulationChannel == 0) { - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 3, 2, "CV1" ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 16, U8G2_BTN_BW0, width, 3, 2, "CV1" ); } 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(leftOffset + width + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "CV2" ); } else if (menuItem != 2 && bpmModulationRange != 0 && bpmModulationChannel == 1){ - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 2, 2, "CV2" ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 16, U8G2_BTN_BW0, width, 2, 2, "CV2" ); } if (menuItem == 2 && bpmModulationRange == 0) { - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "OFF" ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "OFF" ); } else if (menuItem != 2 && bpmModulationRange == 0) { - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 16, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 16, U8G2_BTN_BW0, width, 2, 2, "OFF" ); } String bpmModStr = String(bpmModulationRange * 10); char bpmModChar[3]; bpmModStr.toCharArray(bpmModChar, 3); if (menuItem == 3 && bpmModulationRange != 0) { - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 4, 2, bpmModChar ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 26, U8G2_BTN_BW0|U8G2_BTN_INV, width, 4, 2, bpmModChar ); } else if (menuItem != 3 && bpmModulationRange != 0) { - u8g2.drawButtonUTF8(62 + menuItemWidth + 4, 26, U8G2_BTN_BW0, valueWidth, 4, 2, bpmModChar ); + u8g2.drawButtonUTF8(leftOffset + width + 4, 26, U8G2_BTN_BW0, width, 4, 2, bpmModChar ); } } @@ -84,27 +90,32 @@ void updateScreen() { } char bpmChar[5]; bpmStr.toCharArray(bpmChar, 5); - u8g2.setFont(fabryka); - if (((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) && masterClockMode == 0) { - u8g2.drawButtonUTF8(28, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 5, bpmChar ); - u8g2.setFont(velvetscreen); - 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" ); - } - } else { - u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 55, 0, 2, "PPQN" ); + leftOffset = 29; + width = 55; + if (masterClockMode == 0) { + if ((!insideTab && !shiftBtnPushed) || (insideTab && menuItem != 0)) { //default view, nothing is selected or editable + u8g2.setFont(fabryka); + u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 3, bpmChar ); + u8g2.setFont(velvetscreen); + u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 2, "BPM" ); + } else if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) { //show value as editable + u8g2.setFont(fabryka); + u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW1|U8G2_BTN_HCENTER, width, 0, 3, bpmChar ); + u8g2.setFont(velvetscreen); + u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 2, "BPM" ); + } else if (insideTab && menuItem == 0 && !menuItemSelected) { //show as selected menu item + u8g2.setFont(fabryka); + u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, bpmChar ); + u8g2.setFont(velvetscreen); + u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 2, "BPM" ); } - } else { - u8g2.drawButtonUTF8(28, 26, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 56, 0, 0, bpmChar ); + } + + if (masterClockMode == 1) { + u8g2.setFont(fabryka); + u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 0, bpmChar ); u8g2.setFont(velvetscreen); - if (masterClockMode == 0) { - u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 55, 0, 2, "BPM" ); - } else { - u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 55, 0, 2, "PPQN" ); - } + u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 2, "PPQN" ); } } @@ -112,154 +123,120 @@ void updateScreen() { else { //Menu items lastMenuItem = 4; - byte menuItemWidth = 32; - if (menuItem == 1 && 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:" ); + width = 32; + leftOffset = 62; + for (byte i = 1; i <= lastMenuItem; i++) { + if (i == 1) { + valueStr = "MODE:"; + } else if (i == 2 && channels[displayTab - 1].mode == 0) { + valueStr = "OFFSET:"; + } else if (i == 2 && channels[displayTab - 1].mode == 1) { + valueStr = "SUBDIV:"; + } else if (i == 2 && channels[displayTab - 1].mode == 2) { + valueStr = "EDIT PATTERN"; + } else if (i == 3) { + valueStr = "CV1"; + } else if (i == 4) { + valueStr = "CV2"; + } + valueStr.toCharArray(valueChar, 16); + if (menuItem == i && insideTab) { + u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, width, 1, 2, valueChar ); + } else { + u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW0, width, 1, 2, valueChar); + } } - if (menuItem == 2 && 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 == 2 && 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 == 2 && 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 == 3 && 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 == 4 && 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 == 1 && insideTab && channels[displayTab - 1].mode == 0) { - u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CLOCK" ); - } else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 0) { - u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "CLOCK" ); - } 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" ); - } else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 1) { - u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "RAND" ); - } 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" ); - } else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 2) { - u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "SEQ" ); - } + for (byte i = 1; i <= lastMenuItem; i++) { + if (i == 1 && channels[displayTab - 1].mode == 0) { //Channel mode + valueStr = "CLOCK"; + } else if (i == 1 && channels[displayTab - 1].mode == 1) { + valueStr = "RAND"; + } else if (i == 1 && channels[displayTab - 1].mode == 2) { + valueStr = "SEQ"; + } else if (i == 2 && channels[displayTab - 1].mode == 0) { //SubDiv and offset + valueStr = String(channels[displayTab - 1].offset) + "/"; + valueStr = valueStr + String(channelPulsesPerCycle[displayTab-1]+1); + } else if (i == 2 && channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] > 0) { + valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]); + } else if (i == 2 && channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] < 0) { + valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv])); + } else if (i == 3 && channels[displayTab - 1].CV1Target == 0) { //CV1 + valueStr = "OFF"; + } else if (i == 3 && channels[displayTab - 1].CV1Target == 1) { + valueStr = "SUBDIV"; + } else if (i == 3 && channels[displayTab - 1].CV1Target == 2) { + valueStr = "RAND"; + } else if (i == 3 && channels[displayTab - 1].CV1Target == 3) { + valueStr = "PATT"; + } else if (i == 4 && channels[displayTab - 1].CV2Target == 0) { //CV2 + valueStr = "OFF"; + } else if (i == 4 && channels[displayTab - 1].CV2Target == 1) { + valueStr = "SUBDIV"; + } else if (i == 4 && channels[displayTab - 1].CV2Target == 2) { + valueStr = "RAND"; + } else if (i == 4 && channels[displayTab - 1].CV2Target == 3) { + valueStr = "PATT"; + } - //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 == 2 && insideTab && channels[displayTab - 1].mode != 2) { - u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, valueChar ); - } else if ((menuItem != 2 || !insideTab)) { - u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0, valueWidth, 3, 2, valueChar ); - } - - //CV1 - if (menuItem == 3 && insideTab && channels[displayTab - 1].CV1Target == 1) { - u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "SUBDIV" ); - } else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV1Target == 1) { - u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "SUBDIV" ); - } 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" ); - } else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV1Target == 2) { - u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "RAND" ); - } 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" ); - } else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV1Target == 3) { - u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "PATT" ); - } 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" ); - } else if ((menuItem != 3 || !insideTab) && channels[displayTab - 1].CV1Target == 0) { - u8g2.drawButtonUTF8(menuItemWidth+6, 26, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" ); - } - - //CV2 - if (menuItem == 4 && insideTab && channels[displayTab - 1].CV2Target == 1) { - u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "SUBDIV" ); - } else if ((menuItem != 4 || !insideTab) && channels[displayTab - 1].CV2Target == 1) { - u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "SUBDIV" ); - } 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" ); - } else if ((menuItem != 4 || !insideTab) && channels[displayTab - 1].CV2Target == 2) { - u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "RANDOM" ); - } 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" ); - } else if ((menuItem != 4 || !insideTab) && channels[displayTab - 1].CV2Target == 3) { - u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "PATTERN" ); - } 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" ); - } else if ((menuItem != 4 || !insideTab) && channels[displayTab - 1].CV2Target == 0) { - u8g2.drawButtonUTF8(menuItemWidth+6, 36, U8G2_BTN_BW0, valueWidth, 2, 2, "OFF" ); + valueStr.toCharArray(valueChar, 16); + if (i == 2 && channels[displayTab - 1].mode == 2) { //EDIT PATTERN thing + if (menuItem == i && insideTab) { + u8g2.drawBox(leftOffset + 55, ((i-1) * 11)-1, 10, 11); + } + } else { + if (menuItem == i && insideTab && (menuItemSelected || shiftBtnPushed)) { + u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1, 26, 2, 2, valueChar ); + } else if (menuItem == i && insideTab && (!menuItemSelected || !shiftBtnPushed)) { + u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, 26, 2, 2, valueChar ); + } else { + u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW0, 26, 2, 2, valueChar ); + } + } } //Main Param + leftOffset = 29; + width = 55; + if (channels[displayTab - 1].mode == 0) { + valueStr = "SUBDIVISION"; + } else if (channels[displayTab - 1].mode == 1) { + valueStr = "SKIP CHANCE"; + } else if (channels[displayTab - 1].mode == 2) { + valueStr = "PATTERN"; + } + valueStr.toCharArray(valueChar, 16); + if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) { + u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueChar ); + } else { + u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 1, 2, valueChar ); + } + if (channels[displayTab - 1].mode == 0) { if (subDivs[channels[displayTab - 1].subDiv] > 0) { valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]); } else { 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) { - valueStr = String(channels[displayTab - 1].random) + "0%"; - 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" ); - } + valueStr = String(channels[displayTab - 1].random) + "0%"; } else if (channels[displayTab - 1].mode == 2) { if (channels[displayTab - 1].seqPattern < 8) { valueStr = "A" + String(channels[displayTab - 1].seqPattern + 1); } else { 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, 16); u8g2.setFont(fabryka); - if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) { - u8g2.drawButtonUTF8(96, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 5, valueChar ); + if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) { + u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW1|U8G2_BTN_HCENTER, width, 0, 3, valueChar ); + } else if (insideTab && menuItem == 0 && !menuItemSelected) { + u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueChar ); } else { - u8g2.drawButtonUTF8(96, 26, U8G2_BTN_BW0|U8G2_BTN_HCENTER, 56, 0, 5, valueChar ); + u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 3, valueChar ); } } @@ -311,7 +288,6 @@ void updateScreen() { } char patChar[16]; patStr.toCharArray(patChar, 16); - //u8g2.drawUTF8(31, 5, patChar); u8g2.drawButtonUTF8(64, 5, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 128, 0, 2, patChar ); for (byte i = 0; i < 8; i++) { if (patternToEdit[i]) { @@ -345,21 +321,21 @@ void updateScreen() { else if (displayScreen == 2) { u8g2.drawButtonUTF8(64, 5, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 128, 0, 2, "SETTINGS" ); lastMenuItem = 2; - byte menuItemWidth = 112; + byte width = 112; if (menuItem == 0) { - u8g2.drawButtonUTF8(8, 18, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "CALIBRATE CV INS" ); + u8g2.drawButtonUTF8(8, 18, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "CALIBRATE CV INS" ); } else { - u8g2.drawButtonUTF8(8, 18, U8G2_BTN_BW0, menuItemWidth, 2, 2, "CALIBRATE CV INS" ); + u8g2.drawButtonUTF8(8, 18, U8G2_BTN_BW0, width, 2, 2, "CALIBRATE CV INS" ); } if (menuItem == 1) { - u8g2.drawButtonUTF8(8, 32, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "ROTATE SCREEN" ); + u8g2.drawButtonUTF8(8, 32, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "ROTATE SCREEN" ); } else { - u8g2.drawButtonUTF8(8, 32, U8G2_BTN_BW0, menuItemWidth, 2, 2, "ROTATE SCREEN" ); + u8g2.drawButtonUTF8(8, 32, U8G2_BTN_BW0, width, 2, 2, "ROTATE SCREEN" ); } if (menuItem == 2) { - u8g2.drawButtonUTF8(8, 46, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "FACTORY RESET" ); + u8g2.drawButtonUTF8(8, 46, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "FACTORY RESET" ); } else { - u8g2.drawButtonUTF8(8, 46, U8G2_BTN_BW0, menuItemWidth, 2, 2, "FACTORY RESET" ); + u8g2.drawButtonUTF8(8, 46, U8G2_BTN_BW0, width, 2, 2, "FACTORY RESET" ); } }