From d8398eb986c079a2b0e56014e79679f9c71e0110 Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Thu, 3 Aug 2023 21:02:19 +0300 Subject: [PATCH] Added pattern clearing on long shift press --- Software/Gravity/Gravity.ino | 36 +++++++++++++++++-------------- Software/Gravity/Interactions.ino | 8 +++++++ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index a52d0da..8b55b8d 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -52,22 +52,22 @@ channel channels[6] = { //array of channel settings { 0, 7, 0, 3, 0, 3, 0, 0, 0 } }; -bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}; -bool seqA2[16] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0}; -bool seqA3[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; -bool seqA4[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}; -bool seqA5[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}; -bool seqA6[16] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0}; -bool seqA7[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; -bool seqA8[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}; -bool seqB1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}; -bool seqB2[16] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0}; -bool seqB3[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; -bool seqB4[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}; -bool seqB5[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}; -bool seqB6[16] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0}; -bool seqB7[16] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; -bool seqB8[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}; +bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1}; +bool seqA2[16] = {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}; +bool seqA3[16] = {1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0}; +bool seqA4[16] = {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1}; +bool seqA5[16] = {0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1}; +bool seqA6[16] = {0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0}; +bool seqA7[16] = {1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0}; +bool seqA8[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1}; +bool seqB1[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +bool seqB2[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +bool seqB3[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +bool seqB4[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +bool seqB5[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +bool seqB6[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +bool seqB7[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +bool seqB8[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; byte currentStep = 0; byte stepNumSelected = 0; bool *patternToEdit; @@ -108,6 +108,10 @@ int a2Input = 0; int encPositionOld = 0; unsigned long encPressedTime; unsigned long encReleasedTime; +unsigned long playPressedTime; +unsigned long playReleasedTime; +unsigned long shiftPressedTime; +unsigned long shiftReleasedTime; bool encPressRegistered; //unsigned long lastInteractionTime; // used for display timeout diff --git a/Software/Gravity/Interactions.ino b/Software/Gravity/Interactions.ino index 7d42ded..d008f6e 100644 --- a/Software/Gravity/Interactions.ino +++ b/Software/Gravity/Interactions.ino @@ -240,6 +240,7 @@ void checkInputs() { //shift button if (!digitalRead(SHIFT_BTN_PIN) && !shiftBtnPushed) { shiftBtnPushed = true; + shiftPressedTime = millis(); if (isRecording) { //Live triggering digitalWrite(outsPins[displayTab - 1], HIGH); } @@ -256,6 +257,13 @@ void checkInputs() { updateScreen(); } else if (digitalRead(SHIFT_BTN_PIN) && shiftBtnPushed) { shiftBtnPushed = false; + shiftReleasedTime = millis(); + if (shiftReleasedTime - shiftPressedTime > 500 && shiftReleasedTime - shiftPressedTime < 2000 && isRecording) { + for (byte i = 0; i < 16; i++) { + patternToEdit[i] = 0; + } + } + saveState(); updateScreen(); }