From cf9912cd61c9499fc60a839042fcae1ac556e044 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Thu, 24 Aug 2023 18:38:46 +0200 Subject: Add visual feedback and control for scale roots --- src/drawing.c | 60 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 15 deletions(-) (limited to 'src/drawing.c') 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() { draw_rect(x, y, x + R_COL_W - 2, y + BPM_H - 3, COL_FG); txt_drawf_small("BPM", x + 7, y - 10, COL_FG); - // Make sure its horizontally centered if only 2 digits - int bpm = patterns[pattern_selection_loc].bpm; - if (bpm >= 100) { - txt_drawf("%d", x + 5, y + 2, COL_FG, bpm); + if (settings.sync == SYNC_IN_LINK) { + txt_drawf("SYNC", x + 2, y + 2, COL_FG); } else { - txt_drawf("%d", x + 8, y + 2, COL_FG, bpm); + // Make sure its horizontally centered if only 2 digits + int bpm = patterns[pattern_selection_loc].bpm; + if (bpm >= 100) { + txt_drawf("%d", x + 5, y + 2, COL_FG, bpm); + } else { + txt_drawf("%d", x + 8, y + 2, COL_FG, bpm); + } } } @@ -531,16 +535,18 @@ draw_note(u8 note, u8 clr) { draw_filled_rect(x0, y0, x1, y1, clr); } break; default: { - if (clr == COL_FG) { - clr = COL_BG; - } + // NOTE: Decide if this looks better or nah. Also, not the right + // place for it... + // if (clr == COL_FG) { + // clr = COL_BG; + // } y0 = base_y0; y1 = base_y1 + PIANO_BLACK_H - 2; switch (value) { - case 1: { x0 = base_x + octave * 28 + 3; } break; - case 3: { x0 = base_x + octave * 28 + 7; } break; - case 6: { x0 = base_x + octave * 28 + 15; } break; - case 8: { x0 = base_x + octave * 28 + 19; } break; + case 1: { x0 = base_x + octave * 28 + 3; } break; + case 3: { x0 = base_x + octave * 28 + 7; } break; + case 6: { x0 = base_x + octave * 28 + 15; } break; + case 8: { x0 = base_x + octave * 28 + 19; } break; case 10: { x0 = base_x + octave * 28 + 23; } break; } x1 = x0; @@ -557,7 +563,24 @@ draw_piano(void) { size_t y1 = PIANO_START_Y + PIANO_H; draw_rect(x0, y0, x1, y1, COL_FG); for (size_t i = 0; i < 12 * 6; i++) { - draw_note(i, COL_FG); + u8 clr = COL_FG; + if (input_handler == handle_right_col_selection && + right_col_selection_loc == R_COL_SCALE) { + s8 pos = i % 12; + if (pos == current_scale_root) { + clr = COL_ACC_1; + } else { + s8 scale_pos = (pos - current_scale_root) % 12; + if (scale_pos < 0) { + scale_pos *= -1; + scale_pos = 12 - scale_pos; + } + if (scales[current_scale][scale_pos] == 1) { + clr = COL_ACC_0; + } + } + } + draw_note(i, clr); } } @@ -1314,7 +1337,9 @@ draw_piano_notes(void) { // Show last/current played notes in all channels. if (play_status == 1) { Pattern *pat = &patterns[current_pattern]; - if (pat->empty || play_status == 0) { + if (pat->empty || + play_status == 0 || + input_handler == handle_right_col_selection) { return; } u8 step = step_counter % 16; @@ -1681,7 +1706,12 @@ draw_notif_bar() { txt_drawf_small("SETTINGS", x0 + 2, y0 + 1, color); } break; case R_COL_SCALE: { - txt_drawf_small("SCALE: %s", x0 + 2, y0 + 1, color, scale_long[current_scale]); + const char *roots[12] = { + "C ", "C#", "D ", "D#", "E ", "F ", + "F#", "G ", "G#", "A ", "A#", "B ", + }; + txt_drawf_small("ROOT: %s SCALE: %s", x0 + 2, y0 + 1, color, + roots[current_scale_root], scale_long[current_scale]); } break; case R_COL_BPM: { txt_drawf_small("TEMPO: %d bpm", x0 + 2, y0 + 1, color, patterns[pattern_selection_loc].bpm); -- cgit v1.2.1