diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index aab6e25..f1ece77 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -1,6 +1,4 @@ #include -//#include -//#include #include #include #include @@ -16,17 +14,6 @@ #define MINBPM 20 #define SCREEN_TIMEOUT 600000 //Turn display off after 5 min -/* Rev 1 Config -#define ENC_BTN_PIN 14 -#define ENC_D1_PIN 17 -#define ENC_D2_PIN 4 -#define START_STOP_BTN_PIN 5 -#define EXT_INPUT_PIN 2 //needs to be an interrupt pin -#define ANALOGUE_INPUT_1_PIN A2 -#define ANALOGUE_INPUT_2_PIN A1 -const int outsPins[6] = {6, 11, 7, 10, 8, 9}; -*/ - // Rev 2 and 3 Config #define ENC_BTN_PIN 14 #define ENC_D1_PIN 17 @@ -127,26 +114,20 @@ bool encPressRegistered; U8G2_SSD1306_128X64_NONAME_2_HW_I2C u8g2(U8G2_R2, SCL, SDA, U8X8_PIN_NONE); RotaryEncoder encoder(ENC_D1_PIN, ENC_D2_PIN, RotaryEncoder::LatchMode::TWO03); -const uint8_t velvetscreen[597] U8G2_FONT_SECTION("velvetscreen") = - "I\0\2\2\3\3\3\3\4\5\5\0\0\5\0\5\0\0\363\0\0\2\70!\6)\251\254\0\42\6\23" - "\317$\25#\12-\351UC\345\241*\0$\11,\331\215\24e\32\11%\12-\351\250\244r\245\222\0" - "&\11-\351\351*\311\250\2'\5\21\257\10(\6*\271\251\62)\10*\271\304\224\24\0*\11-\351" - "V\325jF\0+\7\33\313\245\225\0,\5\21\251\10-\5\13\315\14.\5\11\251\4/\7$\331\307" - "\66\0\60\10,\331\251h&\5\61\7+\311\310\326\0\62\11,\331l\224T\36\1\63\11,\331l\224" - "\64\32\11\64\10,\331D\71t\1\65\11,\331\14\275\321H\0\66\11,\331\251\274bR\0\67\10," - "\331\214\34\353\10\70\11,\331\251\230TL\12\71\11,\331\251\230vR\0:\6\31\253\244\0;\6!" - "\251$\1<\7+\311\246\272\0=\6\33\313\354\1>\7+\311\344\252\4\77\11,\331l\224\64\216\0" - "@\12-\351\255J\215\14\27\0A\10,\331\251\70\246\14B\11,\331\254\70R\34\2C\11,\331\251" - "\250cR\0D\10,\331\254h\216\4E\10,\331\14=\364\10F\10,\331\14\275r\6G\10,\331" - "\215\234f\32H\10,\331D\71\246\14I\6)\251\14\1J\10,\331\327\62)\0K\11,\331D\225" - "d*\3L\7,\331\344\366\10M\11-\351\344\265\222\326\1N\11-\351\344\251\222\334\1O\10,\331" - "\251h&\5P\11,\331\254\70R\316\0Q\10,\331\251h\305\24R\10,\331\254\70R\63S\11," - "\331\215\214\64\32\11T\7+\311\254\330\2U\10,\331DgR\0V\12-\351d\235\312\224#\0W" - "\12-\351d\225TR]\0X\11,\331D\231T\224\1Y\12-\351\344Tg\224Q\4Z\7+\311" - "\314T\16[\6*\271\254J\134\11$\331d\224QF\1]\6*\271\250j^\5\23\317\65_\6\14" - "\331\214\0o\7[\333\214\64\2p\11-\351-\265\227Z\0q\7-\351\35_\13r\10+\311D\65" - "T\4s\7-\351\334\366\30t\7-\351\374G\0u\10-\351\334*\351\61v\5\211\335\4w\12-" - "\351\255J\215\234\26\0x\6\33\311\244\16\0\0\0\4\377\377\0"; +const uint8_t velvetscreen[416] U8G2_FONT_SECTION("velvetscreen") = + "\62\0\2\2\3\3\1\3\4\5\5\0\0\5\0\5\0\0\216\0\0\1\203 \4@:%\11m:*" + "\251\134\251$(\6jn\252\14)\7j.\61%\5+\7\333ri%\0,\5Q*\2-\5K" + "\63\3.\5I*\1/\6d\366\261\15\60\10lv*\232I\1\61\6k\62\262\65\62\11l\66\33" + "%\225G\0\63\11l\66\33%\215F\2\64\7l\66Q\16]\65\11l\66Co\64\22\0\66\11l" + "v*\257\230\24\0\67\10l\66#\307:\2\70\11lv*&\25\223\2\71\11lv*\246\235\24\0" + ":\5\331*)A\10lv*\216)\3B\11l\66+\216\24\207\0C\11lv*\352\230\24\0D" + "\10l\66+\232#\1E\10l\66C\17=\2F\10l\66C\257\234\1G\10lv#\247\231\6H" + "\10l\66Q\216)\3I\5i*CJ\7l\366\265L\12K\11l\66Q%\231\312\0L\7l\66" + "\271=\2M\11m:y\255\244u\0N\11m:y\252$w\0O\10lv*\232I\1P\11l" + "\66+\216\224\63\0Q\10lv*Z\61\5R\10l\66+\216\324\14S\11lv##\215F\2T" + "\7k\62+\266\0U\10l\66\321\231\24\0V\11m:Y\247\62\345\10W\12m:Y%\225T\27" + "\0X\11l\66Q&\25e\0Y\12m:\71\325\31e\24\1Z\7k\62\63\225\3r\10k\62Q" + "\15\25\1t\6m:\377\21w\11mz\253R#\247\5x\6[\62\251\3\0\0\0\4\377\377\0"; void setup() { diff --git a/Software/Gravity/InputsCheck.ino b/Software/Gravity/Interactions.ino similarity index 100% rename from Software/Gravity/InputsCheck.ino rename to Software/Gravity/Interactions.ino diff --git a/Software/Gravity/UI.ino b/Software/Gravity/UI.ino index f5b9b17..3fbfdfa 100644 --- a/Software/Gravity/UI.ino +++ b/Software/Gravity/UI.ino @@ -2,372 +2,262 @@ void updateScreen() { u8g2.firstPage(); do { - - //BPM Tab - if (displayTab == 0) { //BPM - u8g2.setFont(velvetscreen); + if (displayScreen == 0) { + //BPM Tab + if (displayTab == 0) { //BPM - //Menu items - 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(59, 6, U8G2_BTN_BW0|U8G2_BTN_INV, 20, 3, 2, "MODE:" ); - } else { - u8g2.drawButtonUTF8(59, 6, U8G2_BTN_BW0, 20, 3, 2, "MODE:" ); - } - if (masterClockMode == 0) { - if (menuItem == 1) { - u8g2.drawButtonUTF8(59, 16, U8G2_BTN_BW0|U8G2_BTN_INV, 20, 3, 2, "MODUL:" ); - } else { - u8g2.drawButtonUTF8(59, 16, U8G2_BTN_BW0, 20, 3, 2, "MODUL:" ); - } - if (bpmModulationRange != 0) { - if (menuItem == 2) { - u8g2.drawButtonUTF8(59, 26, U8G2_BTN_BW0|U8G2_BTN_INV, 20, 3, 2, "RANGE:" ); + 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(59, 26, U8G2_BTN_BW0, 20, 3, 2, "RANGE:" ); + 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); } } - } - //Values - if (menuItem == 0 && insideTab && masterClockMode == 0) { - u8g2.drawButtonUTF8(91, 6, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 4, 2, "INT" ); - } else if ((menuItem != 0 || !insideTab) && masterClockMode == 0) { - u8g2.drawButtonUTF8(91, 6, U8G2_BTN_BW0, 30, 4, 2, "INT" ); - } - if (menuItem == 0 && masterClockMode == 1) { - u8g2.drawButtonUTF8(91, 6, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 4, 2, "EXT" ); - } else if (menuItem != 0 && masterClockMode == 1) { - u8g2.drawButtonUTF8(91, 6, U8G2_BTN_BW0, 30, 4, 2, "EXT" ); - } - if (masterClockMode == 0) { - if (menuItem == 1 && bpmModulationRange != 0 && bpmModulationChannel == 0) { - u8g2.drawButtonUTF8(91, 16, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 4, 2, "CV1" ); - } else if (menuItem != 1 && bpmModulationRange != 0 && bpmModulationChannel == 0) { - u8g2.drawButtonUTF8(91, 16, U8G2_BTN_BW0, 30, 3, 2, "CV1" ); - } - if (menuItem == 1 && bpmModulationRange != 0 && bpmModulationChannel == 1) { - u8g2.drawButtonUTF8(91, 16, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 4, 2, "CV2" ); - } else if (menuItem != 1 && bpmModulationRange != 0 && bpmModulationChannel == 1){ - u8g2.drawButtonUTF8(91, 16, U8G2_BTN_BW0, 30, 3, 2, "CV2" ); - } - if (menuItem == 1 && bpmModulationRange == 0) { - u8g2.drawButtonUTF8(91, 16, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 4, 2, "OFF" ); - } else if (menuItem != 1 && bpmModulationRange == 0) { - u8g2.drawButtonUTF8(91, 16, U8G2_BTN_BW0, 30, 4, 2, "OFF" ); - } - String bpmModStr = String(bpmModulationRange * 10); - char bpmModChar[3]; - bpmModStr.toCharArray(bpmModChar, 3); - if (menuItem == 2 && bpmModulationRange != 0) { - u8g2.drawButtonUTF8(91, 26, U8G2_BTN_BW0|U8G2_BTN_INV, 30, 4, 2, bpmModChar ); - } else if (menuItem != 2 && bpmModulationRange != 0) { - u8g2.drawButtonUTF8(91, 26, U8G2_BTN_BW0, 30, 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" ); - } else if ((menuItem != 1 || insideTab) && channels[displayTab - 1].mode == 2) { - u8g2.drawButtonUTF8(2, 16, U8G2_BTN_BW0, menuItemWidth, 2, 2, "EDIT" ); - } - 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" ); - } - - //Main Param - 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) { - 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 ); - } - - 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 ); - } - - } - /* - } else { //CHANNELS - lastMenuItem = 3; - if (menuItem == 0 && insideTab) { - display.setTextColor(SSD1306_BLACK); - } else { - display.setTextColor(SSD1306_WHITE); - } - display.setCursor(62, 1); - display.println(F("MODE:")); - if (menuItem == 1) { - display.setTextColor(SSD1306_BLACK); - } else { - display.setTextColor(SSD1306_WHITE); - } - display.setCursor(62, 13); - if (channels[displayTab - 1].mode == 0) { - display.println(F("OFT:")); - } else if (channels[displayTab - 1].mode == 1) { - display.println(F("RND:")); - } else if (channels[displayTab - 1].mode == 2) { - display.println(F("PAT:")); - } - if (menuItem == 2) { - display.setTextColor(SSD1306_BLACK); - } else { - display.setTextColor(SSD1306_WHITE); - } - display.setCursor(62, 25); - display.println(F("CV1:")); - if (menuItem == 3) { - display.setTextColor(SSD1306_BLACK); - } else { - display.setTextColor(SSD1306_WHITE); - } - display.setCursor(62, 37); - display.println(F("CV2:")); - }*/ - - /*else { //CHANNELS - if (menuItem == 0 && insideTab) { - display.setTextColor(SSD1306_BLACK); - } else { - display.setTextColor(SSD1306_WHITE); - } - display.setCursor(94, 1); - if (channels[displayTab - 1].mode == 0) { - display.print(F("CLK")); - } else if (channels[displayTab - 1].mode == 1) { - display.print(F("RND")); - } else if (channels[displayTab - 1].mode == 2) { - display.print(F("SEQ")); - } - if (menuItem == 1) { - display.setTextColor(SSD1306_BLACK); - } else { - display.setTextColor(SSD1306_WHITE); - } - display.setCursor(94, 13); - if (channels[displayTab - 1].mode == 0) { //OFFSET - display.print(channels[displayTab - 1].offset); - display.print(F("/")); - display.print(channelPulsesPerCycle[displayTab-1]+1); - display.print(F(" ")); - } else if (channels[displayTab - 1].mode == 1) { //RANDOM - display.print(channels[displayTab - 1].random); - display.print(F("0% ")); - } else if (channels[displayTab - 1].mode == 2) { //SEQ - display.print(channels[displayTab - 1].seqPattern + 1); - } - if (menuItem == 2) { - display.setTextColor(SSD1306_BLACK); - } else { - display.setTextColor(SSD1306_WHITE); - } - display.setCursor(94, 25); - if (channels[displayTab - 1].CV1Target == 1) { - display.print(F("DIV")); - //display.print(channels[displayTab - 1].CV1Value); - } else if (channels[displayTab - 1].CV1Target == 2) { - display.print(F("RND")); - //display.print(channels[displayTab - 1].CV1Value); - } else if (channels[displayTab - 1].CV1Target == 3) { - display.print(F("PAT")); - //display.print(channels[displayTab - 1].CV1Value); - } else { - display.print(F("OFF ")); - } - if (menuItem == 3) { - display.setTextColor(SSD1306_BLACK); - } else { - display.setTextColor(SSD1306_WHITE); - } - display.setCursor(94, 37); - if (channels[displayTab - 1].CV2Target == 1) { - display.print(F("DIV")); - //display.print(channels[displayTab - 1].CV2Value); - } else if (channels[displayTab - 1].CV2Target == 2) { - display.print(F("RND")); - //display.print(channels[displayTab - 1].CV2Value); - } else if (channels[displayTab - 1].CV2Target == 3) { - display.print(F("PAT")); - //display.print(channels[displayTab - 1].CV2Value); - } else { - display.print(F("OFF ")); - } - } - - //Content - display.setCursor(2, 2); - display.setTextSize(3); - if (!insideTab && shiftBtnPushed){ - display.fillRoundRect(0, 0, 58, 42, 5, SSD1306_WHITE); - display.setTextColor(SSD1306_BLACK); - } else { - display.setTextColor(SSD1306_WHITE); - } - if (displayTab == 0 && masterClockMode == 0) { - if (bpm < 100) { - display.print(" "); - } - display.println(bpm); - display.setCursor(19, 26); - display.setTextSize(2); - display.println(F("BPM")); - } else if (displayTab == 0 && masterClockMode == 1) { - display.println(F(" 24")); - display.setCursor(8, 26); - display.setTextSize(2); - display.println(F("PPQN")); - } else if (displayTab == 0 && masterClockMode == 2) { - display.setCursor(8, 8); - display.setTextSize(2); - display.println(F("BEAT")); - } else if (displayTab == 0 && masterClockMode == 3) { - display.setCursor(8, 8); - display.setTextSize(2); - display.println(F("1/16")); - } else { - if (subDivs[channels[displayTab - 1].subDiv] == 0) { - display.print(F("OFF")); - } else if (subDivs[channels[displayTab - 1].subDiv] > 0) { - display.print(F("/")); - display.print(abs(subDivs[channels[displayTab - 1].subDiv])); - } else { - display.print(F("x")); - display.print(abs(subDivs[channels[displayTab - 1].subDiv])); - } - } - */ - - //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); + if (!isPlaying) { + u8g2.drawUTF8(121, yPos, "t"); } else { - u8g2.drawButtonUTF8(i*xWidth + xWidth/2, yPos, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, xWidth-2, 0, 2, tabNameChar); + u8g2.drawUTF8(122, yPos, "r"); } - } 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() ); } \ No newline at end of file