reworked the menu

This commit is contained in:
2023-08-12 23:58:27 +03:00
parent 9d4142b46b
commit adc80bd626
4 changed files with 178 additions and 183 deletions

View File

@ -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";;;
Can't render this file because it has a wrong number of fields in line 2.

View File

@ -1,7 +1,7 @@
{ {
"board": { "board": {
"active_layer": 31, "active_layer": 31,
"active_layer_preset": "Back Assembly View", "active_layer_preset": "",
"auto_track_width": false, "auto_track_width": false,
"hidden_nets": [], "hidden_nets": [],
"high_contrast_mode": 0, "high_contrast_mode": 0,
@ -62,7 +62,7 @@
35, 35,
36 36
], ],
"visible_layers": "0015050_00000000", "visible_layers": "0015050_80000001",
"zone_display_mode": 0 "zone_display_mode": 0
}, },
"meta": { "meta": {

View File

@ -71,6 +71,7 @@ void checkInputs() {
insideTab = 0; insideTab = 0;
menuItem = 0; menuItem = 0;
isRecording = 0; isRecording = 0;
menuItemSelected = 0;
} }
} else if (encReleasedTime - encPressedTime > 2000 && shiftBtnPushed) { //2s+ combo with shift to open the settings } else if (encReleasedTime - encPressedTime > 2000 && shiftBtnPushed) { //2s+ combo with shift to open the settings
displayScreen = 2; displayScreen = 2;
@ -162,7 +163,7 @@ void checkInputs() {
masterClockMode = 1; masterClockMode = 1;
} }
saveState(); 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; bpmModulationChannel = bpmModulationChannel + change;
if (bpmModulationChannel == 0 || bpmModulationChannel == 1) { if (bpmModulationChannel == 0 || bpmModulationChannel == 1) {
bpmModulationRange = 1; bpmModulationRange = 1;
@ -173,7 +174,7 @@ void checkInputs() {
bpmModulationChannel = 1; bpmModulationChannel = 1;
} }
saveState(); 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; bpmModulationRange = bpmModulationRange + change;
if (bpmModulationRange == 0) { if (bpmModulationRange == 0) {
bpmModulationRange = 1; bpmModulationRange = 1;
@ -183,7 +184,7 @@ void checkInputs() {
bpmModulationRange = 5; bpmModulationRange = 5;
} }
saveState(); 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; 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;
@ -193,7 +194,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 == 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; 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;
@ -201,7 +202,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 == 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; 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;
@ -212,7 +213,7 @@ void checkInputs() {
calculateCycles(); calculateCycles();
} }
saveState(); 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; 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 +222,7 @@ void checkInputs() {
} }
saveState(); 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; 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;
@ -229,7 +230,7 @@ void checkInputs() {
channels[displayTab - 1].CV2Target = 1; channels[displayTab - 1].CV2Target = 1;
} }
saveState(); 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; 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;
@ -238,7 +239,7 @@ void checkInputs() {
} }
saveState(); 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; 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

