diff --git a/src/Kaleidoscope/EEPROM-Settings-Focus.cpp b/src/Kaleidoscope/EEPROM-Settings-Focus.cpp index 1be66f6e..dd683ae7 100644 --- a/src/Kaleidoscope/EEPROM-Settings-Focus.cpp +++ b/src/Kaleidoscope/EEPROM-Settings-Focus.cpp @@ -56,4 +56,41 @@ namespace FocusHooks { return true; } + + bool eeprom (const char *command) { + enum { + DUMP, + UPLOAD, + } subCommand; + + if (strcmp_P (command, PSTR ("eeprom.dump")) == 0) + subCommand = DUMP; + else if (strcmp_P (command, PSTR ("eeprom.upload")) == 0) + subCommand = UPLOAD; + else + return false; + + switch (subCommand) { + case DUMP: + for (uint16_t i = 0; i < EEPROM.length (); i++) { + uint8_t d = EEPROM[i]; + if (d < 16) + Serial.print (0); + Serial.print (d, HEX); + Serial.print (F(" ")); + if ((i + 1) % 32 == 0) + Serial.println (); + } + break; + case UPLOAD: + for (uint16_t i = 0; i < EEPROM.length (); i++) { + uint8_t d = Serial.parseInt (); + EEPROM.update (i, d); + } + break; + } + + Serial.read (); + return true; + } }; diff --git a/src/Kaleidoscope/EEPROM-Settings-Focus.h b/src/Kaleidoscope/EEPROM-Settings-Focus.h index de5af745..72e038c8 100644 --- a/src/Kaleidoscope/EEPROM-Settings-Focus.h +++ b/src/Kaleidoscope/EEPROM-Settings-Focus.h @@ -22,6 +22,7 @@ namespace FocusHooks { bool settings (const char *command); + bool eeprom (const char *command); }; #define FOCUS_HOOK_SETTINGS FOCUS_HOOK(FocusHooks::settings, \ @@ -34,3 +35,11 @@ namespace FocusHooks { "settings.crc\n" \ "------------\n" \ "Return the CRC of the settings.") + +#define FOCUS_HOOK_EEPROM FOCUS_HOOK(FocusHooks::eeprom, \ + "eeprom.dump\n" \ + "-----------\n" \ + "Dump the contents of EEPROM.\n\n" \ + "eeprom.upload BYTES...\n" \ + "----------------------\n" \ + "Upload `BYTES` to EEPROM.")