diff options
author | Bad Diode <bd@badd10de.dev> | 2023-06-28 17:30:26 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-06-28 17:30:26 +0200 |
commit | 5bafdd1511d37373022f809cfc2a0589a1d8de38 (patch) | |
tree | e7db952676237319016a03e0284af2dd7f03d415 /src/app.c | |
parent | 05f3c922d703666e0539f27f6cebfbf67d8cea53 (diff) | |
download | launchpad-polymaker-5bafdd1511d37373022f809cfc2a0589a1d8de38.tar.gz launchpad-polymaker-5bafdd1511d37373022f809cfc2a0589a1d8de38.zip |
Add scale transpose and prettier colors
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 208 |
1 files changed, 102 insertions, 106 deletions
@@ -220,12 +220,22 @@ typedef struct Color { | |||
220 | int b; | 220 | int b; |
221 | } Color; | 221 | } Color; |
222 | 222 | ||
223 | Color colors[] = { | 223 | #define DRAW(PAD, CLR) hal_plot_led(TYPEPAD, (PAD), (CLR).r, (CLR).g, (CLR).b) |
224 | { MAXLED, MAXLED, MAXLED }, // White | 224 | #define BLACK (Color){ 0 , 0 , 0 } |
225 | { MAXLED, 0, 0 }, // Red | 225 | #define WHITE (Color){ MAXLED , MAXLED , MAXLED } |
226 | { 0, MAXLED, 0 }, // Green | 226 | #define GREY (Color){ MAXLED / 2 , MAXLED / 2 , MAXLED / 2 } |
227 | { 0, 0, MAXLED }, // Blue | 227 | #define RED (Color){ 62 , 8 , 15 } |
228 | }; | 228 | #define RED_DIM (Color){ MAXLED / 5 , 0 , 0 } |
229 | #define YELLOW (Color){ 61 , 58 , 25 } | ||
230 | #define YELLOW_DIM (Color){ 5 , 5 , 0 } | ||
231 | #define PURPLE (Color){ 20 , 0 , 40 } | ||
232 | #define PURPLE_DIM (Color){ 2 , 0 , 5 } | ||
233 | #define GREEN (Color){ 17 , 53 , 36 } | ||
234 | #define BLUE (Color){ 0 , 34 , 52 } | ||
235 | #define CYAN (Color){ 8 , 62 , 56 } | ||
236 | #define ORANGE (Color){ MAXLED , 40 , 23 } | ||
237 | #define PINK (Color){ 61 , 34 , 39 } | ||
238 | #define TEAL (Color){ 0 , MAXLED / 2 , MAXLED / 2 } | ||
229 | 239 | ||
230 | typedef struct Voice { | 240 | typedef struct Voice { |
231 | u8 active; | 241 | u8 active; |
@@ -248,6 +258,7 @@ typedef struct State { | |||
248 | Mode mode; | 258 | Mode mode; |
249 | // Keyboard. | 259 | // Keyboard. |
250 | u8 kbd_octave; | 260 | u8 kbd_octave; |
261 | u8 kbd_root; | ||
251 | } State; | 262 | } State; |
252 | 263 | ||
253 | // Globals. | 264 | // Globals. |
@@ -326,48 +337,48 @@ kbd_find_note(int index) { | |||
326 | if (index >= POLY_PAD_ROW_0 && index <= (POLY_PAD_ROW_0 + 7)) { | 337 | if (index >= POLY_PAD_ROW_0 && index <= (POLY_PAD_ROW_0 + 7)) { |
327 | row = POLY_PAD_ROW_0; | 338 | row = POLY_PAD_ROW_0; |
328 | black = 1; | 339 | black = 1; |
329 | note = 12 * (state.kbd_octave + 5); | 340 | note = 12 * (state.kbd_octave + 5) + state.kbd_root; |
330 | } | 341 | } |
331 | if (index >= POLY_PAD_ROW_1 && index <= (POLY_PAD_ROW_1 + 7)) { | 342 | if (index >= POLY_PAD_ROW_1 && index <= (POLY_PAD_ROW_1 + 7)) { |
332 | row = POLY_PAD_ROW_1; | 343 | row = POLY_PAD_ROW_1; |
333 | note = 12 * (state.kbd_octave + 5); | 344 | note = 12 * (state.kbd_octave + 5) + state.kbd_root; |
334 | } | 345 | } |
335 | 346 | ||
336 | // B | 347 | // B |
337 | if (index >= POLY_PAD_ROW_2 && index <= (POLY_PAD_ROW_2 + 7)) { | 348 | if (index >= POLY_PAD_ROW_2 && index <= (POLY_PAD_ROW_2 + 7)) { |
338 | row = POLY_PAD_ROW_2; | 349 | row = POLY_PAD_ROW_2; |
339 | black = 1; | 350 | black = 1; |
340 | note = 12 * (state.kbd_octave + 4); | 351 | note = 12 * (state.kbd_octave + 4) + state.kbd_root; |
341 | } | 352 | } |
342 | if (index >= POLY_PAD_ROW_3 && index <= (POLY_PAD_ROW_3 + 7)) { | 353 | if (index >= POLY_PAD_ROW_3 && index <= (POLY_PAD_ROW_3 + 7)) { |
343 | row = POLY_PAD_ROW_3; | 354 | row = POLY_PAD_ROW_3; |
344 | note = 12 * (state.kbd_octave + 4); | 355 | note = 12 * (state.kbd_octave + 4) + state.kbd_root; |
345 | } | 356 | } |
346 | 357 | ||
347 | // C | 358 | // C |
348 | if (index >= POLY_PAD_ROW_4 && index <= (POLY_PAD_ROW_4 + 7)) { | 359 | if (index >= POLY_PAD_ROW_4 && index <= (POLY_PAD_ROW_4 + 7)) { |
349 | row = POLY_PAD_ROW_4; | 360 | row = POLY_PAD_ROW_4; |
350 | black = 1; | 361 | black = 1; |
351 | note = 12 * (state.kbd_octave + 3); | 362 | note = 12 * (state.kbd_octave + 3) + state.kbd_root; |
352 | } | 363 | } |
353 | if (index >= POLY_PAD_ROW_5 && index <= (POLY_PAD_ROW_5 + 7)) { | 364 | if (index >= POLY_PAD_ROW_5 && index <= (POLY_PAD_ROW_5 + 7)) { |
354 | row = POLY_PAD_ROW_5; | 365 | row = POLY_PAD_ROW_5; |
355 | note = 12 * (state.kbd_octave + 3); | 366 | note = 12 * (state.kbd_octave + 3) + state.kbd_root; |
356 | } | 367 | } |
357 | 368 | ||
358 | // D | 369 | // D |
359 | if (index >= POLY_PAD_ROW_6 && index <= (POLY_PAD_ROW_6 + 7)) { | 370 | if (index >= POLY_PAD_ROW_6 && index <= (POLY_PAD_ROW_6 + 7)) { |
360 | row = POLY_PAD_ROW_6; | 371 | row = POLY_PAD_ROW_6; |
361 | black = 1; | 372 | black = 1; |
362 | note = 12 * (state.kbd_octave + 2); | 373 | note = 12 * (state.kbd_octave + 2) + state.kbd_root; |
363 | } | 374 | } |
364 | if (index >= POLY_PAD_ROW_7 && index <= (POLY_PAD_ROW_7 + 7)) { | 375 | if (index >= POLY_PAD_ROW_7 && index <= (POLY_PAD_ROW_7 + 7)) { |
365 | row = POLY_PAD_ROW_7; | 376 | row = POLY_PAD_ROW_7; |
366 | note = 12 * (state.kbd_octave + 2); | 377 | note = 12 * (state.kbd_octave + 2) + state.kbd_root; |
367 | } | 378 | } |
368 | 379 | ||
369 | // Invalid pad index. | 380 | // Invalid pad index. |
370 | if (note < 0) { | 381 | if (note < 0 || note > 127) { |
371 | return -1; | 382 | return -1; |
372 | } | 383 | } |
373 | 384 | ||
@@ -478,6 +489,9 @@ app_surface_event(u8 type, u8 index, u8 value) { | |||
478 | } break; | 489 | } break; |
479 | case MOD_POLY_KBD: { | 490 | case MOD_POLY_KBD: { |
480 | if (index >= POLY_TOP_ROW && index <= (POLY_TOP_ROW + 7)) { | 491 | if (index >= POLY_TOP_ROW && index <= (POLY_TOP_ROW + 7)) { |
492 | if (!value) { | ||
493 | return; | ||
494 | } | ||
481 | switch (index) { | 495 | switch (index) { |
482 | // Transposition. | 496 | // Transposition. |
483 | case POLY_PAD_UP: { | 497 | case POLY_PAD_UP: { |
@@ -486,6 +500,12 @@ app_surface_event(u8 type, u8 index, u8 value) { | |||
486 | case POLY_PAD_DOWN: { | 500 | case POLY_PAD_DOWN: { |
487 | if (state.kbd_octave > 0) { state.kbd_octave--; } | 501 | if (state.kbd_octave > 0) { state.kbd_octave--; } |
488 | } break; | 502 | } break; |
503 | case POLY_PAD_RIGHT: { | ||
504 | if (state.kbd_root < 12) { state.kbd_root++; } | ||
505 | } break; | ||
506 | case POLY_PAD_LEFT: { | ||
507 | if (state.kbd_root > 0) { state.kbd_root--; } | ||
508 | } break; | ||
489 | // Different sections. | 509 | // Different sections. |
490 | case POLY_PAD_SESSION: { | 510 | case POLY_PAD_SESSION: { |
491 | state.mode = MOD_POLY_MAIN; | 511 | state.mode = MOD_POLY_MAIN; |
@@ -496,10 +516,8 @@ app_surface_event(u8 type, u8 index, u8 value) { | |||
496 | return; | 516 | return; |
497 | } | 517 | } |
498 | u8 channel = 0; | 518 | u8 channel = 0; |
499 | // TODO: Velocity on/off configuration. | 519 | // TODO: Velocity on/off/curve configuration. |
500 | // TODO: Velocity curve adjustment. | ||
501 | // TODO: Aftertouch? | 520 | // TODO: Aftertouch? |
502 | // TODO: Different colors for different octaves. | ||
503 | // TODO: Per KBD channel selection. | 521 | // TODO: Per KBD channel selection. |
504 | int note = kbd_find_note(index); | 522 | int note = kbd_find_note(index); |
505 | if (note == -1) { | 523 | if (note == -1) { |
@@ -674,21 +692,23 @@ app_cable_event(u8 type, u8 value) { | |||
674 | } | 692 | } |
675 | } | 693 | } |
676 | if (midi_in_connected && midi_out_connected) { | 694 | if (midi_in_connected && midi_out_connected) { |
677 | hal_plot_led(TYPESETUP, 0, 0, value, 0); | 695 | Color clr = CYAN; |
696 | hal_plot_led(TYPESETUP, 0, clr.r, clr.g, clr.b); | ||
678 | } else { | 697 | } else { |
679 | hal_plot_led(TYPESETUP, 0, value, 0, 0); | 698 | Color clr = RED; |
699 | hal_plot_led(TYPESETUP, 0, clr.r, clr.g, clr.b); | ||
680 | } | 700 | } |
681 | } | 701 | } |
682 | 702 | ||
683 | void | 703 | void |
684 | print_number(u8 n, u16 r, u16 g, u16 b, u8 x, u8 y) { | 704 | print_number(u8 n, Color clr, u8 x, u8 y) { |
685 | u16 number = font_numbers[n]; | 705 | u16 number = font_numbers[n]; |
686 | for (u8 row = 0; row < 5; row++) { | 706 | for (u8 row = 0; row < 5; row++) { |
687 | u8 pos = 11 + 10 * (7 - y) - row * 10 + x; | 707 | u8 pos = 11 + 10 * (7 - y) - row * 10 + x; |
688 | u16 cur = number >> (13 - 3 * row); | 708 | u16 cur = number >> (13 - 3 * row); |
689 | for (u8 i = 0; i < 3; i++) { | 709 | for (u8 i = 0; i < 3; i++) { |
690 | if ((cur >> (2 - i)) & 0x1) { | 710 | if ((cur >> (2 - i)) & 0x1) { |
691 | hal_plot_led(TYPEPAD, pos + i, r, g, b); | 711 | DRAW(pos + i, clr); |
692 | } | 712 | } |
693 | } | 713 | } |
694 | } | 714 | } |
@@ -696,15 +716,6 @@ print_number(u8 n, u16 r, u16 g, u16 b, u8 x, u8 y) { | |||
696 | 716 | ||
697 | void | 717 | void |
698 | update(void) { | 718 | update(void) { |
699 | // for (int i = 0; i < PAD_COUNT; ++i) { | ||
700 | // // Get the first detected button n_voices. | ||
701 | // u16 x = (99 * g_ADC[i]) >> 12; | ||
702 | // if (x > 3) { | ||
703 | // n_voices = x; | ||
704 | // return; | ||
705 | // } | ||
706 | // } | ||
707 | // n_voices = 0; | ||
708 | if (save_state) { | 719 | if (save_state) { |
709 | hal_write_flash(0, (u8*)&state, sizeof(State)); | 720 | hal_write_flash(0, (u8*)&state, sizeof(State)); |
710 | save_state = 0; | 721 | save_state = 0; |
@@ -714,79 +725,59 @@ update(void) { | |||
714 | void | 725 | void |
715 | clear_pads(void) { | 726 | clear_pads(void) { |
716 | for (int i = 0; i < PAD_COUNT; ++i) { | 727 | for (int i = 0; i < PAD_COUNT; ++i) { |
717 | hal_plot_led(TYPEPAD, ADC_MAP[i], 0, 0, 0); | 728 | DRAW(ADC_MAP[i], BLACK); |
718 | } | 729 | } |
719 | hal_plot_led(TYPEPAD, POLY_PAD_SESSION, 0, 0, 0); | 730 | DRAW(POLY_PAD_SESSION, BLACK); |
720 | hal_plot_led(TYPEPAD, POLY_PAD_NOTE, 0, 0, 0); | 731 | DRAW(POLY_PAD_NOTE, BLACK); |
721 | } | 732 | } |
722 | 733 | ||
723 | void | 734 | void |
724 | draw_poly_active_button(void) { | 735 | draw_poly_active_button(void) { |
725 | if (state.active) { | 736 | if (state.active) { |
726 | hal_plot_led(TYPEPAD, POLY_PAD_ACTIVE, 0, MAXLED, 0); | 737 | DRAW(POLY_PAD_ACTIVE, GREEN); |
727 | } else { | 738 | } else { |
728 | hal_plot_led(TYPEPAD, POLY_PAD_ACTIVE, MAXLED, 0, 0); | 739 | DRAW(POLY_PAD_ACTIVE, RED); |
729 | } | 740 | } |
730 | } | 741 | } |
731 | 742 | ||
732 | void | 743 | void |
733 | draw_poly_steal_button(void) { | 744 | draw_poly_steal_button(void) { |
734 | switch (state.stealing) { | 745 | switch (state.stealing) { |
735 | case POLY_STEAL_OFF: { | 746 | case POLY_STEAL_OFF: { DRAW(POLY_PAD_STEAL, RED); } break; |
736 | hal_plot_led(TYPEPAD, POLY_PAD_STEAL, MAXLED, 0, 0); | 747 | case POLY_STEAL_OLD: { DRAW(POLY_PAD_STEAL, CYAN); } break; |
737 | } break; | 748 | case POLY_STEAL_HIGH: { DRAW(POLY_PAD_STEAL, ORANGE); } break; |
738 | case POLY_STEAL_OLD: { | 749 | case POLY_STEAL_LOW: { DRAW(POLY_PAD_STEAL, PURPLE); } break; |
739 | hal_plot_led(TYPEPAD, POLY_PAD_STEAL, 0, 24, 24); | ||
740 | } break; | ||
741 | case POLY_STEAL_HIGH: { | ||
742 | hal_plot_led(TYPEPAD, POLY_PAD_STEAL, 0, 24, 0); | ||
743 | } break; | ||
744 | case POLY_STEAL_LOW: { | ||
745 | hal_plot_led(TYPEPAD, POLY_PAD_STEAL, 0, 0, 24); | ||
746 | } break; | ||
747 | } | 750 | } |
748 | } | 751 | } |
749 | 752 | ||
750 | void | 753 | void |
751 | draw_poly_main(void) { | 754 | draw_poly_main(void) { |
752 | hal_plot_led(TYPEPAD, POLY_PAD_SESSION, MAXLED / 2, MAXLED / 2, MAXLED / 2); | 755 | DRAW(POLY_PAD_SESSION, GREY); |
753 | print_number((n_voices / 10) % 10, MAXLED, MAXLED, MAXLED, 0, 0); | 756 | print_number((n_voices / 10) % 10, WHITE, 0, 0); |
754 | print_number( n_voices % 10, MAXLED, MAXLED, MAXLED, 4, 0); | 757 | print_number(n_voices % 10, WHITE, 4, 0); |
755 | draw_poly_active_button(); | 758 | draw_poly_active_button(); |
756 | draw_poly_steal_button(); | 759 | draw_poly_steal_button(); |
757 | } | 760 | } |
758 | 761 | ||
759 | void | 762 | void |
760 | draw_min_channel(void) { | 763 | draw_min_channel(void) { |
761 | // for (u8 i = 0; i < 8; i++) { | ||
762 | // if (state.ch_max < 8 && i > state.ch_max) { | ||
763 | // clr = colors[1]; | ||
764 | // } else if (i != state.ch_min){ | ||
765 | // clr = colors[2]; | ||
766 | // } | ||
767 | // hal_plot_led(TYPEPAD, POLY_PAD_MIN_CH_0 + i, clr.r, clr.g, clr.b); | ||
768 | // } | ||
769 | for (u8 i = 0; i < 8; i++) { | 764 | for (u8 i = 0; i < 8; i++) { |
770 | if (i == state.ch_min) { | 765 | if (i == state.ch_min) { |
771 | hal_plot_led(TYPEPAD, POLY_PAD_MIN_CH_0 + i, MAXLED, MAXLED, MAXLED); | 766 | DRAW(POLY_PAD_MIN_CH_0 + i, GREY); |
772 | continue; | 767 | } else if (state.ch_max >= 8 || i <= state.ch_max) { |
773 | } | 768 | DRAW(POLY_PAD_MIN_CH_0 + i, RED); |
774 | if (state.ch_max < 8 && i > state.ch_max) { | 769 | } else { |
775 | hal_plot_led(TYPEPAD, POLY_PAD_MIN_CH_0 + i, 5, 0, 0); | 770 | DRAW(POLY_PAD_MIN_CH_0 + i, RED_DIM); |
776 | continue; | ||
777 | } | 771 | } |
778 | hal_plot_led(TYPEPAD, POLY_PAD_MIN_CH_0 + i, MAXLED / 2, 0, 0); | ||
779 | } | 772 | } |
780 | for (u8 i = 0; i < 8; i++) { | 773 | for (u8 i = 0; i < 8; i++) { |
781 | if ((i + 8) == state.ch_min) { | 774 | if ((i + 8) == state.ch_min) { |
782 | hal_plot_led(TYPEPAD, POLY_PAD_MIN_CH_8 + i, MAXLED, MAXLED, MAXLED); | 775 | DRAW(POLY_PAD_MIN_CH_8 + i, GREY); |
783 | continue; | 776 | } else if (state.ch_max >= 16 || (i + 8) <= state.ch_max) { |
784 | } | 777 | DRAW(POLY_PAD_MIN_CH_8 + i, RED); |
785 | if (state.ch_max < 16 && (i + 8) > state.ch_max) { | 778 | } else { |
786 | hal_plot_led(TYPEPAD, POLY_PAD_MIN_CH_8 + i, 5, 0, 0); | 779 | DRAW(POLY_PAD_MIN_CH_8 + i, RED_DIM); |
787 | continue; | ||
788 | } | 780 | } |
789 | hal_plot_led(TYPEPAD, POLY_PAD_MIN_CH_8 + i, MAXLED / 2, 0, 0); | ||
790 | } | 781 | } |
791 | } | 782 | } |
792 | 783 | ||
@@ -794,25 +785,21 @@ void | |||
794 | draw_max_channel(void) { | 785 | draw_max_channel(void) { |
795 | for (u8 i = 0; i < 8; i++) { | 786 | for (u8 i = 0; i < 8; i++) { |
796 | if (i == state.ch_max) { | 787 | if (i == state.ch_max) { |
797 | hal_plot_led(TYPEPAD, POLY_PAD_MAX_CH_0 + i, MAXLED, MAXLED, MAXLED); | 788 | DRAW(POLY_PAD_MAX_CH_0 + i, GREY); |
798 | continue; | 789 | } else if (i < state.ch_min) { |
799 | } | 790 | DRAW(POLY_PAD_MAX_CH_0 + i, YELLOW_DIM); |
800 | if (i < state.ch_min) { | 791 | } else { |
801 | hal_plot_led(TYPEPAD, POLY_PAD_MAX_CH_0 + i, 5, 5, 0); | 792 | DRAW(POLY_PAD_MAX_CH_0 + i, YELLOW); |
802 | continue; | ||
803 | } | 793 | } |
804 | hal_plot_led(TYPEPAD, POLY_PAD_MAX_CH_0 + i, MAXLED / 2, MAXLED / 2, 0); | ||
805 | } | 794 | } |
806 | for (u8 i = 0; i < 8; i++) { | 795 | for (u8 i = 0; i < 8; i++) { |
807 | if ((i + 8) == state.ch_max) { | 796 | if ((i + 8) == state.ch_max) { |
808 | hal_plot_led(TYPEPAD, POLY_PAD_MAX_CH_8 + i, MAXLED, MAXLED, MAXLED); | 797 | DRAW(POLY_PAD_MAX_CH_8 + i, GREY); |
809 | continue; | 798 | } else if (state.ch_min >= 8 && (i + 8) < state.ch_min) { |
810 | } | 799 | DRAW(POLY_PAD_MAX_CH_8 + i, YELLOW_DIM); |
811 | if (state.ch_min >= 8 && (i + 8) < state.ch_min) { | 800 | } else { |
812 | hal_plot_led(TYPEPAD, POLY_PAD_MAX_CH_8 + i, 5, 5, 0); | 801 | DRAW(POLY_PAD_MAX_CH_8 + i, YELLOW); |
813 | continue; | ||
814 | } | 802 | } |
815 | hal_plot_led(TYPEPAD, POLY_PAD_MAX_CH_8 + i, MAXLED / 2, MAXLED / 2, 0); | ||
816 | } | 803 | } |
817 | } | 804 | } |
818 | 805 | ||
@@ -820,16 +807,16 @@ void | |||
820 | draw_sel_channel(void) { | 807 | draw_sel_channel(void) { |
821 | for (u8 i = 0; i < 8; i++) { | 808 | for (u8 i = 0; i < 8; i++) { |
822 | if (state.ch_listen[i]) { | 809 | if (state.ch_listen[i]) { |
823 | hal_plot_led(TYPEPAD, POLY_PAD_SEL_CH_0 + i, 20, 0, 40); | 810 | DRAW(POLY_PAD_SEL_CH_0 + i, PURPLE); |
824 | } else { | 811 | } else { |
825 | hal_plot_led(TYPEPAD, POLY_PAD_SEL_CH_0 + i, 2, 0, 5); | 812 | DRAW(POLY_PAD_SEL_CH_0 + i, PURPLE_DIM); |
826 | } | 813 | } |
827 | } | 814 | } |
828 | for (u8 i = 0; i < 8; i++) { | 815 | for (u8 i = 0; i < 8; i++) { |
829 | if (state.ch_listen[i + 8]) { | 816 | if (state.ch_listen[i + 8]) { |
830 | hal_plot_led(TYPEPAD, POLY_PAD_SEL_CH_8 + i, 20, 0, 40); | 817 | DRAW(POLY_PAD_SEL_CH_8 + i, PURPLE); |
831 | } else { | 818 | } else { |
832 | hal_plot_led(TYPEPAD, POLY_PAD_SEL_CH_8 + i, 2, 0, 5); | 819 | DRAW(POLY_PAD_SEL_CH_8 + i, PURPLE_DIM); |
833 | } | 820 | } |
834 | } | 821 | } |
835 | } | 822 | } |
@@ -848,27 +835,35 @@ draw_kbd(int loc, Color clr) { | |||
848 | if (loc < 0 || loc >= 7) { | 835 | if (loc < 0 || loc >= 7) { |
849 | return; | 836 | return; |
850 | } | 837 | } |
851 | Color clr_top = clr; | ||
852 | Color clr_bot = (Color){clr_top.r / 4, clr_top.g / 4, clr_top.b / 4 }; | ||
853 | int idx_top = row_idx[loc]; | 838 | int idx_top = row_idx[loc]; |
854 | int idx_bot = row_idx[loc + 1]; | 839 | int idx_bot = row_idx[loc + 1]; |
855 | hal_plot_led(TYPEPAD, idx_top + 1, clr_bot.r, clr_bot.g, clr_bot.b); | 840 | Color colors[] = { |
856 | hal_plot_led(TYPEPAD, idx_top + 2, clr_bot.r, clr_bot.g, clr_bot.b); | 841 | PINK, BLUE, GREEN, YELLOW, ORANGE, RED, CYAN, |
857 | hal_plot_led(TYPEPAD, idx_top + 4, clr_bot.r, clr_bot.g, clr_bot.b); | 842 | }; |
858 | hal_plot_led(TYPEPAD, idx_top + 5, clr_bot.r, clr_bot.g, clr_bot.b); | 843 | Color root_clr = colors[state.kbd_octave + 3 - loc / 2]; |
859 | hal_plot_led(TYPEPAD, idx_top + 6, clr_bot.r, clr_bot.g, clr_bot.b); | 844 | DRAW(idx_top + 1, state.kbd_root == 1 ? WHITE : root_clr); |
860 | for (u8 i = 0; i < 8; i++) { | 845 | DRAW(idx_top + 2, state.kbd_root == 3 ? WHITE : root_clr); |
861 | hal_plot_led(TYPEPAD, idx_bot + i, clr_top.r, clr_top.g, clr_top.b); | 846 | DRAW(idx_top + 4, state.kbd_root == 6 ? WHITE : root_clr); |
862 | } | 847 | DRAW(idx_top + 5, state.kbd_root == 8 ? WHITE : root_clr); |
848 | DRAW(idx_top + 6, state.kbd_root == 10 ? WHITE : root_clr); | ||
849 | |||
850 | DRAW(idx_bot + 0, state.kbd_root == 0 ? WHITE : root_clr); | ||
851 | DRAW(idx_bot + 1, state.kbd_root == 2 ? WHITE : root_clr); | ||
852 | DRAW(idx_bot + 2, state.kbd_root == 4 ? WHITE : root_clr); | ||
853 | DRAW(idx_bot + 3, state.kbd_root == 5 ? WHITE : root_clr); | ||
854 | DRAW(idx_bot + 4, state.kbd_root == 7 ? WHITE : root_clr); | ||
855 | DRAW(idx_bot + 5, state.kbd_root == 9 ? WHITE : root_clr); | ||
856 | DRAW(idx_bot + 6, state.kbd_root == 11 ? WHITE : root_clr); | ||
857 | DRAW(idx_bot + 7, state.kbd_root == 12 ? WHITE : root_clr); | ||
863 | } | 858 | } |
864 | 859 | ||
865 | void | 860 | void |
866 | draw_poly_kbd(void) { | 861 | draw_poly_kbd(void) { |
867 | hal_plot_led(TYPEPAD, POLY_PAD_NOTE, MAXLED / 2, MAXLED / 2, MAXLED / 2); | 862 | DRAW(POLY_PAD_NOTE, GREY); |
868 | draw_kbd(0, colors[0]); | 863 | draw_kbd(0, PURPLE); |
869 | draw_kbd(2, colors[1]); | 864 | draw_kbd(2, PURPLE); |
870 | draw_kbd(4, colors[2]); | 865 | draw_kbd(4, PURPLE); |
871 | draw_kbd(6, colors[3]); | 866 | draw_kbd(6, PURPLE); |
872 | } | 867 | } |
873 | 868 | ||
874 | void | 869 | void |
@@ -908,6 +903,7 @@ app_init(const u16 *adc_raw) { | |||
908 | .ch_listen = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, | 903 | .ch_listen = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, |
909 | .mode = MOD_POLY_MAIN, | 904 | .mode = MOD_POLY_MAIN, |
910 | .kbd_octave = 0, | 905 | .kbd_octave = 0, |
906 | .kbd_root = 0, | ||
911 | }; | 907 | }; |
912 | } | 908 | } |
913 | 909 | ||