From 41340d18d92e0133540f32418519cb26c3d7e119 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sun, 1 Jan 2023 18:08:05 +0100 Subject: [PATCH] Fix for storing performance name. --- MicroDexed.ino | 1 - UI.hpp | 38 +++++++++---------------- UI_FX_T4.h | 4 +-- addon/SD/PERFORMANCE/0/performance.json | 2 +- config.h | 1 - dexed_sd.cpp | 19 +++++++++++-- 6 files changed, 33 insertions(+), 32 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 7e3d49d..61e4958 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -2107,7 +2107,6 @@ void init_configuration(void) { #endif strlcpy(configuration.performance.name, "INIT Perf", sizeof(configuration.performance.name)); - strlcpy(configuration.performance.name_temp, "INIT Perf", sizeof(configuration.performance.name_temp)); eeprom_update(); } diff --git a/UI.hpp b/UI.hpp index 66f02d3..11064e8 100644 --- a/UI.hpp +++ b/UI.hpp @@ -4602,8 +4602,8 @@ void UI_func_save_performance(uint8_t param) { overwrite = false; if (check_sd_performance_exists(temp_int)) { get_sd_performance_name_json(temp_int); - if (configuration.performance.name_temp[0] != 0) - display.show(1, 5, 11, configuration.performance.name_temp); + if (configuration.performance.name[0] != 0) + display.show(1, 5, 11, configuration.performance.name); else display.print("-- DATA -- "); } else @@ -4660,8 +4660,8 @@ void UI_func_save_performance(uint8_t param) { display.print("-- EMPTY --"); } else if (check_sd_performance_exists(temp_int)) { get_sd_performance_name_json(temp_int); - if (configuration.performance.name_temp[0] != 0) - display.show(1, 5, 11, configuration.performance.name_temp); + if (configuration.performance.name[0] != 0) + display.show(1, 5, 11, configuration.performance.name); else display.print("-- DATA -- "); } else display.print("-- EMPTY --"); } else if (mode < 0xff) { @@ -4704,8 +4704,8 @@ void UI_func_load_performance(uint8_t param) { display.print(tmp); if (check_sd_performance_exists(temp_int)) { get_sd_performance_name_json(temp_int); - if (configuration.performance.name_temp[0] != 0) - display.show(1, 5, 11, configuration.performance.name_temp); + if (configuration.performance.name[0] != 0) + display.show(1, 5, 11, configuration.performance.name); else display.print(" -- DATA -- "); } else display.print(" -- EMPTY --"); @@ -4737,8 +4737,8 @@ void UI_func_load_performance(uint8_t param) { display.print(tmp); if (check_sd_performance_exists(temp_int)) { get_sd_performance_name_json(temp_int); - if (configuration.performance.name_temp[0] != 0) - display.show(1, 5, 11, configuration.performance.name_temp); + if (configuration.performance.name[0] != 0) + display.show(1, 5, 11, configuration.performance.name); else display.print(" -- DATA -- "); } else display.print(" -- EMPTY --"); @@ -5533,26 +5533,16 @@ void UI_func_set_performance_name(uint8_t param) { { 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_temp, BANK_NAME_LEN - 1, false); + if (mode == 1) ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, PERFORMANCE_NAME_LEN - 1, false); } else if (LCDML.BT_checkUp()) { - if (mode == 1) ui_select_name_state = UI_select_name(1, 1, configuration.performance.name_temp, BANK_NAME_LEN - 1, false); - // if (ui_select_name_state == false) { - // display.setCursor(12, 1); - // display.print(" "); - // display.setCursor(0, 1); - // display.print("["); - // display.setCursor(11, 1); - // display.print("]"); - // display.blink(); - // ui_select_name_state = UI_select_name(1, 1, configuration.performance.name_temp, BANK_NAME_LEN - 1, true); - // } + if (mode == 1) ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, PERFORMANCE_NAME_LEN - 1, 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_temp, BANK_NAME_LEN - 1, false); + ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, PERFORMANCE_NAME_LEN - 1, false); if (ui_select_name_state == true) { - strlcpy(configuration.performance.name, configuration.performance.name_temp, sizeof(configuration.performance.name)); + strlcpy(configuration.performance.name, configuration.performance.name, sizeof(configuration.performance.name)); mode = 0xff; display.noBlink(); display.setCursor(0, 1); @@ -5564,10 +5554,10 @@ void UI_func_set_performance_name(uint8_t param) { } if (mode == 0) { mode = 1; - strlcpy(configuration.performance.name_temp, configuration.performance.name, sizeof(configuration.performance.name_temp)); + 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_temp, BANK_NAME_LEN - 1, true); + ui_select_name_state = UI_select_name(1, 1, configuration.performance.name, PERFORMANCE_NAME_LEN - 1, true); display.blink(); } } diff --git a/UI_FX_T4.h b/UI_FX_T4.h index f9edef7..3d6b227 100644 --- a/UI_FX_T4.h +++ b/UI_FX_T4.h @@ -141,8 +141,8 @@ LCDML_add(107, LCDML_0_4_2, 3, "220Hz", UI_func_eq_3); LCDML_add(108, LCDML_0_4_2, 4, "1000Hz", UI_func_eq_4); LCDML_add(109, LCDML_0_4_2, 5, "2000Hz", UI_func_eq_5); LCDML_add(110, LCDML_0_4_2, 6, "7000Hz", UI_func_eq_6); -LCDML_add(111, LCDML_0_4_2, 7, "High-Cut", UI_func_eq_7) - LCDML_add(112, LCDML_0, 5, "Load/Save", NULL); +LCDML_add(111, LCDML_0_4_2, 7, "High-Cut", UI_func_eq_7); +LCDML_add(112, LCDML_0, 5, "Load/Save", NULL); LCDML_add(113, LCDML_0_5, 1, "Load Perf.", UI_func_load_performance); LCDML_add(114, LCDML_0_5, 2, "Save Perf.", UI_func_save_performance); LCDML_add(115, LCDML_0_5, 3, "Name Perf.", UI_func_set_performance_name); diff --git a/addon/SD/PERFORMANCE/0/performance.json b/addon/SD/PERFORMANCE/0/performance.json index 4cdaadf..61d107d 100644 --- a/addon/SD/PERFORMANCE/0/performance.json +++ b/addon/SD/PERFORMANCE/0/performance.json @@ -1,3 +1,3 @@ { - "name": "MD-Perf1" + "name": "Default" } diff --git a/config.h b/config.h index 901c088..d34f119 100644 --- a/config.h +++ b/config.h @@ -909,7 +909,6 @@ typedef struct sys_s { typedef struct performance_s { char name[PERFORMANCE_NAME_LEN]; - char name_temp[PERFORMANCE_NAME_LEN]; } performance_t; typedef struct drums_s { diff --git a/dexed_sd.cpp b/dexed_sd.cpp index 1ce4420..0ea62cc 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -36,6 +36,10 @@ extern void set_drums_volume(float vol); //extern drum_config_t drum_config[]; #endif +#include +#include "disp_plus.h" + +extern Disp_Plus display; extern void init_MIDI_send_CC(void); extern void check_configuration_dexed(uint8_t instance_id); @@ -1143,6 +1147,7 @@ bool save_sd_performance_json(uint8_t number) { AudioNoInterrupts(); + display.show(1, 13, 3, "1/5"); check_performance_directory(number); #ifdef DEBUG @@ -1150,7 +1155,9 @@ bool save_sd_performance_json(uint8_t number) { Serial.println(number); #endif + display.show(1, 13, 3, "2/5"); save_sd_fx_json(number); + display.show(1, 13, 3, "3/5"); save_sd_epiano_json(number); for (uint8_t i = 0; i < MAX_DEXED; i++) { @@ -1159,6 +1166,7 @@ bool save_sd_performance_json(uint8_t number) { Serial.print(F("Write Voice-Config")); Serial.println(filename); #endif + display.show(1, 13, 3, "4/5"); save_sd_voiceconfig_json(number, i); } @@ -1173,10 +1181,11 @@ bool save_sd_performance_json(uint8_t number) { Serial.println(filename); #endif + display.show(1, 13, 3, "5/5"); SD.remove(filename); json = SD.open(filename, FILE_WRITE); if (json) { - strlcpy(data_json["name"] | "NoName", configuration.performance.name_temp, sizeof(configuration.performance.name_temp)); + data_json["name"] = configuration.performance.name; serializeJsonPretty(data_json, json); json.close(); AudioInterrupts(); @@ -1254,12 +1263,13 @@ void get_sd_performance_name_json(uint8_t number) { AudioInterrupts(); } - strlcpy(configuration.performance.name_temp, data_json["name"] | "NoName", sizeof(configuration.performance.name_temp)); + strlcpy(configuration.performance.name, data_json["name"] | "NoName", sizeof(configuration.performance.name)); + #ifdef DEBUG Serial.print(F("Get performance name for ")); Serial.print(number); Serial.print(F(": [")); - Serial.print(configuration.performance.name_temp); + Serial.print(configuration.performance.name); Serial.println("]"); #endif } @@ -1267,6 +1277,9 @@ void get_sd_performance_name_json(uint8_t number) { } bool load_sd_performance_json(uint8_t number) { + + get_sd_performance_name_json(number); + dac_mute(); handleStop(); number = constrain(number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX);