Storing and loading configs implemented.

master
Holger Wirtz 6 years ago
parent ea818821cb
commit 277216429e
  1. 34
      MicroMDAEPiano.ino
  2. 2
      UI.hpp
  3. 2
      config.h

@ -218,6 +218,7 @@ void setup()
Serial.println(F("<setup end>"));
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC)
Serial.println();
show_cpu_and_mem_usage();
cpu_mem_millis = 0;
#endif
@ -456,6 +457,37 @@ void set_master_volume(uint8_t value)
EEPROM HELPER
******************************************************************************/
void config_from_eeprom(void)
{
uint32_t checksum;
config_t tmp_conf;
EEPROM_readAnything(EEPROM_CONFIGURATIONS + sizeof(config_t) * (sound - 1), tmp_conf);
checksum = crc32((byte*)&tmp_conf + 4, sizeof(tmp_conf) - 4);
#ifdef DEBUG
Serial.print(F("EEPROM checksum: 0x"));
Serial.print(tmp_conf.checksum, HEX);
Serial.print(F(" / 0x"));
Serial.print(checksum, HEX);
#endif
if (checksum == tmp_conf.checksum)
{
EEPROM_readAnything(EEPROM_CONFIGURATIONS + sizeof(config_t) * (sound - 1), configuration);
Serial.print(F(" - OK, loading config "));
Serial.print(sound,DEC);
}
else
#ifdef DEBUG
Serial.println(F(" - mismatch (or force) -> nothing done!"));
#endif
#ifdef DEBUG
Serial.println();
#endif
}
void initial_values_from_eeprom(void)
{
uint32_t checksum;
@ -488,6 +520,8 @@ void initial_values_from_eeprom(void)
#ifdef DEBUG
Serial.print(F(" - Master volume: "));
Serial.println(master_volume, DEC);
Serial.print(F("Max configs in EEPROM: "));
Serial.println(MAX_SOUNDS);
#endif
}

@ -705,7 +705,7 @@ void callback_load_sound_function() {
menu_system.change_menu(load_sound_menu);
menu_position[MAIN] = encoder_value[RIGHT_ENCODER];
encoder_value[RIGHT_ENCODER] = sound;
enc[RIGHT_ENCODER].write(sound, 1, 99);
enc[RIGHT_ENCODER].write(sound, 1, MAX_SOUNDS);
menu_system.update();
}

@ -135,6 +135,8 @@
//* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!!
//*************************************************************************************************
#define MAX_SOUNDS min(99,int((4096-EEPROM_CONFIGURATIONS)/sizeof(config_t)))
#define CONTROL_RATE_MS 100
#define BACK_TO_MAIN_MS 800
#define STORE_MASTER_VOLUME_MS 5000

Loading…
Cancel
Save