Several additions for LiquidMenu structures.

master
Holger Wirtz 6 years ago
parent 36cdb13133
commit f439470d01
  1. 14
      MicroMDAEPiano.ino
  2. 88
      UI.hpp

@ -91,7 +91,6 @@ AudioConnection patchCord13(volume_l, 0, pt8211_1, 0);
mdaEPiano* ep; mdaEPiano* ep;
LiquidCrystal_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES); LiquidCrystal_I2C lcd(LCD_I2C_ADDRESS, LCD_CHARS, LCD_LINES);
Encoder4 enc[2] = {Encoder4(ENC_L_PIN_A, ENC_L_PIN_B), Encoder4(ENC_R_PIN_A, ENC_R_PIN_B)}; Encoder4 enc[2] = {Encoder4(ENC_L_PIN_A, ENC_L_PIN_B), Encoder4(ENC_R_PIN_A, ENC_R_PIN_B)};
int32_t enc_val[2] = {INITIAL_ENC_L_VALUE, INITIAL_ENC_R_VALUE};
Bounce but[2] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)}; Bounce but[2] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)};
// Variables // Variables
@ -122,16 +121,18 @@ void setup()
menu_init(); menu_init();
lcd.clear();
lcd.setCursor(1,0);
lcd.print(F("MicroMDAEpiano"));
lcd.setCursor(0,1);
lcd.print(F("(c)parasiTstudio"));
Serial.begin(SERIAL_SPEED); Serial.begin(SERIAL_SPEED);
delay(500); delay(500);
// Encoder setup // Encoder setup
enc[0].write(INITIAL_ENC_L_VALUE); enc[0].write(INITIAL_ENC_L_VALUE);
enc_val[0] = enc[0].read();
enc[1].write(INITIAL_ENC_R_VALUE); enc[1].write(INITIAL_ENC_R_VALUE);
enc_val[1] = enc[1].read();
but[0].update();
but[1].update();
// Debug output // Debug output
Serial.println(F("MicroMDAEPiano based on https://sourceforge.net/projects/mda-vst")); Serial.println(F("MicroMDAEPiano based on https://sourceforge.net/projects/mda-vst"));
@ -230,7 +231,6 @@ void setup()
Serial.println(F("<setup end>")); Serial.println(F("<setup end>"));
menu_system.next_screen();
menu_system.update(); menu_system.update();
menu_system.switch_focus(); menu_system.switch_focus();
@ -301,6 +301,8 @@ void loop()
if (control_rate > CONTROL_RATE_MS) if (control_rate > CONTROL_RATE_MS)
{ {
control_rate = 0; control_rate = 0;
handle_ui();
} }
} }

@ -21,21 +21,20 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#ifndef UI_HPP_INCLUDED #ifndef UI_HPP_INCLUDED
#define UI_HPP_INCLUDED #define UI_HPP_INCLUDED
extern LiquidCrystal_I2C lcd; #include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <Bounce.h>
#include "Encoder4.h"
extern LiquidCrystal_I2C lcd;
extern Encoder4 enc[2];
extern Bounce but[2];
// Welcome screen // Global vars
const char text00[] PROGMEM = "MicroMDAEPiano"; uint8_t main_menu_selector = 0;
const char text01[] PROGMEM = "(c)parasiTstudio";
LiquidLine welcome_line1(1, 0, text00);
LiquidLine welcome_line2(0, 1, text01);
LiquidScreen welcome_screen(welcome_line1, welcome_line2);
// Main menu // Main menu
const char text10[] PROGMEM = "Favorites "; const char text10[] PROGMEM = "Favorites ";
@ -44,8 +43,10 @@ const char text12[] PROGMEM = "Store ";
const char text13[] PROGMEM = "Info "; const char text13[] PROGMEM = "Info ";
LiquidLine main_line1(0, 0, text10); LiquidLine main_line1(0, 0, text10);
LiquidLine main_line2(0, 1, text11); LiquidLine main_line2(0, 1, text11);
LiquidScreen main_screen(main_line1, main_line2); LiquidLine main_line3(0, 1, text12);
LiquidMenu main_menu(lcd,welcome_screen,main_screen,1); LiquidLine main_line4(0, 1, text13);
LiquidScreen main_screen;
LiquidMenu main_menu(lcd);
// Sound menu // Sound menu
const char text20[] PROGMEM = "Decay "; const char text20[] PROGMEM = "Decay ";
@ -57,27 +58,78 @@ LiquidLine sound_line2(0, 1, text21);
LiquidLine sound_line3(0, 1, text22); LiquidLine sound_line3(0, 1, text22);
LiquidLine sound_line4(0, 1, text23); LiquidLine sound_line4(0, 1, text23);
LiquidScreen sound_screen(sound_line1, sound_line2, sound_line3, sound_line4); LiquidScreen sound_screen(sound_line1, sound_line2, sound_line3, sound_line4);
LiquidMenu sound_menu(lcd,sound_screen); LiquidMenu sound_menu(lcd, sound_screen);
// System menu // System menu
LiquidSystem menu_system(main_menu, sound_menu); LiquidSystem menu_system(main_menu, sound_menu);
void callback_main_function() { void callback_favorites_function() {
Serial.println(F("You called the main callback function.")); Serial.println(F("callback_favorites_function"));
}
void callback_sound_function() {
Serial.println(F("callback_sound_function"));
}
void callback_store_function() {
Serial.println(F("callback_store_function"));
}
void callback_info_function() {
Serial.println(F("callback_info_function"));
} }
void menu_init(void) void menu_init(void)
{ {
uint8_t i;
// LCD display setup // LCD display setup
lcd.init(); lcd.init();
lcd.blink_off(); lcd.blink_off();
lcd.cursor_off(); lcd.cursor_off();
lcd.backlight(); lcd.backlight();
lcd.noAutoscroll(); //lcd.noAutoscroll();
main_screen.add_line(main_line1);
main_screen.add_line(main_line2);
main_screen.add_line(main_line3);
main_screen.add_line(main_line4);
main_line1.attach_function(1, callback_favorites_function);
main_line2.attach_function(2, callback_sound_function);
main_line3.attach_function(3, callback_store_function);
main_line4.attach_function(4, callback_info_function);
main_screen.set_displayLineCount(2);
main_menu.add_screen(main_screen);
main_line1.attach_function(1, callback_main_function);
menu_system.update(); menu_system.update();
for (i = 0; i < NUM_ENCODER; i++)
but[i].update();
enc[1].write(0, 0, 99);
enc[1].write(1, 0, 4);
} }
void handle_ui(void)
{
uint8_t i;
for (i = 0; i < NUM_ENCODER; i++)
{
but[i].update();
switch (i)
{
case 1:
if (but[i].risingEdge() || but[i].fallingEdge())
{
Serial.println(F("B0"));
main_menu.switch_focus();
}
break;
}
}
}
#endif #endif

Loading…
Cancel
Save