From 47e4babcf6cf7d039af8234b222e73b72238ed5d Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Tue, 11 Mar 2025 20:27:50 +0200 Subject: [PATCH] sequence length can be changed from the UI --- Software/Gravity/Gravity.ino | 2 +- Software/Gravity/Interactions.ino | 19 ++++++++++++------- Software/Gravity/UI.ino | 22 ++++++++++++++++++---- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Software/Gravity/Gravity.ino b/Software/Gravity/Gravity.ino index 64acb02..536d663 100644 --- a/Software/Gravity/Gravity.ino +++ b/Software/Gravity/Gravity.ino @@ -102,7 +102,7 @@ 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[7] = {0}; -byte stepNumSelected = 0; +int8_t stepNumSelected = 0; byte patternToEdit; unsigned int channelPulseCount[7]; diff --git a/Software/Gravity/Interactions.ino b/Software/Gravity/Interactions.ino index fe765ac..b40ee9f 100644 --- a/Software/Gravity/Interactions.ino +++ b/Software/Gravity/Interactions.ino @@ -342,14 +342,19 @@ void checkInputs() { channels[displayTab - 1].CV2Target = 3; } saveState(); - } - } else if (displayScreen == 1 && !isRecording) { + } + } else if (displayScreen == 1 && !isRecording && !shiftBtnPushed) { stepNumSelected = stepNumSelected + change; - if (stepNumSelected > sequences[channels[displayTab - 1].seqPattern].length + 1) { - stepNumSelected = sequences[channels[displayTab - 1].seqPattern].length; - } else if (stepNumSelected > sequences[channels[displayTab - 1].seqPattern].length) { + if (stepNumSelected < -1 ) { + stepNumSelected = -1; + } else if (stepNumSelected > sequences[channels[displayTab - 1].seqPattern].length && !shiftBtnPushed) { stepNumSelected = 0; - } + } + } else if (displayScreen == 1 && !isRecording && stepNumSelected == -1 && shiftBtnPushed) { + if ((sequences[channels[displayTab - 1].seqPattern].length != 31 && change > 0) || + (sequences[channels[displayTab - 1].seqPattern].length != 0 && change < 0)) { + sequences[channels[displayTab - 1].seqPattern].length += change; + } } else if (displayScreen == 2 && !shiftBtnPushed) { menuItem = menuItem + change; if (menuItem > 100) { //for "negative" values @@ -399,7 +404,7 @@ void checkInputs() { if (isRecording) { //Live triggering digitalWrite(outsPins[displayTab - 1], HIGH); } - if (displayScreen == 1 && !isRecording) { + if (displayScreen == 1 && !isRecording && stepNumSelected <= sequences[patternToEdit].length) { sequences[patternToEdit].sequence = bitFlip(sequences[patternToEdit].sequence, stepNumSelected); } else if (displayScreen == 1 && isRecording && !recordToNextStep) { //Recording bitSet(sequences[patternToEdit].sequence, currentStep[displayTab - 1]); diff --git a/Software/Gravity/UI.ino b/Software/Gravity/UI.ino index ac692b1..cfde9f9 100644 --- a/Software/Gravity/UI.ino +++ b/Software/Gravity/UI.ino @@ -301,16 +301,30 @@ void updateScreen() { valueStr = F("PATTERN B"); valueStr = valueStr + String(pattern - 7); } - u8g2.drawUTF8(8, 5, valueStr.c_str() ); + u8g2.drawUTF8(8, 6, valueStr.c_str() ); valueStr = F("L: "); - u8g2.drawUTF8(100, 5, valueStr.c_str() ); + //u8g2.drawUTF8(100, 5, valueStr.c_str() ); + if (!isRecording && stepNumSelected == -1) { + u8g2.drawButtonUTF8(97, 6, U8G2_BTN_BW1|U8G2_BTN_INV, 5, 1, 2, valueStr.c_str() ); + } else { + u8g2.drawButtonUTF8(97, 6, U8G2_BTN_BW0, 5, 1, 2, valueStr.c_str() ); + } + valueStr = String(sequences[patternToEdit].length + 1); - u8g2.drawUTF8(110, 5, valueStr.c_str() ); + //u8g2.drawUTF8(110, 5, valueStr.c_str() ); + if (!isRecording && stepNumSelected == -1 && (menuItemSelected || shiftBtnPushed)) { + u8g2.drawButtonUTF8(110, 6, U8G2_BTN_BW1, 8, 1, 2, valueStr.c_str() ); + } else if (!isRecording && stepNumSelected == -1 && (!menuItemSelected || !shiftBtnPushed)) { + u8g2.drawButtonUTF8(110, 6, U8G2_BTN_BW1|U8G2_BTN_INV, 8, 1, 2, valueStr.c_str() ); + } else { + u8g2.drawButtonUTF8(110, 6, U8G2_BTN_BW0, 8, 1, 2, valueStr.c_str() ); + } + u8g2.drawHLine(0, 8, 128); for (byte i = 0; i <= sequences[patternToEdit].length; i++) { u8g2.drawUTF8(19 + (i % 8)*12, 18 + ((i / 8) * 11), (bitRead(sequences[patternToEdit].sequence, i) ? "q" : "p")); } - if (!isRecording) { + if (!isRecording && stepNumSelected >= 0) { u8g2.drawFrame(16 + (stepNumSelected % 8)*12, 10 + ((stepNumSelected / 8) * 11), 11, 11); //cursor }