diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-24 18:38:46 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-24 18:38:46 +0200 |
commit | cf9912cd61c9499fc60a839042fcae1ac556e044 (patch) | |
tree | 47d396da1f5515038080adcd8c947e593a205b21 /src/drawing.c | |
parent | 84f7dd59c87506a29f534a2f6a558799db38d256 (diff) | |
download | stepper-cf9912cd61c9499fc60a839042fcae1ac556e044.tar.gz stepper-cf9912cd61c9499fc60a839042fcae1ac556e044.zip |
Add visual feedback and control for scale roots
Diffstat (limited to 'src/drawing.c')
-rw-r--r-- | src/drawing.c | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/src/drawing.c b/src/drawing.c index a432285..f3115c5 100644 --- a/src/drawing.c +++ b/src/drawing.c | |||
@@ -393,12 +393,16 @@ draw_bpm() { | |||
393 | draw_rect(x, y, x + R_COL_W - 2, y + BPM_H - 3, COL_FG); | 393 | draw_rect(x, y, x + R_COL_W - 2, y + BPM_H - 3, COL_FG); |
394 | txt_drawf_small("BPM", x + 7, y - 10, COL_FG); | 394 | txt_drawf_small("BPM", x + 7, y - 10, COL_FG); |
395 | 395 | ||
396 | // Make sure its horizontally centered if only 2 digits | 396 | if (settings.sync == SYNC_IN_LINK) { |
397 | int bpm = patterns[pattern_selection_loc].bpm; | 397 | txt_drawf("SYNC", x + 2, y + 2, COL_FG); |
398 | if (bpm >= 100) { | ||
399 | txt_drawf("%d", x + 5, y + 2, COL_FG, bpm); | ||
400 | } else { | 398 | } else { |
401 | txt_drawf("%d", x + 8, y + 2, COL_FG, bpm); | 399 | // Make sure its horizontally centered if only 2 digits |
400 | int bpm = patterns[pattern_selection_loc].bpm; | ||
401 | if (bpm >= 100) { | ||
402 | txt_drawf("%d", x + 5, y + 2, COL_FG, bpm); | ||
403 | } else { | ||
404 | txt_drawf("%d", x + 8, y + 2, COL_FG, bpm); | ||
405 | } | ||
402 | } | 406 | } |
403 | } | 407 | } |
404 | 408 | ||
@@ -531,16 +535,18 @@ draw_note(u8 note, u8 clr) { | |||
531 | draw_filled_rect(x0, y0, x1, y1, clr); | 535 | draw_filled_rect(x0, y0, x1, y1, clr); |
532 | } break; | 536 | } break; |
533 | default: { | 537 | default: { |
534 | if (clr == COL_FG) { | 538 | // NOTE: Decide if this looks better or nah. Also, not the right |
535 | clr = COL_BG; | 539 | // place for it... |
536 | } | 540 | // if (clr == COL_FG) { |
541 | // clr = COL_BG; | ||
542 | // } | ||
537 | y0 = base_y0; | 543 | y0 = base_y0; |
538 | y1 = base_y1 + PIANO_BLACK_H - 2; | 544 | y1 = base_y1 + PIANO_BLACK_H - 2; |
539 | switch (value) { | 545 | switch (value) { |
540 | case 1: { x0 = base_x + octave * 28 + 3; } break; | 546 | case 1: { x0 = base_x + octave * 28 + 3; } break; |
541 | case 3: { x0 = base_x + octave * 28 + 7; } break; | 547 | case 3: { x0 = base_x + octave * 28 + 7; } break; |
542 | case 6: { x0 = base_x + octave * 28 + 15; } break; | 548 | case 6: { x0 = base_x + octave * 28 + 15; } break; |
543 | case 8: { x0 = base_x + octave * 28 + 19; } break; | 549 | case 8: { x0 = base_x + octave * 28 + 19; } break; |
544 | case 10: { x0 = base_x + octave * 28 + 23; } break; | 550 | case 10: { x0 = base_x + octave * 28 + 23; } break; |
545 | } | 551 | } |
546 | x1 = x0; | 552 | x1 = x0; |
@@ -557,7 +563,24 @@ draw_piano(void) { | |||
557 | size_t y1 = PIANO_START_Y + PIANO_H; | 563 | size_t y1 = PIANO_START_Y + PIANO_H; |
558 | draw_rect(x0, y0, x1, y1, COL_FG); | 564 | draw_rect(x0, y0, x1, y1, COL_FG); |
559 | for (size_t i = 0; i < 12 * 6; i++) { | 565 | for (size_t i = 0; i < 12 * 6; i++) { |
560 | draw_note(i, COL_FG); | 566 | u8 clr = COL_FG; |
567 | if (input_handler == handle_right_col_selection && | ||
568 | right_col_selection_loc == R_COL_SCALE) { | ||
569 | s8 pos = i % 12; | ||
570 | if (pos == current_scale_root) { | ||
571 | clr = COL_ACC_1; | ||
572 | } else { | ||
573 | s8 scale_pos = (pos - current_scale_root) % 12; | ||
574 | if (scale_pos < 0) { | ||
575 | scale_pos *= -1; | ||
576 | scale_pos = 12 - scale_pos; | ||
577 | } | ||
578 | if (scales[current_scale][scale_pos] == 1) { | ||
579 | clr = COL_ACC_0; | ||
580 | } | ||
581 | } | ||
582 | } | ||
583 | draw_note(i, clr); | ||
561 | } | 584 | } |
562 | } | 585 | } |
563 | 586 | ||
@@ -1314,7 +1337,9 @@ draw_piano_notes(void) { | |||
1314 | // Show last/current played notes in all channels. | 1337 | // Show last/current played notes in all channels. |
1315 | if (play_status == 1) { | 1338 | if (play_status == 1) { |
1316 | Pattern *pat = &patterns[current_pattern]; | 1339 | Pattern *pat = &patterns[current_pattern]; |
1317 | if (pat->empty || play_status == 0) { | 1340 | if (pat->empty || |
1341 | play_status == 0 || | ||
1342 | input_handler == handle_right_col_selection) { | ||
1318 | return; | 1343 | return; |
1319 | } | 1344 | } |
1320 | u8 step = step_counter % 16; | 1345 | u8 step = step_counter % 16; |
@@ -1681,7 +1706,12 @@ draw_notif_bar() { | |||
1681 | txt_drawf_small("SETTINGS", x0 + 2, y0 + 1, color); | 1706 | txt_drawf_small("SETTINGS", x0 + 2, y0 + 1, color); |
1682 | } break; | 1707 | } break; |
1683 | case R_COL_SCALE: { | 1708 | case R_COL_SCALE: { |
1684 | txt_drawf_small("SCALE: %s", x0 + 2, y0 + 1, color, scale_long[current_scale]); | 1709 | const char *roots[12] = { |
1710 | "C ", "C#", "D ", "D#", "E ", "F ", | ||
1711 | "F#", "G ", "G#", "A ", "A#", "B ", | ||
1712 | }; | ||
1713 | txt_drawf_small("ROOT: %s SCALE: %s", x0 + 2, y0 + 1, color, | ||
1714 | roots[current_scale_root], scale_long[current_scale]); | ||
1685 | } break; | 1715 | } break; |
1686 | case R_COL_BPM: { | 1716 | case R_COL_BPM: { |
1687 | txt_drawf_small("TEMPO: %d bpm", x0 + 2, y0 + 1, color, patterns[pattern_selection_loc].bpm); | 1717 | txt_drawf_small("TEMPO: %d bpm", x0 + 2, y0 + 1, color, patterns[pattern_selection_loc].bpm); |