aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-07-19 10:03:33 +0200
committerBad Diode <bd@badd10de.dev>2023-07-19 10:03:33 +0200
commite8be8a52e999b7a9ee4fc935a33ebfefad5bae3a (patch)
treee87b4a6899dc2ece106fb8e9f886ea3dc7ea08cb
parent1e666da666081bece2c244c2297d08801add3103 (diff)
downloadstepper-e8be8a52e999b7a9ee4fc935a33ebfefad5bae3a.tar.gz
stepper-e8be8a52e999b7a9ee4fc935a33ebfefad5bae3a.zip
Allow removing the last chain when playing
-rw-r--r--src/globals.c2
-rw-r--r--src/main.c2
-rw-r--r--src/sequencer.c13
3 files changed, 10 insertions, 7 deletions
diff --git a/src/globals.c b/src/globals.c
index 1e0d964..7a55f02 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -149,6 +149,4 @@ typedef struct Chain {
149 u8 playing; 149 u8 playing;
150} Chain; 150} Chain;
151 151
152// DEBUG:...
153// static Chain chain = {.chain = {0, 1, 2, 3, 4, 5, 6}, .active = { 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,1, 1,1,1,1}, .len = 14};
154static Chain chain = {0}; 152static Chain chain = {0};
diff --git a/src/main.c b/src/main.c
index 2cda769..61e26e7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -95,7 +95,7 @@ render_sequencer(void) {
95 } 95 }
96 96
97 if (input_handler == handle_pattern_selection || 97 if (input_handler == handle_pattern_selection ||
98 input_handler == handle_pattern_chain){ 98 input_handler == handle_pattern_chain) {
99 draw_pattern_chain(); 99 draw_pattern_chain();
100 } 100 }
101 101
diff --git a/src/sequencer.c b/src/sequencer.c
index 9de08f8..038b608 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -565,22 +565,27 @@ handle_pattern_chain(void) {
565 } else if (key_tap(KEY_B)) { 565 } else if (key_tap(KEY_B)) {
566 if (chain.active[param_selection_loc]) { 566 if (chain.active[param_selection_loc]) {
567 // Can't toggle current chain. 567 // Can't toggle current chain.
568 if (!play_status || param_selection_loc != chain.current) { 568 if (!play_status
569 || param_selection_loc != chain.current
570 || chain.len == 1) {
569 chain.active[param_selection_loc] = 0; 571 chain.active[param_selection_loc] = 0;
570 chain.len--; 572 chain.len--;
571 } 573 }
572 } else { 574 } else {
575 if (chain.len == 0) {
576 chain.current = param_selection_loc;
577 }
573 chain.active[param_selection_loc] = 1; 578 chain.active[param_selection_loc] = 1;
574 chain.len++; 579 chain.len++;
575 } 580 }
576 } else if (key_tap(KEY_L)) { 581 } else if (key_tap(KEY_L)) {
577 if (chain.active[param_selection_loc] 582 if (chain.active[param_selection_loc]
578 && chain.chain[param_selection_loc] > 0 583 && chain.chain[param_selection_loc] > 0
579 && (!play_status || param_selection_loc != chain.current)) { 584 && (!play_status || param_selection_loc != chain.current)) {
580 chain.chain[param_selection_loc]--; 585 chain.chain[param_selection_loc]--;
581 } 586 }
582 } else if (key_tap(KEY_R)) { 587 } else if (key_tap(KEY_R)) {
583 if (chain.active[param_selection_loc] 588 if (chain.active[param_selection_loc]
584 && chain.chain[param_selection_loc] < 7 589 && chain.chain[param_selection_loc] < 7
585 && (!play_status || param_selection_loc != chain.current)) { 590 && (!play_status || param_selection_loc != chain.current)) {
586 chain.chain[param_selection_loc]++; 591 chain.chain[param_selection_loc]++;
@@ -663,7 +668,7 @@ handle_pattern_selection(void) {
663 size_t idx = 15 - i; 668 size_t idx = 15 - i;
664 if (chain.active[idx] == 1) { 669 if (chain.active[idx] == 1) {
665 // If the pattern is currently playing it can't be removed. 670 // If the pattern is currently playing it can't be removed.
666 if (play_status && idx == chain.current) { 671 if (play_status && idx == chain.current && chain.len > 1) {
667 continue; 672 continue;
668 } else if (idx == chain.current) { 673 } else if (idx == chain.current) {
669 update_current = true; 674 update_current = true;