Focus: Add an EEPROM dump, and an upload command

Fixes keyboardio/Kaleidoscope-Focus#1.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent c0d2c51730
commit ff29bce43e

@ -56,4 +56,41 @@ namespace FocusHooks {
return true; 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;
}
}; };

@ -22,6 +22,7 @@
namespace FocusHooks { namespace FocusHooks {
bool settings (const char *command); bool settings (const char *command);
bool eeprom (const char *command);
}; };
#define FOCUS_HOOK_SETTINGS FOCUS_HOOK(FocusHooks::settings, \ #define FOCUS_HOOK_SETTINGS FOCUS_HOOK(FocusHooks::settings, \
@ -34,3 +35,11 @@ namespace FocusHooks {
"settings.crc\n" \ "settings.crc\n" \
"------------\n" \ "------------\n" \
"Return the CRC of the settings.") "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.")

Loading…
Cancel
Save