From 938bc40e71919968fb1c9c73d0cc1634371a43fb Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Mon, 11 May 2020 09:55:52 +0200 Subject: [PATCH] Added voice selection code for dual instance. --- UI.hpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 6 deletions(-) diff --git a/UI.hpp b/UI.hpp index c587dbe..e8cc13b 100644 --- a/UI.hpp +++ b/UI.hpp @@ -139,7 +139,14 @@ const uint8_t meter_bar[5][8] = { {B00001, B00001, B00001, B00001, B00001, B00001, B00001, B00001} }; -enum { SCROLLBAR, BLOCKBAR, METERBAR }; +const uint8_t inverse_num[4][8] = { + {B11111, B11011, B10011, B11011, B11011, B11011, B10001, B11111}, + {B11111, B11011, B10101, B11101, B11011, B10111, B10001, B11111}, + {B00000, B00100, B01100, B00100, B00100, B00100, B01110, B00000}, + {B00000, B00100, B01010, B00010, B00100, B01000, B01110, B00000} +}; + +enum { SCROLLBAR, BLOCKBAR, METERBAR, INVERSE_NUM }; enum { ENC_R, ENC_L }; enum {MENU_VOICE_BANK, MENU_VOICE_SOUND}; uint8_t menu_voice_select = MENU_VOICE_SOUND; @@ -388,6 +395,8 @@ bool menu_init = true; #ifdef U8X8_DISPLAY const uint8_t * flipped_scroll_bar[5]; const uint8_t * flipped_block_bar[5]; +const uint8_t * flipped_meter_bar[5]; +const uint8_t * flipped_inverse_num[4]; uint8_t * rotTile(const uint8_t * tile) { @@ -3298,16 +3307,20 @@ void UI_func_eeprom_reset(uint8_t param) void UI_func_voice_select(uint8_t param) { - uint8_t instance_id = 0; + static uint8_t instance_id = 0; static uint8_t menu_voice_select = MENU_VOICE_SOUND; - if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2) - instance_id = 1; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { + lcd_special_chars(INVERSE_NUM); + encoderDir[ENC_R].reset(); + if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2) + instance_id = 1; + else + instance_id = 0; + char bank_name[BANK_NAME_LEN]; char voice_name[VOICE_NAME_LEN]; @@ -3321,6 +3334,19 @@ void UI_func_voice_select(uint8_t param) lcd.show(0, 4, 10, bank_name); lcd.show(1, 4, 10, voice_name); +#if NUM_DEXED > 1 + lcd.setCursor(15, 0); + if (instance_id == 0) + lcd.write(instance_id); + else + lcd.write(2); + lcd.setCursor(15, 1); + if (instance_id == 1) + lcd.write(instance_id); + else + lcd.write(3); +#endif + switch (menu_voice_select) { case MENU_VOICE_BANK: @@ -3431,6 +3457,7 @@ void UI_func_voice_select(uint8_t param) break; } } +#if NUM_DEXED == 1 else if (LCDML.BT_checkEnter()) { if (menu_voice_select == MENU_VOICE_BANK) @@ -3438,6 +3465,42 @@ void UI_func_voice_select(uint8_t param) else menu_voice_select = MENU_VOICE_BANK; } +#else + else if (LCDML.BT_checkEnter()) + { + if (menu_voice_select == MENU_VOICE_BANK) + { + menu_voice_select = MENU_VOICE_SOUND; + instance_id = !instance_id; + + char bank_name[BANK_NAME_LEN]; + char voice_name[VOICE_NAME_LEN]; + + if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) + strncpy(bank_name, "*ERROR*", sizeof(bank_name)); + if (!get_voice_by_bank_name(configuration.performance.bank[instance_id], bank_name, configuration.performance.voice[instance_id], voice_name, sizeof(voice_name))) + strncpy(voice_name, "*ERROR*", sizeof(voice_name)); + + lcd.show(0, 0, 2, configuration.performance.bank[instance_id]); + lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1); + lcd.show(0, 4, 10, bank_name); + lcd.show(1, 4, 10, voice_name); + + lcd.setCursor(15, 0); + if (instance_id == 0) + lcd.write(instance_id); + else + lcd.write(2); + lcd.setCursor(15, 1); + if (instance_id == 1) + lcd.write(instance_id); + else + lcd.write(3); + } + else + menu_voice_select = MENU_VOICE_BANK; + } +#endif } if (strlen(g_bank_name[instance_id]) > 0) @@ -3484,6 +3547,8 @@ void UI_func_voice_select(uint8_t param) if (LCDML.FUNC_close()) // ****** STABLE END ********* { + lcd_special_chars(SCROLLBAR); + encoderDir[ENC_R].reset(); if (instance_id == 0) { @@ -4729,7 +4794,18 @@ void lcd_special_chars(uint8_t mode) #ifdef I2C_DISPLAY lcd.createChar(i, (uint8_t*)meter_bar[i]); #else - flipped_block_bar[i] = rotTile(meter_bar[i]); + flipped_meter_bar[i] = rotTile(meter_bar[i]); +#endif + } + break; + case INVERSE_NUM: + // set special chars for volumebar + for (uint8_t i = 0; i < 4; i++) + { +#ifdef I2C_DISPLAY + lcd.createChar(i, (uint8_t*)inverse_num[i]); +#else + flipped_inverse_num[i] = rotTile(inverse_num[i]); #endif } break;