Adding auto-store for configuration.sys (only when no voice is playing and after the last change of data) (currently only when volume changes).

pull/111/head
Holger Wirtz 3 years ago
parent 871b2be0b2
commit a9e20ca7a0
  1. 43
      MicroDexed.ino
  2. 4
      UI.hpp
  3. 1
      config.h

@ -302,6 +302,7 @@ int16_t _midi_bpm = -1;
elapsedMillis midi_bpm_timer; elapsedMillis midi_bpm_timer;
elapsedMillis long_button_pressed; elapsedMillis long_button_pressed;
elapsedMillis control_rate; elapsedMillis control_rate;
elapsedMillis save_sys;
uint8_t active_voices[NUM_DEXED]; uint8_t active_voices[NUM_DEXED];
uint8_t midi_voices[NUM_DEXED]; uint8_t midi_voices[NUM_DEXED];
#ifdef SHOW_CPU_LOAD_MSEC #ifdef SHOW_CPU_LOAD_MSEC
@ -562,7 +563,7 @@ void setup()
timer1.begin(sequencer, seq_tempo_ms / 2, false); timer1.begin(sequencer, seq_tempo_ms / 2, false);
// Load initial Performance or the last used one // Load initial Performance or the last used one
initial_values_from_eeprom(false); initial_values(false);
#ifdef DISPLAY_LCD_SPI #ifdef DISPLAY_LCD_SPI
change_disp_sd(true); change_disp_sd(true);
@ -689,6 +690,7 @@ void loop()
} }
} }
} }
// CONTROL-RATE-EVENT-HANDLING // CONTROL-RATE-EVENT-HANDLING
if (control_rate > CONTROL_RATE_MS) if (control_rate > CONTROL_RATE_MS)
{ {
@ -747,6 +749,43 @@ void loop()
else else
yield(); yield();
// SAVE-SYS-EVENT-HANDLING
if (save_sys > SAVE_SYS_MS)
{
#ifdef DEBUG
Serial.println(F("Check if we can save configuration.sys"));
#endif
bool instance_is_playing = false;
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
if (active_voices[instance_id] > 0)
{
instance_is_playing = true;
break;
}
}
if (instance_is_playing == false)
{
for (uint8_t instance_id = 0; instance_id < NUM_DRUMS; instance_id++)
{
if (Drum[instance_id]->isPlaying())
{
instance_is_playing = true;
break;
}
}
}
if (instance_is_playing == false)
save_sd_sys_json();
else
{
#ifdef DEBUG
Serial.println(F("System is playing, next try..."));
#endif
save_sys = 0;
}
}
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
if (cpu_mem_millis >= SHOW_CPU_LOAD_MSEC) if (cpu_mem_millis >= SHOW_CPU_LOAD_MSEC)
{ {
@ -1867,7 +1906,7 @@ void set_volume(uint8_t v, uint8_t m)
EEPROM HELPER EEPROM HELPER
******************************************************************************/ ******************************************************************************/
void initial_values_from_eeprom(bool init) void initial_values(bool init)
{ {
uint16_t _m_; uint16_t _m_;

@ -162,6 +162,7 @@ extern uint8_t midi_bpm;
GLOBAL GLOBAL
************************************************************************/ ************************************************************************/
elapsedMillis back_from_volume; elapsedMillis back_from_volume;
extern elapsedMillis save_sys;
uint8_t instance_num[8][8]; uint8_t instance_num[8][8];
const char accepted_chars[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-abcdefghijklmnopqrstuvwxyz"; const char accepted_chars[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-abcdefghijklmnopqrstuvwxyz";
const char noteNames[12][3] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; const char noteNames[12][3] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
@ -7014,7 +7015,8 @@ void UI_func_volume(uint8_t param)
lcd_special_chars(SCROLLBAR); lcd_special_chars(SCROLLBAR);
encoderDir[ENC_L].reset(); encoderDir[ENC_L].reset();
EEPROM.update(EEPROM_START_ADDRESS + 3, configuration.sys.vol); //EEPROM.update(EEPROM_START_ADDRESS + 3, configuration.sys.vol);
save_sys = 0;
} }
} }

@ -330,6 +330,7 @@
//************************************************************************************************* //*************************************************************************************************
#define MAX_DEXED 2 // No! - even don't think about increasing this number! IT _WILL_ PRODUCE MASSIVE PROBLEMS! #define MAX_DEXED 2 // No! - even don't think about increasing this number! IT _WILL_ PRODUCE MASSIVE PROBLEMS!
#define CONTROL_RATE_MS 50 #define CONTROL_RATE_MS 50
#define SAVE_SYS_MS 5000
#define VOL_MAX_FLOAT 0.95 #define VOL_MAX_FLOAT 0.95
#define EEPROM_MARKER 0x4242 #define EEPROM_MARKER 0x4242

Loading…
Cancel
Save