UI implementation.

pull/3/head
Holger Wirtz 5 years ago
parent 3599442a2c
commit e6f79d3254
  1. 66
      MicroDexed.ino
  2. 155
      UI.hpp
  3. 7
      config.h

@ -30,14 +30,12 @@
#include <SD.h>
#include <MIDI.h>
#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>
#include <LCDMenuLib2.h>
#include "UI.hpp"
#include "EEPROMAnything.h"
#include "midi_devices.hpp"
#include "dexed.h"
#include "dexed_sysex.h"
#include "PluginFx.h"
#include "UI.hpp"
AudioPlayQueue queue1;
AudioAnalyzePeak peak1;
@ -108,17 +106,49 @@ value_change_t soften_volume = {0.0, 0};
value_change_t soften_filter_res = {0.0, 0};
value_change_t soften_filter_cut = {0.0, 0};
#ifdef ENABLE_LCD_UI
/***********************************************************************
LCDMenuLib2
***********************************************************************/
extern LiquidCrystal_I2C lcd;
extern LCDMenuLib2 LCDML;
#endif
void setup()
{
//while (!Serial) ; // wait for Arduino Serial Monitor
Serial.begin(SERIAL_SPEED);
#ifdef ENABLE_LCD_UI
// LCD Begin
lcd.init();
lcd.backlight();
lcd.clear();
lcd.blink_off();
lcd.cursor_off();
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("MicroDexed");
lcd.setCursor(0, 1);
lcd.print("(c)parasiTstudio");
// set special chars for scrollbar
lcd.createChar(0, (uint8_t*)scroll_bar[0]);
lcd.createChar(1, (uint8_t*)scroll_bar[1]);
lcd.createChar(2, (uint8_t*)scroll_bar[2]);
lcd.createChar(3, (uint8_t*)scroll_bar[3]);
lcd.createChar(4, (uint8_t*)scroll_bar[4]);
// LCDMenuLib Setup
LCDML_setup(_LCDML_DISP_cnt);
// Enable Menu Rollover
LCDML.MENU_enRollover();
// Enable Screensaver (screensaver menu function, time to activate in ms)
LCDML.SCREEN_enable(UI_func_screensaver, 10000); // set to 10 seconds
#else
Serial.println(F("NO LCD DISPLAY ENABLED!"));
#endif
delay(220);
Serial.println(F("MicroDexed based on https://github.com/asb2m10/dexed"));
@ -257,33 +287,6 @@ void setup()
AudioInterrupts();
// LCD Begin
lcd.init();
lcd.backlight();
lcd.clear();
lcd.blink_off();
lcd.cursor_off();
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("MicroDexed");
lcd.setCursor(0, 1);
lcd.print("(c)parasiTstudio");
delay(1000);
// set special chars for scrollbar
lcd.createChar(0, (uint8_t*)scroll_bar[0]);
lcd.createChar(1, (uint8_t*)scroll_bar[1]);
lcd.createChar(2, (uint8_t*)scroll_bar[2]);
lcd.createChar(3, (uint8_t*)scroll_bar[3]);
lcd.createChar(4, (uint8_t*)scroll_bar[4]);
// LCDMenuLib Setup
LCDML_setup(_LCDML_DISP_cnt);
// Enable Menu Rollover
LCDML.MENU_enRollover();
// Enable Screensaver (screensaver menu function, time to activate in ms)
LCDML.SCREEN_enable(UI_func_screensaver, 10000); // set to 10 seconds
Serial.println(F("<setup end>"));
}
@ -332,9 +335,10 @@ void loop()
// CONTROL-RATE-EVENT-HANDLING
if (control_rate > CONTROL_RATE_MS)
{
#ifdef ENABLE_LCD_UI
// LCD Menu
LCDML.loop();
#endif
control_rate = 0;
// Shutdown unused voices

155
UI.hpp

@ -22,15 +22,16 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef ENABLE_LCD_UI
#ifndef _UI_HPP_
#define _UI_HPP_
#include <LiquidCrystal_I2C.h>
#include <LCDMenuLib2.h>
#include "Arduino.h"
#include "config.h"
#define _LCDML_DISP_cols 16
#define _LCDML_DISP_rows 2
#define _LCDML_DISP_cols LCD_cols
#define _LCDML_DISP_rows LCD_rows
#define _LCDML_DISP_cfg_cursor 0x7E // cursor Symbol
#define _LCDML_DISP_cfg_scrollbar 1 // enable a scrollbar
@ -51,9 +52,18 @@ const uint8_t scroll_bar[5][8] = {
void lcdml_menu_display(void);
void lcdml_menu_clear(void);
void lcdml_menu_control(void);
void UI_func_information(uint8_t param);
void UI_func_screensaver(uint8_t param);
void UI_func_test(uint8_t param);
void UI_func_sound(uint8_t param);
void UI_func_reverb_roomsize(uint8_t param);
void UI_func_reverb_damping(uint8_t param);
void UI_func_reverb_level(uint8_t param);
void UI_func_chorus_frequency(uint8_t param);
void UI_func_chorus_depth(uint8_t param);
void UI_func_chorus_level(uint8_t param);
void UI_func_delay_time(uint8_t param);
void UI_func_delay_feedback(uint8_t param);
void UI_func_delay_level(uint8_t param);
void UI_func_filter_cutoff(uint8_t param);
void UI_func_filter_resonance(uint8_t param);
void UI_func_back(uint8_t param);
void UI_func_goToRootMenu(uint8_t param);
@ -61,10 +71,28 @@ LCDMenuLib2_menu LCDML_0(255, 0, 0, NULL, NULL); // root menu element (do not ch
LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control);
// LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function)
LCDML_add(0, LCDML_0, 1, "Information", UI_func_information);
LCDML_add(1, LCDML_0, 2, "Test", UI_func_test);
LCDML_add(2, LCDML_0, 3, "Screensaver", UI_func_screensaver);
#define _LCDML_DISP_cnt 2
LCDML_add(0, LCDML_0, 1, "Sound", UI_func_sound);
LCDML_add(1, LCDML_0, 2, "Effect", NULL);
LCDML_add(2, LCDML_0_2, 1, "Reverb", NULL);
LCDML_add(3, LCDML_0_2_1, 1, "Roomsize", UI_func_reverb_roomsize);
LCDML_add(4, LCDML_0_2_1, 2, "Damping", UI_func_reverb_damping);
LCDML_add(5, LCDML_0_2_1, 3, "Level", UI_func_reverb_level);
LCDML_add(6, LCDML_0_2, 2, "Chorus", NULL);
LCDML_add(7, LCDML_0_2_2, 1, "Frequency", UI_func_chorus_frequency);
LCDML_add(8, LCDML_0_2_2, 2, "Depth", UI_func_chorus_depth);
LCDML_add(9, LCDML_0_2_2, 3, "Level", UI_func_chorus_level);
LCDML_add(10, LCDML_0_2, 3, "Delay", NULL);
LCDML_add(11, LCDML_0_2_3, 1, "Time", UI_func_delay_time);
LCDML_add(12, LCDML_0_2_3, 2, "Feedback", UI_func_delay_feedback);
LCDML_add(13, LCDML_0_2_3, 3, "Level", UI_func_delay_level);
LCDML_add(14, LCDML_0_2, 4, "Filter", NULL);
LCDML_add(15, LCDML_0_2_4, 1, "Cutoff", UI_func_filter_cutoff);
LCDML_add(16, LCDML_0_2_4, 2, "Resonance", UI_func_filter_resonance);
LCDML_add(17, LCDML_0, 3, "Store", NULL);
LCDML_add(18, LCDML_0, 4, "System", NULL);
LCDML_add(19, LCDML_0, 5, "Info", NULL);
#define _LCDML_DISP_cnt 19
// create menu
LCDML_createMenu(_LCDML_DISP_cnt);
@ -276,21 +304,19 @@ void lcdml_menu_display(void)
/***********************************************************************
MENU
***********************************************************************/
void UI_func_information(uint8_t param)
void UI_func_sound(uint8_t param)
{
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// setup function
lcd.setCursor(0, 0);
lcd.print(F("MicroDexed"));
lcd.print(F("Filter Res."));
lcd.setCursor(0, 1);
lcd.print(F("LCDMenuLib2"));
lcd.print(F("<valua>"));
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
{
// loop function, can be run in a loop when LCDML_DISP_triggerMenu(xx) is set
// the quit button works in every DISP function without any checks; it starts the loop_end function
if (LCDML.BT_checkAny()) { // check if any button is pressed (enter, up, down, left, right)
// LCDML_goToMenu stops a running menu function and goes to the menu
LCDML.FUNC_goBackToMenu();
@ -303,42 +329,97 @@ void UI_func_information(uint8_t param)
}
}
void UI_func_screensaver(uint8_t param)
void UI_func_reverb_roomsize(uint8_t param)
{
if (LCDML.FUNC_setup()) // ****** SETUP *********
;
}
void UI_func_reverb_damping(uint8_t param)
{
// update LCD content
lcd.setCursor(0, 0); // set cursor
lcd.print("screensaver"); // print change content
lcd.setCursor(0, 1); // set cursor
lcd.print("press any key");
LCDML.FUNC_setLoopInterval(100); // starts a trigger event for the loop function every 100 milliseconds
;
}
if (LCDML.FUNC_loop())
void UI_func_reverb_level(uint8_t param)
{
if (LCDML.BT_checkAny()) // check if any button is pressed (enter, up, down, left, right)
;
}
void UI_func_chorus_frequency(uint8_t param)
{
LCDML.FUNC_goBackToMenu(); // leave this function
;
}
void UI_func_chorus_depth(uint8_t param)
{
;
}
if (LCDML.FUNC_close())
void UI_func_chorus_level(uint8_t param)
{
// The screensaver go to the root menu
LCDML.MENU_goRoot();
;
}
void UI_func_delay_time(uint8_t param)
{
;
}
void UI_func_test(uint8_t param)
void UI_func_delay_feedback(uint8_t param)
{
;
}
void UI_func_delay_level(uint8_t param)
{
;
}
void UI_func_filter_cutoff(uint8_t param)
{
;
}
void UI_func_filter_resonance(uint8_t param)
{
;
}
void UI_func_information(uint8_t param)
{
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// setup function
lcd.setCursor(0, 0);
lcd.print(F("MicroDexed"));
lcd.setCursor(0, 1);
lcd.print(F("LCDMenuLib2"));
}
if (LCDML.FUNC_loop()) // ****** LOOP *********
{
// loop function, can be run in a loop when LCDML_DISP_triggerMenu(xx) is set
// the quit button works in every DISP function without any checks; it starts the loop_end function
if (LCDML.BT_checkAny()) { // check if any button is pressed (enter, up, down, left, right)
// LCDML_goToMenu stops a running menu function and goes to the menu
LCDML.FUNC_goBackToMenu();
}
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
// you can here reset some global vars or do nothing
}
}
void UI_func_screensaver(uint8_t param)
{
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// update LCD content
lcd.setCursor(0, 0); // set cursor
lcd.print("TEST"); // print change content
lcd.print("screensaver"); // print change content
lcd.setCursor(0, 1); // set cursor
lcd.print("TEST123");
lcd.print("press any key");
LCDML.FUNC_setLoopInterval(100); // starts a trigger event for the loop function every 100 milliseconds
}
@ -357,15 +438,6 @@ void UI_func_test(uint8_t param)
}
}
/*void UI_func_back(uint8_t param)
{
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// end function and go an layer back
LCDML.FUNC_goBackToMenu(1); // leave this function and go a layer back
}
}*/
void UI_func_goToRootMenu(uint8_t param)
{
if (LCDML.FUNC_setup()) // ****** SETUP *********
@ -376,3 +448,4 @@ void UI_func_goToRootMenu(uint8_t param)
}
#endif
#endif

@ -99,9 +99,12 @@
#define SOFTEN_VALUE_CHANGE_STEPS 20
//*************************************************************************************************
//* UI AND DATA-STORE SETTINGS
//* UI
//*************************************************************************************************
#define CONTROL_RATE_MS 10
#define ENABLE_LCD_UI 1
#define LCD_cols 16
#define LCD_rows 2
#define CONTROL_RATE_MS 50
//*************************************************************************************************
//* DEBUG OUTPUT SETTINGS

Loading…
Cancel
Save