From b5c418c10b0599922028bff0dfae4bd5eef082fd Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Mon, 6 May 2019 15:43:55 +0200 Subject: [PATCH] Fixing not working buttons. --- MicroMDAEPiano.ino | 17 ++++++++++------- UI.hpp | 20 +++++++++++++++----- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/MicroMDAEPiano.ino b/MicroMDAEPiano.ino index db70e21..90bf4db 100644 --- a/MicroMDAEPiano.ino +++ b/MicroMDAEPiano.ino @@ -119,14 +119,17 @@ void setup() { //while (!Serial) ; // wait for Arduino Serial Monitor + pinMode(BUT_L_PIN, INPUT_PULLUP); + pinMode(BUT_R_PIN, INPUT_PULLUP); + menu_init(); - + lcd.clear(); - lcd.setCursor(1,0); + lcd.setCursor(1, 0); lcd.print(F("MicroMDAEpiano")); - lcd.setCursor(0,1); + lcd.setCursor(0, 1); lcd.print(F("(c)parasiTstudio")); - + Serial.begin(SERIAL_SPEED); delay(500); @@ -233,7 +236,7 @@ void setup() menu_system.update(); menu_system.switch_focus(); - + #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) show_cpu_and_mem_usage(); cpu_mem_millis = 0; @@ -454,8 +457,8 @@ void set_volume(float v, float p) #endif // http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html - mixer_r.gain(0,sinf(p * PI / 2)); - mixer_l.gain(0,cosf(p * PI / 2)); + mixer_r.gain(0, sinf(p * PI / 2)); + mixer_l.gain(0, cosf(p * PI / 2)); } /****************************************************************************** diff --git a/UI.hpp b/UI.hpp index 0215a80..95031ae 100644 --- a/UI.hpp +++ b/UI.hpp @@ -36,6 +36,8 @@ extern Bounce but[2]; // Global vars uint8_t main_menu_selector = 0; +enum { BUT_L, BUT_R }; + // Main menu const char text10[] PROGMEM = "Favorites "; const char text11[] PROGMEM = "Sound "; @@ -60,8 +62,14 @@ LiquidLine sound_line4(0, 1, text23); LiquidScreen sound_screen(sound_line1, sound_line2, sound_line3, sound_line4); LiquidMenu sound_menu(lcd, sound_screen); +// Info menu +const char text40[] PROGMEM = "INFO "; +LiquidLine info_line1(0, 0, text40); +LiquidScreen info_screen(info_line1); +LiquidMenu info_menu(lcd, info_screen); + // System menu -LiquidSystem menu_system(main_menu, sound_menu); +LiquidSystem menu_system(main_menu, sound_menu, info_menu); void callback_favorites_function() { Serial.println(F("callback_favorites_function")); @@ -122,11 +130,13 @@ void handle_ui(void) switch (i) { - case 1: - if (but[i].risingEdge() || but[i].fallingEdge()) + case BUT_R: // SELECT + if (but[i].fallingEdge()) { - Serial.println(F("B0")); - main_menu.switch_focus(); +#ifdef DEBUG + Serial.println(F("SELECT-R")); +#endif + menu_system.next_screen(); } break; }