From 329a153a2c2971968095b5299e7183b1abd7d656 Mon Sep 17 00:00:00 2001 From: twobit Date: Wed, 4 Sep 2013 01:27:50 +0200 Subject: [PATCH] implement five key piano --- firmware/apps/tonictest.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/firmware/apps/tonictest.c b/firmware/apps/tonictest.c index bde21f1..a94fa9e 100644 --- a/firmware/apps/tonictest.c +++ b/firmware/apps/tonictest.c @@ -1,6 +1,7 @@ #include #include #include +#include static void init(void) { pentatonic_direction(ALL_IN); @@ -9,21 +10,18 @@ static void init(void) { static void run(void) { pentatonic_direction(ALL_IN); + uint8_t prev_buttons = 0; for(;;) { uint8_t buttons = pentatonic_buttons(); - - if(buttons) { - pentatonic_direction(ALL_OUT); - - pentatonic_all_led_set(buttons); - - led_inv(RIGHT); - - wait_ms(1000); - - break; + if (prev_buttons != buttons) { + if (buttons & 16) set_note(NOTE_Db, 4); + else if (buttons & 8) set_note(NOTE_Eb, 4); + else if (buttons & 4) set_note(NOTE_Gb, 4); + else if (buttons & 2) set_note(NOTE_Ab, 4); + else if (buttons & 1) set_note(NOTE_Bb, 4); + else stop_note(); + prev_buttons = buttons; } - wait_ms(1); } }