Added autostore of configuration.sys.

pull/111/head
Holger Wirtz 3 years ago
parent a9e20ca7a0
commit a0b3f45f2d
  1. 12
      MicroDexed.ino
  2. 50
      UI.hpp
  3. 1
      config.h
  4. 4
      dexed_sd.cpp

@ -303,6 +303,7 @@ elapsedMillis midi_bpm_timer;
elapsedMillis long_button_pressed;
elapsedMillis control_rate;
elapsedMillis save_sys;
bool save_sys_flag = false;
uint8_t active_voices[NUM_DEXED];
uint8_t midi_voices[NUM_DEXED];
#ifdef SHOW_CPU_LOAD_MSEC
@ -750,7 +751,7 @@ void loop()
yield();
// SAVE-SYS-EVENT-HANDLING
if (save_sys > SAVE_SYS_MS)
if (save_sys > SAVE_SYS_MS && save_sys_flag == true)
{
#ifdef DEBUG
Serial.println(F("Check if we can save configuration.sys"));
@ -1941,6 +1942,7 @@ void initial_values(bool init)
check_configuration();
}
configuration.sys.vol = EEPROM[EEPROM_START_ADDRESS + 3];
set_volume(configuration.sys.vol, configuration.sys.mono);
#ifdef DEBUG
@ -1959,12 +1961,11 @@ void check_configuration(void)
void check_configuration_sys(void)
{
configuration.sys.instances = constrain(configuration.sys.instances, INSTANCES_MIN, INSTANCES_MAX);
configuration.sys.vol = constrain(configuration.sys.vol, VOLUME_MIN, VOLUME_MAX);
configuration.sys.mono = constrain(configuration.sys.mono, MONO_MIN, MONO_MAX);
configuration.sys.soft_midi_thru = constrain(configuration.sys.soft_midi_thru, SOFT_MIDI_THRU_MIN, SOFT_MIDI_THRU_MAX);
configuration.sys.performance_number = constrain(configuration.sys.performance_number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX);
configuration.sys.favorites = constrain(configuration.sys.favorites, FAVORITES_NUM_MIN, FAVORITES_NUM_MAX);
configuration.sys.performance_number = constrain(configuration.sys.performance_number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX);
}
void check_configuration_fx(void)
@ -2056,7 +2057,6 @@ void init_configuration(void)
Serial.println(F("INITIALIZING CONFIGURATION"));
#endif
configuration.sys.instances = INSTANCES_DEFAULT;
configuration.sys.vol = VOLUME_DEFAULT;
configuration.sys.mono = MONO_DEFAULT;
configuration.sys.soft_midi_thru = SOFT_MIDI_THRU_DEFAULT;
@ -2142,6 +2142,7 @@ void eeprom_update(void)
EEPROM.update(EEPROM_START_ADDRESS, (EEPROM_MARKER & 0xff00) >> 8);
EEPROM.update(EEPROM_START_ADDRESS + 1, EEPROM_MARKER & 0xff);
EEPROM.update(EEPROM_START_ADDRESS + 2, configuration.sys.performance_number);
EEPROM.update(EEPROM_START_ADDRESS + 3, configuration.sys.vol);
}
/******************************************************************************
@ -2757,10 +2758,11 @@ void show_configuration(void)
Serial.println();
Serial.println(F("CONFIGURATION:"));
Serial.println(F("System"));
Serial.print(F(" Instances ")); Serial.println(configuration.sys.instances, DEC);
Serial.print(F(" Volume ")); Serial.println(configuration.sys.vol, DEC);
Serial.print(F(" Mono ")); Serial.println(configuration.sys.mono, DEC);
Serial.print(F(" Soft MIDI Thru ")); Serial.println(configuration.sys.soft_midi_thru, DEC);
Serial.print(F(" Favorites ")); Serial.println(configuration.sys.favorites, DEC);
Serial.print(F(" Performance Number ")); Serial.println(configuration.sys.performance_number, DEC);
Serial.println(F("FX"));
Serial.print(F(" Reverb Roomsize ")); Serial.println(configuration.fx.reverb_roomsize, DEC);
Serial.print(F(" Reverb Level ")); Serial.println(configuration.fx.reverb_level, DEC);

@ -64,6 +64,7 @@ extern float midi_volume_transform(uint8_t midi_amp);
extern float volume_transform(float amp);
extern uint8_t selected_instance_id;
extern char receive_bank_filename[FILENAME_LEN];
extern void eeprom_update(void);
#if NUM_DRUMS > 0
#include "drums.h"
@ -157,12 +158,14 @@ extern int perform_attack_mod[NUM_DEXED];
extern int perform_release_mod[NUM_DEXED];
extern float midi_ticks_factor[10];
extern uint8_t midi_bpm;
extern bool save_sys_flag;
extern elapsedMillis save_sys;
extern bool save_sys_flag;
/***********************************************************************
GLOBAL
************************************************************************/
elapsedMillis back_from_volume;
extern elapsedMillis save_sys;
uint8_t instance_num[8][8];
const char accepted_chars[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-abcdefghijklmnopqrstuvwxyz";
const char noteNames[12][3] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
@ -2211,9 +2214,12 @@ void UI_func_panorama(uint8_t param)
void UI_func_favorites(uint8_t param)
{
static uint8_t old_favorites;
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
encoderDir[ENC_L].reset();
old_favorites = configuration.sys.favorites;
lcd.setCursor(0, 0);
lcd.print(F("Favorites"));
@ -2261,15 +2267,26 @@ void UI_func_favorites(uint8_t param)
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
lcd_special_chars(SCROLLBAR);
encoderDir[ENC_L].reset();
if (old_favorites != configuration.sys.favorites)
{
save_sys_flag = true;
save_sys = 0;
}
}
}
void UI_func_stereo_mono(uint8_t param)
{
static uint8_t old_mono;
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
encoderDir[ENC_R].reset();
old_mono = configuration.sys.mono;
lcd.setCursor(0, 0);
lcd.print(F("Stereo/Mono"));
@ -2326,7 +2343,16 @@ void UI_func_stereo_mono(uint8_t param)
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
encoderDir[ENC_R].reset();
{
lcd_special_chars(SCROLLBAR);
encoderDir[ENC_L].reset();
if (old_mono != configuration.sys.mono)
{
save_sys_flag = true;
save_sys = 0;
}
}
}
void UI_func_polyphony(uint8_t param)
@ -6417,6 +6443,8 @@ void UI_func_information(uint8_t param)
void UI_func_midi_soft_thru(uint8_t param)
{
static uint8_t old_soft_midi_thru;
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
encoderDir[ENC_R].reset();
@ -6448,7 +6476,15 @@ void UI_func_midi_soft_thru(uint8_t param)
}
if (LCDML.FUNC_close()) // ****** STABLE END *********
{
encoderDir[ENC_R].reset();
if (old_soft_midi_thru != configuration.sys.soft_midi_thru)
{
save_sys_flag = true;
save_sys = 0;
}
}
}
void UI_func_smart_filter(uint8_t param)
@ -6849,9 +6885,11 @@ void UI_func_voice_select(uint8_t param)
void UI_func_volume(uint8_t param)
{
char tmp[6];
static uint8_t old_volume;
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
old_volume = configuration.sys.vol;
encoderDir[ENC_L].reset();
@ -7015,8 +7053,12 @@ void UI_func_volume(uint8_t param)
lcd_special_chars(SCROLLBAR);
encoderDir[ENC_L].reset();
//EEPROM.update(EEPROM_START_ADDRESS + 3, configuration.sys.vol);
save_sys = 0;
if (old_volume != configuration.sys.vol)
{
eeprom_update();
save_sys_flag = true;
save_sys = 0;
}
}
}

