implement five key piano

This commit is contained in:
twobit 2013-09-04 01:27:50 +02:00
parent 0d10ffb67e
commit 329a153a2c

View File

@ -1,6 +1,7 @@
#include <pentabug/app.h> #include <pentabug/app.h>
#include <pentabug/pentatonic.h> #include <pentabug/pentatonic.h>
#include <pentabug/hal.h> #include <pentabug/hal.h>
#include <pentabug/music.h>
static void init(void) { static void init(void) {
pentatonic_direction(ALL_IN); pentatonic_direction(ALL_IN);
@ -9,21 +10,18 @@ static void init(void) {
static void run(void) { static void run(void) {
pentatonic_direction(ALL_IN); pentatonic_direction(ALL_IN);
uint8_t prev_buttons = 0;
for(;;) { for(;;) {
uint8_t buttons = pentatonic_buttons(); uint8_t buttons = pentatonic_buttons();
if (prev_buttons != buttons) {
if(buttons) { if (buttons & 16) set_note(NOTE_Db, 4);
pentatonic_direction(ALL_OUT); else if (buttons & 8) set_note(NOTE_Eb, 4);
else if (buttons & 4) set_note(NOTE_Gb, 4);
pentatonic_all_led_set(buttons); else if (buttons & 2) set_note(NOTE_Ab, 4);
else if (buttons & 1) set_note(NOTE_Bb, 4);
led_inv(RIGHT); else stop_note();
prev_buttons = buttons;
wait_ms(1000);
break;
} }
wait_ms(1); wait_ms(1);
} }
} }