|
|
|
@ -73,7 +73,7 @@ extern void eeprom_update(void); |
|
|
|
|
#if NUM_DRUMS > 0 |
|
|
|
|
#include "midinotes.h" |
|
|
|
|
#include "drumset.h" |
|
|
|
|
extern void get_sd_performance_name_json(uint8_t number); |
|
|
|
|
extern void get_sd_performance_name_json(uint8_t number,char* name, uint8_t len); |
|
|
|
|
extern bool save_sd_performance_json(uint8_t p); |
|
|
|
|
extern uint8_t drum_midi_channel; |
|
|
|
|
//extern drum_config_t drum_config[NUM_DRUMSET_CONFIG];
|
|
|
|
@ -4601,9 +4601,10 @@ void UI_func_save_performance(uint8_t param) { |
|
|
|
|
else |
|
|
|
|
overwrite = false; |
|
|
|
|
if (check_sd_performance_exists(temp_int)) { |
|
|
|
|
get_sd_performance_name_json(temp_int); |
|
|
|
|
if (configuration.performance.name[0] != 0) |
|
|
|
|
display.show(1, 5, 11, configuration.performance.name); |
|
|
|
|
char tmp_confname[PERFORMANCE_NAME_LEN]; |
|
|
|
|
get_sd_performance_name_json(temp_int, tmp_confname, sizeof(tmp_confname)); |
|
|
|
|
if (tmp_confname[0] != 0) |
|
|
|
|
display.show(1, 5, 11, tmp_confname); |
|
|
|
|
else |
|
|
|
|
display.print("-- DATA -- "); |
|
|
|
|
} else |
|
|
|
@ -4659,11 +4660,14 @@ void UI_func_save_performance(uint8_t param) { |
|
|
|
|
if (overwrite == false) { |
|
|
|
|
display.print("-- EMPTY --"); |
|
|
|
|
} else if (check_sd_performance_exists(temp_int)) { |
|
|
|
|
get_sd_performance_name_json(temp_int); |
|
|
|
|
if (configuration.performance.name[0] != 0) |
|
|
|
|
display.show(1, 5, 11, configuration.performance.name); |
|
|
|
|
else display.print("-- DATA -- "); |
|
|
|
|
} else display.print("-- EMPTY --"); |
|
|
|
|
char tmp_confname[PERFORMANCE_NAME_LEN]; |
|
|
|
|
get_sd_performance_name_json(temp_int, tmp_confname, sizeof(tmp_confname)); |
|
|
|
|
if (tmp_confname[0] != 0) |
|
|
|
|
display.show(1, 5, 11, tmp_confname); |
|
|
|
|
else |
|
|
|
|
display.print("-- DATA -- "); |
|
|
|
|
} else |
|
|
|
|
display.print("-- EMPTY --"); |
|
|
|
|
} else if (mode < 0xff) { |
|
|
|
|
display.setCursor(12, 1); |
|
|
|
|
if (yesno == true) { |
|
|
|
@ -4672,7 +4676,6 @@ void UI_func_save_performance(uint8_t param) { |
|
|
|
|
display.print(F("NO ")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//encoderDir[ENC_R].reset();
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (LCDML.FUNC_close()) // ****** STABLE END *********
|
|
|
|
@ -4703,7 +4706,7 @@ void UI_func_load_performance(uint8_t param) { |
|
|
|
|
snprintf_P(tmp, sizeof(tmp), PSTR("[%2d]"), temp_int); |
|
|
|
|
display.print(tmp); |
|
|
|
|
if (check_sd_performance_exists(temp_int)) { |
|
|
|
|
get_sd_performance_name_json(temp_int); |
|
|
|
|
get_sd_performance_name_json(temp_int, configuration.performance.name, sizeof(configuration.performance.name)); |
|
|
|
|
if (configuration.performance.name[0] != 0) |
|
|
|
|
display.show(1, 5, 11, configuration.performance.name); |
|
|
|
|
else |
|
|
|
@ -4736,7 +4739,7 @@ void UI_func_load_performance(uint8_t param) { |
|
|
|
|
snprintf_P(tmp, sizeof(tmp), PSTR("[%2d]"), temp_int); |
|
|
|
|
display.print(tmp); |
|
|
|
|
if (check_sd_performance_exists(temp_int)) { |
|
|
|
|
get_sd_performance_name_json(temp_int); |
|
|
|
|
get_sd_performance_name_json(temp_int, configuration.performance.name, sizeof(configuration.performance.name)); |
|
|
|
|
if (configuration.performance.name[0] != 0) |
|
|
|
|
display.show(1, 5, 11, configuration.performance.name); |
|
|
|
|
else |
|
|
|
@ -5528,21 +5531,31 @@ void UI_func_set_performance_name(uint8_t param) { |
|
|
|
|
mode = 0; |
|
|
|
|
display.setCursor(0, 0); |
|
|
|
|
display.print(F("Perf. Name")); |
|
|
|
|
|
|
|
|
|
bool found = false; |
|
|
|
|
for (uint8_t i = 0; i < sizeof(configuration.performance.name) - 1; i++) { |
|
|
|
|
if (configuration.performance.name[i] == 0 && found == false) |
|
|
|
|
found = true; |
|
|
|
|
if (found == true) { |
|
|
|
|
configuration.performance.name[i] = ' '; |
|
|
|
|
configuration.performance.name[i + 1] = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (LCDML.FUNC_loop()) // ****** LOOP *********
|
|
|
|
|
{ |
|
|
|
|
if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) { |
|
|
|
|
if (LCDML.BT_checkDown()) { |
|
|
|
|
if (mode == 1) ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, PERFORMANCE_NAME_LEN - 1, false); |
|
|
|
|
if (mode == 1) ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, sizeof(configuration.performance.name), false); |
|
|
|
|
} else if (LCDML.BT_checkUp()) { |
|
|
|
|
if (mode == 1) ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, PERFORMANCE_NAME_LEN - 1, false); |
|
|
|
|
if (mode == 1) ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, sizeof(configuration.performance.name), false); |
|
|
|
|
} |
|
|
|
|
} else if (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort()) { |
|
|
|
|
|
|
|
|
|
if (mode == 1) { |
|
|
|
|
ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, PERFORMANCE_NAME_LEN - 1, false); |
|
|
|
|
ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, sizeof(configuration.performance.name), false); |
|
|
|
|
if (ui_select_name_state == true) { |
|
|
|
|
strlcpy(configuration.performance.name, configuration.performance.name, sizeof(configuration.performance.name)); |
|
|
|
|
mode = 0xff; |
|
|
|
|
display.noBlink(); |
|
|
|
|
display.setCursor(0, 1); |
|
|
|
@ -5554,10 +5567,9 @@ void UI_func_set_performance_name(uint8_t param) { |
|
|
|
|
} |
|
|
|
|
if (mode == 0) { |
|
|
|
|
mode = 1; |
|
|
|
|
strlcpy(configuration.performance.name, configuration.performance.name, sizeof(configuration.performance.name)); |
|
|
|
|
display.setCursor(0, 1); |
|
|
|
|
display.print(F("[ ] ")); |
|
|
|
|
ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, PERFORMANCE_NAME_LEN - 1, true); |
|
|
|
|
ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, sizeof(configuration.performance.name), true); |
|
|
|
|
display.blink(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -6205,15 +6217,11 @@ bool UI_select_name(uint8_t y, uint8_t x, char* edit_string, uint8_t len, bool i |
|
|
|
|
static int8_t edit_pos; |
|
|
|
|
static bool edit_mode; |
|
|
|
|
static uint8_t edit_value; |
|
|
|
|
static uint8_t last_char_pos; |
|
|
|
|
|
|
|
|
|
if (init == true) { |
|
|
|
|
edit_mode = false; |
|
|
|
|
edit_pos = 0; |
|
|
|
|
edit_value = search_accepted_char(edit_string[edit_pos]); |
|
|
|
|
last_char_pos = strlen(edit_string); |
|
|
|
|
|
|
|
|
|
string_trim(edit_string); // just to be sure
|
|
|
|
|
|
|
|
|
|
display.setCursor(x, y); |
|
|
|
|
display.print(edit_string); |
|
|
|
@ -6222,88 +6230,69 @@ bool UI_select_name(uint8_t y, uint8_t x, char* edit_string, uint8_t len, bool i |
|
|
|
|
return (false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (LCDML.BT_checkDown() || LCDML.BT_checkUp()) { |
|
|
|
|
if (LCDML.BT_checkDown()) { |
|
|
|
|
if (edit_mode == true) { |
|
|
|
|
if (LCDML.BT_checkDown() || LCDML.BT_checkUp() || LCDML.BT_checkEnter()) { |
|
|
|
|
switch (edit_mode) { |
|
|
|
|
case true: |
|
|
|
|
edit_value = search_accepted_char(edit_string[edit_pos]); |
|
|
|
|
|
|
|
|
|
if (edit_value < sizeof(accepted_chars) - 2) |
|
|
|
|
edit_value++; |
|
|
|
|
if (edit_value == 0 && edit_string[constrain(edit_pos + 1, 0, len)] > 0) |
|
|
|
|
edit_value = 1; |
|
|
|
|
if (LCDML.BT_checkDown()) { |
|
|
|
|
if (edit_value < sizeof(accepted_chars) - 2) |
|
|
|
|
edit_value++; |
|
|
|
|
} else if (LCDML.BT_checkUp()) { |
|
|
|
|
if (edit_value > 0) |
|
|
|
|
edit_value--; |
|
|
|
|
} else if (LCDML.BT_checkEnter()) { |
|
|
|
|
edit_mode = !edit_mode; |
|
|
|
|
display.setCursor(LCD_cols - 1, 0); |
|
|
|
|
display.print(F(" ")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
edit_string[edit_pos] = accepted_chars[edit_value]; |
|
|
|
|
|
|
|
|
|
display.setCursor(x + edit_pos, y); |
|
|
|
|
display.print(edit_string[edit_pos]); |
|
|
|
|
} else { |
|
|
|
|
if (edit_string[edit_pos] != 0 && edit_string[edit_pos] != 32) |
|
|
|
|
edit_pos = constrain(edit_pos + 1, 0, len); |
|
|
|
|
else { |
|
|
|
|
if (edit_pos + 1 > last_char_pos) |
|
|
|
|
edit_pos = len; |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case false: |
|
|
|
|
if (LCDML.BT_checkDown()) { |
|
|
|
|
if (edit_pos < len - 1) |
|
|
|
|
edit_pos++; |
|
|
|
|
} else if (LCDML.BT_checkUp()) { |
|
|
|
|
if (edit_pos > 0) |
|
|
|
|
edit_pos--; |
|
|
|
|
} else if (LCDML.BT_checkEnter()) { |
|
|
|
|
if (edit_pos == len - 1) { // OK pressed
|
|
|
|
|
edit_pos = 0; |
|
|
|
|
edit_mode = false; |
|
|
|
|
string_trim(edit_string); |
|
|
|
|
return (true); |
|
|
|
|
} else { |
|
|
|
|
edit_mode = !edit_mode; |
|
|
|
|
display.setCursor(LCD_cols - 1, 0); |
|
|
|
|
display.print(F("*")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (edit_pos == len) { |
|
|
|
|
if (edit_pos > len - 2) { |
|
|
|
|
display.noBlink(); |
|
|
|
|
display.setCursor(x - 1, y); |
|
|
|
|
display.print(F(" ")); |
|
|
|
|
display.setCursor(x + len, y); |
|
|
|
|
display.setCursor(x + len - 1, y); |
|
|
|
|
display.print(F(" ")); |
|
|
|
|
display.setCursor(x + len + 1, y); |
|
|
|
|
display.setCursor(LCD_cols - 4, y); |
|
|
|
|
display.print(F("[OK]")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (LCDML.BT_checkUp()) { |
|
|
|
|
if (edit_mode == true) { |
|
|
|
|
edit_value = search_accepted_char(edit_string[edit_pos]); |
|
|
|
|
|
|
|
|
|
if (edit_value >= 1) |
|
|
|
|
edit_value--; |
|
|
|
|
if (edit_value == 0 && edit_string[constrain(edit_pos + 1, 0, len)] > 0) |
|
|
|
|
edit_value = 1; |
|
|
|
|
edit_string[edit_pos] = accepted_chars[edit_value]; |
|
|
|
|
|
|
|
|
|
display.setCursor(x + edit_pos, y); |
|
|
|
|
display.print(edit_string[edit_pos]); |
|
|
|
|
} else { |
|
|
|
|
if (edit_pos - 1 > last_char_pos) |
|
|
|
|
edit_pos = last_char_pos; |
|
|
|
|
else |
|
|
|
|
edit_pos = constrain(edit_pos - 1, 0, len - 1); |
|
|
|
|
|
|
|
|
|
if (edit_pos == last_char_pos) { |
|
|
|
|
} else if (edit_pos == len - 2) { |
|
|
|
|
display.setCursor(x - 1, y); |
|
|
|
|
display.print(F("[")); |
|
|
|
|
display.setCursor(x + len, y); |
|
|
|
|
display.setCursor(x + len - 1, y); |
|
|
|
|
display.print(F("]")); |
|
|
|
|
display.setCursor(x + len + 1, y); |
|
|
|
|
display.setCursor(LCD_cols - 4, y); |
|
|
|
|
display.print(F(" ")); |
|
|
|
|
display.blink(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (LCDML.BT_checkEnter()) { |
|
|
|
|
last_char_pos = strlen(edit_string); |
|
|
|
|
if (edit_pos >= len) { |
|
|
|
|
edit_pos = 0; |
|
|
|
|
edit_mode = false; |
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
|
} else { |
|
|
|
|
last_char_pos = strlen(edit_string); |
|
|
|
|
edit_mode = !edit_mode; |
|
|
|
|
} |
|
|
|
|
if (edit_mode == false && edit_pos < len && edit_string[edit_pos] != 0 && edit_string[edit_pos] != 32) |
|
|
|
|
edit_pos++; |
|
|
|
|
if (edit_mode == true) { |
|
|
|
|
display.setCursor(x + len + 1, y); |
|
|
|
|
display.print(F("*")); |
|
|
|
|
} else { |
|
|
|
|
display.setCursor(x + len + 1, y); |
|
|
|
|
display.print(F(" ")); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
display.setCursor(x + edit_pos, y); |
|
|
|
|
encoderDir[ENC_R].reset(); |
|
|
|
|
|
|
|
|
|