@ -2,6 +2,11 @@ void updateScreen() {
u8g2.firstPage(); u8g2.firstPage();
do { do {
byte leftOffset;
byte width;
//String textToShow;
String valueStr;
char valueChar[16];
if (displayScreen == 0) { if (displayScreen == 0) {
//BPM Tab //BPM Tab
@ -10,7 +15,8 @@ void updateScreen() {
u8g2.setFont(velvetscreen); u8g2.setFont(velvetscreen);
//Menu items //Menu items
byte menuItemWidth = 32; width = 32;
leftOffset = 62;
if (masterClockMode == 0 && bpmModulationRange == 0) { if (masterClockMode == 0 && bpmModulationRange == 0) {
lastMenuItem = 2; lastMenuItem = 2;
} else if (masterClockMode == 0 && bpmModulationRange != 0) { } else if (masterClockMode == 0 && bpmModulationRange != 0) {
@ -19,60 +25,60 @@ void updateScreen() {
lastMenuItem = 0; lastMenuItem = 0;
} }
if ((menuItem == 1 && insideTab) || (insideTab && masterClockMode == 1 && menuItem == 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 { } 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 (masterClockMode == 0) {
if (menuItem == 2) { 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 { } 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 (bpmModulationRange != 0) {
if (menuItem == 3) { 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 { } else {
u8g2.drawButtonUTF8(62, 26, U8G2_BTN_BW0, menuItemWidth, 2, 2, "RANGE:" ); u8g2.drawButtonUTF8(leftOffset, 26, U8G2_BTN_BW0, width, 2, 2, "RANGE:" );
} }
} }
} }
//Values //Values
byte valueWidth = 28; width = 28;
if (menuItem == 1 && 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(leftOffset + width + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "INT" );
} else if ((menuItem != 1 || !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(leftOffset + width + 4, 6, U8G2_BTN_BW0, width, 2, 2, "INT" );
} }
if (menuItem == 1 && 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(leftOffset + width + 4, 6, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 2, 2, "EXT" );
} else if ((menuItem != 1 || !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(leftOffset + width + 4, 6, U8G2_BTN_BW0, width, 2, 2, "EXT" );
} }
if (masterClockMode == 0) { if (masterClockMode == 0) {
if (menuItem == 2 && 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(leftOffset + width + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "CV1" );
} else if (menuItem != 2 && 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(leftOffset + width + 4, 16, U8G2_BTN_BW0, width, 3, 2, "CV1" );
} }
if (menuItem == 2 && 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(leftOffset + width + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "CV2" );
} else if (menuItem != 2 && 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(leftOffset + width + 4, 16, U8G2_BTN_BW0, width, 2, 2, "CV2" );
} }
if (menuItem == 2 && 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(leftOffset + width + 4, 16, U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 2, "OFF" );
} else if (menuItem != 2 && bpmModulationRange == 0) { } 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); String bpmModStr = String(bpmModulationRange * 10);
char bpmModChar[3]; char bpmModChar[3];
bpmModStr.toCharArray(bpmModChar, 3); bpmModStr.toCharArray(bpmModChar, 3);
if (menuItem == 3 && 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(leftOffset + width + 4, 26, U8G2_BTN_BW0|U8G2_BTN_INV, width, 4, 2, bpmModChar );
} else if (menuItem != 3 && bpmModulationRange != 0) { } 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]; char bpmChar[5];
bpmStr.toCharArray(bpmChar, 5); bpmStr.toCharArray(bpmChar, 5);
u8g2.setFont(fabryka); leftOffset = 29;
if (((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) && masterClockMode == 0) { width = 55;
u8g2.drawButtonUTF8(28, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 5, bpmChar ); if (masterClockMode == 0) {
u8g2.setFont(velvetscreen); if ((!insideTab && !shiftBtnPushed) || (insideTab && menuItem != 0)) { //default view, nothing is selected or editable
if (masterClockMode == 0) { u8g2.setFont(fabryka);
if (insideTab && menuItem == 0 && !menuItemSelected && !shiftBtnPushed) { u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 3, bpmChar );
u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 55, 0, 2, "BPM" ); u8g2.setFont(velvetscreen);
} else { u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 2, "BPM" );
u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 55, 0, 2, "BPM" ); } else if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) { //show value as editable
} u8g2.setFont(fabryka);
} else { u8g2.drawButtonUTF8(leftOffset-1, 28, U8G2_BTN_BW1|U8G2_BTN_HCENTER, width, 0, 3, bpmChar );
u8g2.drawButtonUTF8(29, 40, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 55, 0, 2, "PPQN" ); 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); u8g2.setFont(velvetscreen);
if (masterClockMode == 0) { u8g2.drawButtonUTF8(leftOffset, 40, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 2, "PPQN" );
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" );
}
} }
} }
@ -112,154 +123,120 @@ void updateScreen() {
else { else {
//Menu items //Menu items
lastMenuItem = 4; lastMenuItem = 4;
byte menuItemWidth = 32; width = 32;
if (menuItem == 1 && insideTab) { leftOffset = 62;
u8g2.drawButtonUTF8(2, 6, U8G2_BTN_BW0|U8G2_BTN_INV, menuItemWidth, 2, 2, "MODE:" ); for (byte i = 1; i <= lastMenuItem; i++) {
} else { if (i == 1) {
u8g2.drawButtonUTF8(2, 6, U8G2_BTN_BW0, menuItemWidth, 2, 2, "MODE:" ); 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 //Values
byte valueWidth = 28; for (byte i = 1; i <= lastMenuItem; i++) {
if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 0) { if (i == 1 && channels[displayTab - 1].mode == 0) { //Channel mode
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "CLOCK" ); valueStr = "CLOCK";
} else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 0) { } else if (i == 1 && channels[displayTab - 1].mode == 1) {
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "CLOCK" ); valueStr = "RAND";
} else if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 1) { } else if (i == 1 && channels[displayTab - 1].mode == 2) {
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "RAND" ); valueStr = "SEQ";
} else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 1) { } else if (i == 2 && channels[displayTab - 1].mode == 0) { //SubDiv and offset
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "RAND" ); valueStr = String(channels[displayTab - 1].offset) + "/";
} else if (menuItem == 1 && insideTab && channels[displayTab - 1].mode == 2) { valueStr = valueStr + String(channelPulsesPerCycle[displayTab-1]+1);
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, "SEQ" ); } else if (i == 2 && channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] > 0) {
} else if ((menuItem != 1 || !insideTab) && channels[displayTab - 1].mode == 2) { valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]);
u8g2.drawButtonUTF8(menuItemWidth+6, 6, U8G2_BTN_BW0, valueWidth, 3, 2, "SEQ" ); } 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 valueStr.toCharArray(valueChar, 16);
if (channels[displayTab - 1].mode == 0) { if (i == 2 && channels[displayTab - 1].mode == 2) { //EDIT PATTERN thing
valueStr = String(channels[displayTab - 1].offset) + "/"; if (menuItem == i && insideTab) {
valueStr = valueStr + String(channelPulsesPerCycle[displayTab-1]+1); u8g2.drawBox(leftOffset + 55, ((i-1) * 11)-1, 10, 11);
} else if (channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] > 0) { }
valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]); } else {
} else if (channels[displayTab - 1].mode == 1 && subDivs[channels[displayTab - 1].subDiv] < 0) { if (menuItem == i && insideTab && (menuItemSelected || shiftBtnPushed)) {
valueStr = "x" + String(abs(subDivs[channels[displayTab - 1].subDiv])); u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1, 26, 2, 2, valueChar );
} } else if (menuItem == i && insideTab && (!menuItemSelected || !shiftBtnPushed)) {
valueStr.toCharArray(valueChar, 8); u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, 26, 2, 2, valueChar );
if (menuItem == 2 && insideTab && channels[displayTab - 1].mode != 2) { } else {
u8g2.drawButtonUTF8(menuItemWidth+6, 16, U8G2_BTN_BW0|U8G2_BTN_INV, valueWidth, 2, 2, valueChar ); u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW0, 26, 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" );
} }
//Main Param //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 (channels[displayTab - 1].mode == 0) {
if (subDivs[channels[displayTab - 1].subDiv] > 0) { if (subDivs[channels[displayTab - 1].subDiv] > 0) {
valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]); valueStr = "/" + String(subDivs[channels[displayTab - 1].subDiv]);
} else { } 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%";
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) { } else if (channels[displayTab - 1].mode == 2) {
if (channels[displayTab - 1].seqPattern < 8) { if (channels[displayTab - 1].seqPattern < 8) {
valueStr = "A" + String(channels[displayTab - 1].seqPattern + 1); valueStr = "A" + String(channels[displayTab - 1].seqPattern + 1);
} else { } 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, 16);
u8g2.setFont(fabryka); u8g2.setFont(fabryka);
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) { if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) {
u8g2.drawButtonUTF8(96, 26, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, 56, 0, 5, valueChar ); 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 { } 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]; char patChar[16];
patStr.toCharArray(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 ); u8g2.drawButtonUTF8(64, 5, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 128, 0, 2, patChar );
for (byte i = 0; i < 8; i++) { for (byte i = 0; i < 8; i++) {
if (patternToEdit[i]) { if (patternToEdit[i]) {
@ -345,21 +321,21 @@ void updateScreen() {
else if (displayScreen == 2) { else if (displayScreen == 2) {
u8g2.drawButtonUTF8(64, 5, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 128, 0, 2, "SETTINGS" ); u8g2.drawButtonUTF8(64, 5, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 128, 0, 2, "SETTINGS" );
lastMenuItem = 2; lastMenuItem = 2;
byte menuItemWidth = 112; byte width = 112;
if (menuItem == 0) { 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 { } 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) { 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 { } 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) { 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 { } 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" );
} }
} }