@ -748,7 +748,6 @@ typedef struct performance_s {
} performance_t;
typedef struct sys_s {
uint8_t instances;
uint8_t vol;
uint8_t mono;
uint8_t soft_midi_thru;

@ -90,6 +90,7 @@ extern float get_sample_vol_max(uint8_t sample);
extern float get_sample_vol_min(uint8_t sample);
extern float get_sample_reverb_send(uint8_t sample);
extern uint8_t find_drum_number_from_note(uint8_t note);
extern bool save_sys_flag;
/******************************************************************************
SD BANK/VOICE LOADING
@ -979,7 +980,6 @@ bool load_sd_sys_json(void)
Serial.println();
#endif
configuration.sys.instances = data_json["instances"];
configuration.sys.vol = data_json["vol"];
configuration.sys.mono = data_json["mono"];
configuration.sys.soft_midi_thru = data_json["soft_midi_thru"];
@ -1033,7 +1033,6 @@ bool save_sd_sys_json(void)
json = SD.open(filename, FILE_WRITE);
if (json)
{
data_json["instances"] = configuration.sys.instances;
data_json["vol"] = configuration.sys.vol;
data_json["mono"] = configuration.sys.mono;
data_json["soft_midi_thru"] = configuration.sys.soft_midi_thru;
@ -1048,6 +1047,7 @@ bool save_sd_sys_json(void)
serializeJsonPretty(data_json, json);
json.close();
AudioInterrupts();
save_sys_flag = false;
return (true);
}
json.close();

Loading…
Cancel
Save