Fixed performance naming function.

Small fixes.
dev
Holger Wirtz 2 years ago
parent 41340d18d9
commit c297aff79f
  1. 155
      UI.hpp
  2. 4
      addon/tools/wav2c.sh
  3. 2
      config.h
  4. 18
      dexed_sd.cpp
  5. 839751
      drumset.h

155
UI.hpp

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

@ -99,6 +99,8 @@ rm -f "${DRUMSET_H}"
cat >> "${DRUMSET_H}" << EOF cat >> "${DRUMSET_H}" << EOF
#pragma once #pragma once
#if NUM_DRUMS > 0
#include <Arduino.h> #include <Arduino.h>
typedef struct drum_config_s { typedef struct drum_config_s {
@ -265,6 +267,8 @@ cat >> "${DRUMS_H}" << EOF
0.0 0.0
} }
}; };
#endif
EOF EOF
echo "" >> "${DRUMSET_H}" echo "" >> "${DRUMSET_H}"

@ -319,7 +319,7 @@
#define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN #define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN
#define CONFIG_FILENAME_LEN 50 #define CONFIG_FILENAME_LEN 50
#define DRUM_NAME_LEN 9 #define DRUM_NAME_LEN 9
#define PERFORMANCE_NAME_LEN 12 #define PERFORMANCE_NAME_LEN 11
#define FAV_CONFIG_PATH "FAVCFG" #define FAV_CONFIG_PATH "FAVCFG"
#define FAV_CONFIG_NAME "FAVCFG" #define FAV_CONFIG_NAME "FAVCFG"

@ -1141,13 +1141,14 @@ bool save_sd_sys_json(void) {
bool save_sd_performance_json(uint8_t number) { bool save_sd_performance_json(uint8_t number) {
char filename[CONFIG_FILENAME_LEN]; char filename[CONFIG_FILENAME_LEN];
number = constrain(number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX); number = constrain(number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX);
dac_mute(); dac_mute();
AudioNoInterrupts(); AudioNoInterrupts();
display.show(1, 13, 3, "1/5"); display.show(1, 13, 3, "1/4");
check_performance_directory(number); check_performance_directory(number);
#ifdef DEBUG #ifdef DEBUG
@ -1155,9 +1156,9 @@ bool save_sd_performance_json(uint8_t number) {
Serial.println(number); Serial.println(number);
#endif #endif
display.show(1, 13, 3, "2/5"); display.show(1, 13, 3, "2/4");
save_sd_fx_json(number); save_sd_fx_json(number);
display.show(1, 13, 3, "3/5"); display.show(1, 13, 3, "3/4");
save_sd_epiano_json(number); save_sd_epiano_json(number);
for (uint8_t i = 0; i < MAX_DEXED; i++) { for (uint8_t i = 0; i < MAX_DEXED; i++) {
@ -1166,7 +1167,7 @@ bool save_sd_performance_json(uint8_t number) {
Serial.print(F("Write Voice-Config")); Serial.print(F("Write Voice-Config"));
Serial.println(filename); Serial.println(filename);
#endif #endif
display.show(1, 13, 3, "4/5"); display.show(1, 13, 3, "4/4");
save_sd_voiceconfig_json(number, i); save_sd_voiceconfig_json(number, i);
} }
@ -1181,7 +1182,6 @@ bool save_sd_performance_json(uint8_t number) {
Serial.println(filename); Serial.println(filename);
#endif #endif
display.show(1, 13, 3, "5/5");
SD.remove(filename); SD.remove(filename);
json = SD.open(filename, FILE_WRITE); json = SD.open(filename, FILE_WRITE);
if (json) { if (json) {
@ -1241,7 +1241,7 @@ bool check_performance_directory(uint8_t number) {
return (false); return (false);
} }
void get_sd_performance_name_json(uint8_t number) { void get_sd_performance_name_json(uint8_t number, char* name, uint8_t len) {
number = constrain(number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX); number = constrain(number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX);
if (sd_card > 0) { if (sd_card > 0) {
File json; File json;
@ -1263,13 +1263,13 @@ void get_sd_performance_name_json(uint8_t number) {
AudioInterrupts(); AudioInterrupts();
} }
strlcpy(configuration.performance.name, data_json["name"] | "NoName", sizeof(configuration.performance.name)); strlcpy(name, data_json["name"] | "NoName", len);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Get performance name for ")); Serial.print(F("Get performance name for "));
Serial.print(number); Serial.print(number);
Serial.print(F(": [")); Serial.print(F(": ["));
Serial.print(configuration.performance.name); Serial.print(name);
Serial.println("]"); Serial.println("]");
#endif #endif
} }
@ -1278,7 +1278,7 @@ void get_sd_performance_name_json(uint8_t number) {
bool load_sd_performance_json(uint8_t number) { bool load_sd_performance_json(uint8_t number) {
get_sd_performance_name_json(number); get_sd_performance_name_json(number, configuration.performance.name, sizeof(configuration.performance.name));
dac_mute(); dac_mute();
handleStop(); handleStop();

839751
drumset.h

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save