You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
3.7 KiB
146 lines
3.7 KiB
6 years ago
|
/*
|
||
|
MicroMDAEPiano
|
||
|
|
||
|
MicroMDAEPiano is a port of the MDA-EPiano sound engine
|
||
|
(https://sourceforge.net/projects/mda-vst/) for the Teensy-3.5/3.6 with audio shield.
|
||
|
|
||
|
(c)2019 H. Wirtz <wirtz@parasitstudio.de>
|
||
|
|
||
|
This program is free software; you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation; either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this program; if not, write to the Free Software Foundation,
|
||
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
|
*/
|
||
|
|
||
|
#ifndef UI_HPP_INCLUDED
|
||
|
#define UI_HPP_INCLUDED
|
||
|
|
||
|
#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];
|
||
|
|
||
|
// 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 ";
|
||
|
const char text12[] PROGMEM = "Store ";
|
||
|
const char text13[] PROGMEM = "Info ";
|
||
|
LiquidLine main_line1(0, 0, text10);
|
||
|
LiquidLine main_line2(0, 1, text11);
|
||
|
LiquidLine main_line3(0, 1, text12);
|
||
|
LiquidLine main_line4(0, 1, text13);
|
||
|
LiquidScreen main_screen;
|
||
|
LiquidMenu main_menu(lcd);
|
||
|
|
||
|
// Sound menu
|
||
|
const char text20[] PROGMEM = "Decay ";
|
||
|
const char text21[] PROGMEM = "Release ";
|
||
|
const char text22[] PROGMEM = "Hardness ";
|
||
|
const char text23[] PROGMEM = "Treble ";
|
||
|
LiquidLine sound_line1(0, 0, text20);
|
||
|
LiquidLine sound_line2(0, 1, text21);
|
||
|
LiquidLine sound_line3(0, 1, text22);
|
||
|
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, info_menu);
|
||
|
|
||
|
void callback_favorites_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)
|
||
|
{
|
||
|
uint8_t i;
|
||
|
|
||
|
// LCD display setup
|
||
|
lcd.init();
|
||
|
lcd.blink_off();
|
||
|
lcd.cursor_off();
|
||
|
lcd.backlight();
|
||
|
//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);
|
||
|
|
||
|
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 BUT_R: // SELECT
|
||
|
if (but[i].fallingEdge())
|
||
|
{
|
||
|
#ifdef DEBUG
|
||
|
Serial.println(F("SELECT-R"));
|
||
|
#endif
|
||
|
menu_system.next_screen();
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endif
|