From a40f7ec67d55b492433a61c3e3330b93229a679d Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Wed, 2 Aug 2023 23:29:44 +0300 Subject: [PATCH] Added sequence recorder --- Software/Gravity/Gravity.ino | 1 + Software/Gravity/Interactions.ino | 16 +++++++++++----- Software/Gravity/UI.ino | 17 +++++++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index 626e2e7..41e2496 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -81,6 +81,7 @@ int playingModes[6]; //actual channel modes array updated from channels object unsigned int pulsePeriod; bool isPlaying = false; +bool isRecording = false; unsigned int tickCount = 0; unsigned int pulseCount = 0; diff --git a/Software/Gravity/Interactions.ino b/Software/Gravity/Interactions.ino index e0cbc3f..30fb16b 100644 --- a/Software/Gravity/Interactions.ino +++ b/Software/Gravity/Interactions.ino @@ -9,9 +9,9 @@ void checkInputs() { encReleasedTime = millis(); if (encReleasedTime - encPressedTime < 500) { // press shorter than .5s is for entering the submenu - if (!insideTab) { - insideTab = 1; - } else if (insideTab && channels[displayTab - 1].mode == 2 && menuItem == 1) { //enter the pattern editor + if (!insideTab && displayScreen == 0) { + insideTab = true; + } else if (insideTab && channels[displayTab - 1].mode == 2 && menuItem == 1 && displayScreen == 0) { //enter the pattern editor if (channels[displayTab - 1].seqPattern == 0) { patternToEdit = seqA1; } else if (channels[displayTab - 1].seqPattern == 1) { @@ -46,6 +46,9 @@ void checkInputs() { patternToEdit = seqB8; } displayScreen = 1; + isRecording = 0; + } else if (displayScreen == 1) { + isRecording = !isRecording; } updateScreen(); } else if (encReleasedTime - encPressedTime < 2000) { // longer press (<2s) is for navigating back. longer than 2s presses are ignored @@ -54,6 +57,7 @@ void checkInputs() { } else if (insideTab == 1) { insideTab = 0; menuItem = 0; + isRecording = 0; } updateScreen(); } @@ -207,7 +211,7 @@ void checkInputs() { } saveState(); } - } else if (displayScreen == 1) { + } else if (displayScreen == 1 && !isRecording) { stepNumSelected = stepNumSelected + change; if (stepNumSelected > 100) { stepNumSelected = 15; @@ -236,9 +240,11 @@ void checkInputs() { //shift button if (!digitalRead(SHIFT_BTN_PIN) && !shiftBtnPushed) { shiftBtnPushed = true; - if (displayScreen == 1) { + if (displayScreen == 1 && !isRecording) { patternToEdit[stepNumSelected] = !patternToEdit[stepNumSelected]; saveState(); + } else if (displayScreen == 1 && isRecording) { + patternToEdit[currentStep] = 1; } updateScreen(); } else if (digitalRead(SHIFT_BTN_PIN) && shiftBtnPushed) { diff --git a/Software/Gravity/UI.ino b/Software/Gravity/UI.ino index 69b1d7b..cc07e0b 100644 --- a/Software/Gravity/UI.ino +++ b/Software/Gravity/UI.ino @@ -271,10 +271,9 @@ void updateScreen() { u8g2.drawUTF8(122, yPos, "r"); } } - //Edit Pattern + //Edit Pattern Screen else if (displayScreen == 1) { - //patternToEdit = seqA4; for (byte i = 0; i < 8; i++) { if (patternToEdit[i]) { u8g2.drawUTF8(19 + i*12, 20, "q"); @@ -289,10 +288,16 @@ void updateScreen() { u8g2.drawUTF8(19 + (i-8)*12, 40, "p"); } } - if (stepNumSelected < 8 ) { - u8g2.drawFrame(16 + stepNumSelected * 12, 12, 11, 11); - } else { - u8g2.drawFrame(16 + (stepNumSelected-8) * 12, 32, 11, 11); + if (!isRecording) { + if (stepNumSelected < 8 ) { + u8g2.drawFrame(16 + stepNumSelected * 12, 12, 11, 11); + } else { + u8g2.drawFrame(16 + (stepNumSelected-8) * 12, 32, 11, 11); + } + } + + if (isRecording) { + u8g2.drawUTF8(44, 60, "RECORDING"); } }