From cdb4cb58a215509388b315aa3a73d485001b5720 Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Sat, 5 Aug 2023 00:40:44 +0300 Subject: [PATCH] Added empty (for now) settings screen --- Software/Gravity/Gravity.ino | 6 +++--- Software/Gravity/Interactions.ino | 20 ++++++++++++++------ Software/Gravity/UI.ino | 16 ++++++++++++---- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index 7a325e5..0f92e83 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -25,8 +25,8 @@ #define ANALOGUE_INPUT_2_PIN A6 const byte outsPins[6] = { 7, 8, 10, 6, 9, 11 }; -int CV1Calibration; -int CV2Calibration; +int CV1Calibration = 0; +int CV2Calibration = 0; const int subDivs[17] = { -24, -12, -8, -6, -4, -3, -2, 1, 2, 3, 4, 5, 6, 7, 8, 16, 32 }; //positive - divide, negative - multiply, 0 - off @@ -115,7 +115,7 @@ unsigned long playPressedTime; unsigned long playReleasedTime; unsigned long shiftPressedTime; unsigned long shiftReleasedTime; -bool encPressRegistered; +bool encBtnPushed; //unsigned long lastInteractionTime; // used for display timeout diff --git a/Software/Gravity/Interactions.ino b/Software/Gravity/Interactions.ino index d3d7206..221772b 100644 --- a/Software/Gravity/Interactions.ino +++ b/Software/Gravity/Interactions.ino @@ -1,11 +1,11 @@ void checkInputs() { //encoder button - if (!digitalRead(ENC_BTN_PIN) && !encPressRegistered) { - encPressRegistered = true; + if (!digitalRead(ENC_BTN_PIN) && !encBtnPushed) { + encBtnPushed = true; encPressedTime = millis(); - } else if (digitalRead(ENC_BTN_PIN) && encPressRegistered) { - encPressRegistered = false; + } else if (digitalRead(ENC_BTN_PIN) && encBtnPushed) { + encBtnPushed = false; encReleasedTime = millis(); if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s is for entering the submenu @@ -47,8 +47,11 @@ void checkInputs() { } displayScreen = 1; isRecording = 0; - } else if (displayScreen == 1) { - isRecording = !isRecording; + } else if (displayScreen == 1 && !isRecording) { + isPlaying = 1; + isRecording = 1; + } else if (displayScreen == 1 && isRecording) { + isRecording = 0; } updateScreen(); } else if (encReleasedTime - encPressedTime < 2000) { // longer press (<2s) is for navigating back. longer than 2s presses are ignored @@ -60,6 +63,9 @@ void checkInputs() { isRecording = 0; } updateScreen(); + } else if (encReleasedTime - encPressedTime > 2000 && shiftBtnPushed) { + displayScreen = 2; + updateScreen(); } } @@ -264,6 +270,8 @@ void checkInputs() { for (byte i = 0; i < 16; i++) { patternToEdit[i] = 0; } + } else if (shiftReleasedTime - shiftPressedTime > 2000 && encBtnPushed) { + displayScreen = 2; } saveState(); updateScreen(); diff --git a/Software/Gravity/UI.ino b/Software/Gravity/UI.ino index 8d8c7e5..77f6984 100644 --- a/Software/Gravity/UI.ino +++ b/Software/Gravity/UI.ino @@ -270,7 +270,8 @@ void updateScreen() { } else { u8g2.drawUTF8(122, yPos, "r"); } - } + } + //Edit Pattern Screen else if (displayScreen == 1) { byte pattern = channels[displayTab - 1].seqPattern; @@ -282,7 +283,8 @@ void updateScreen() { } char patChar[16]; patStr.toCharArray(patChar, 16); - u8g2.drawUTF8(31, 5, patChar); + //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]) { u8g2.drawUTF8(19 + i*12, 24, "q"); @@ -306,9 +308,15 @@ void updateScreen() { } if (isRecording) { - u8g2.drawUTF8(43, 60, "RECORDING"); + //u8g2.drawUTF8(43, 60, "RECORDING"); + u8g2.drawButtonUTF8(64, 62, U8G2_BTN_BW1|U8G2_BTN_HCENTER|U8G2_BTN_INV, 50, 0, 2, "RECORDING" ); } - } + + //Settings Screen + else if (displayScreen == 2) { + u8g2.drawButtonUTF8(64, 5, U8G2_BTN_BW1|U8G2_BTN_HCENTER, 128, 0, 2, "SETTINGS" ); + } + } while ( u8g2.nextPage() ); } \ No newline at end of file