Fix for loading EEPROM data.

Fix for loading configs from SD,
pull/32/head
Holger Wirtz 4 years ago
parent 5ad7b10528
commit cfba74f860
  1. 21
      MicroDexed.ino
  2. 15
      UI.hpp
  3. 4
      config.h

@ -1432,21 +1432,20 @@ void set_volume(uint8_t v, uint8_t m)
void initial_values_from_eeprom(bool init)
{
uint32_t _m_;
uint16_t _m_;
if (init == true)
init_configuration();
else
{
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, _marker_), _m_);
_m_ = (EEPROM[EEPROM_START_ADDRESS + offsetof(configuration_s, _marker_)] << 8) | EEPROM[EEPROM_START_ADDRESS + offsetof(configuration_s, _marker_) + 1];
if (_m_ != EEPROM_MARKER)
{
#ifdef DEBUG
Serial.println(F("Found wrong EEPROM marker, initializing EEPROM..."));
#endif
init = true;
configuration._marker_ = EEPROM_MARKER;
init_configuration();
}
#ifdef DEBUG
@ -1461,18 +1460,13 @@ void initial_values_from_eeprom(bool init)
eeprom_get_dexed(i);
}
#ifdef DEBUG
show_configuration();
#endif
#ifdef DEBUG
Serial.println(F("OK, loaded!"));
#endif
}
check_configuration();
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{
set_voiceconfig_params(instance_id);
@ -1732,6 +1726,9 @@ void eeprom_update_performance()
bool eeprom_get_performance()
{
EEPROM.get(EEPROM_START_ADDRESS + offsetof(configuration_s, performance), configuration.performance);
#ifdef DEBUG
Serial.println(F("Getting EEPROM performance."));
#endif
return (true);
}
@ -1855,8 +1852,8 @@ float pseudo_log_curve(float value)
{
//return (mapfloat(_pseudo_log * arm_sin_f32(value), 0.0, _pseudo_log * arm_sin_f32(1.0), 0.0, 1.0));
//return (1 - sqrt(1 - value * value));
//return (pow(value, 2));
return (pow(2, value) - 1);
//return (pow(2, value) - 1);
return (pow(value, 2.5));
}
uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https://www.arduino.cc/en/Tutorial/EEPROMCrc

@ -1361,7 +1361,6 @@ void UI_func_delay_level(uint8_t param)
lcd_display_bar_int("Delay Lvl.", configuration.fx.delay_level[selected_instance_id], 1.0, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 3, false, false, false);
delay_mixer[selected_instance_id]->gain(1, pseudo_log_curve(mapfloat(configuration.fx.delay_level[selected_instance_id], DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)));
if (configuration.fx.delay_level[selected_instance_id] <= DELAY_LEVEL_MIN)
delay_fx[selected_instance_id]->disable(0);
else
@ -4083,7 +4082,7 @@ void UI_func_save_performance(uint8_t param)
delay(MESSAGE_WAIT_TIME);
}
EEPROM.update(EEPROM_START_ADDRESS + offsetof(sys_s, performance_number), configuration.sys.performance_number);
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, sys.performance_number), configuration.sys.performance_number);
encoderDir[ENC_R].reset();
}
@ -4181,10 +4180,10 @@ void UI_func_load_voiceconfig(uint8_t param)
#if NUM_DEXED > 1
if (selected_instance_id > 0)
EEPROM.update(EEPROM_START_ADDRESS + offsetof(performance_s, voiceconfig_number[1]), configuration.performance.voiceconfig_number[1]);
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voiceconfig_number[1]), configuration.performance.voiceconfig_number[1]);
else
#endif
EEPROM.update(EEPROM_START_ADDRESS + offsetof(performance_s, voiceconfig_number[0]), configuration.performance.voiceconfig_number[0]);
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voiceconfig_number[0]), configuration.performance.voiceconfig_number[0]);
encoderDir[ENC_R].reset();
}
@ -4330,10 +4329,10 @@ void UI_func_save_voiceconfig(uint8_t param)
#if NUM_DEXED > 1
if (selected_instance_id > 0)
EEPROM.update(EEPROM_START_ADDRESS + offsetof(performance_s, voiceconfig_number[1]), configuration.performance.voiceconfig_number[1]);
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voiceconfig_number[1]), configuration.performance.voiceconfig_number[1]);
else
#endif
EEPROM.update(EEPROM_START_ADDRESS + offsetof(performance_s, voiceconfig_number[0]), configuration.performance.voiceconfig_number[0]);
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voiceconfig_number[0]), configuration.performance.voiceconfig_number[0]);
encoderDir[ENC_R].reset();
}
@ -4402,7 +4401,7 @@ void UI_func_load_fx(uint8_t param)
else
eeprom_update_fx();
EEPROM.update(EEPROM_START_ADDRESS + offsetof(performance_s, fx_number), configuration.performance.fx_number);
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.fx_number), configuration.performance.fx_number);
encoderDir[ENC_R].reset();
}
@ -4524,7 +4523,7 @@ void UI_func_save_fx(uint8_t param)
delay(MESSAGE_WAIT_TIME);
}
EEPROM.update(EEPROM_START_ADDRESS + offsetof(performance_s, fx_number), configuration.performance.fx_number);
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.fx_number), configuration.performance.fx_number);
encoderDir[ENC_R].reset();
}

@ -56,7 +56,7 @@
// sed -i.orig 's/^#define USB_MIDI_SYSEX_MAX 290/#define USB_MIDI_SYSEX_MAX 4104/' /usr/local/arduino-teensy/hardware/teensy/avr/cores/teensy3/usb_midi.h
//#define USB_MIDI_SYSEX_MAX 4104
#define VERSION "1.0.2"
#define VERSION "1.0.3"
//*************************************************************************************************
//* DEVICE SETTINGS
@ -647,7 +647,7 @@ typedef struct configuration_s {
fx_t fx;
performance_t performance;
dexed_t dexed[MAX_DEXED];
uint32_t _marker_;
uint16_t _marker_;
} config_t;
#if !defined(_MAPFLOAT)

Loading…
Cancel
Save