Focus: Merge the eeprom.dump and eeprom.upload commands

Fixes #2.

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

@ -60,34 +60,35 @@ namespace FocusHooks {
bool eeprom (const char *command) {
enum {
CONTENTS,
FREE,
DUMP,
UPLOAD,
} subCommand;
if (strcmp_P (command, PSTR ("eeprom.dump")) == 0)
subCommand = DUMP;
else if (strcmp_P (command, PSTR ("eeprom.upload")) == 0)
subCommand = UPLOAD;
if (strcmp_P (command, PSTR ("eeprom.contents")) == 0)
subCommand = CONTENTS;
else if (strcmp_P (command, PSTR ("eeprom.free")) == 0)
subCommand = FREE;
else
return false;
switch (subCommand) {
case DUMP:
case CONTENTS: {
if (Serial.peek () == '\n') {
for (uint16_t i = 0; i < EEPROM.length (); i++) {
uint8_t d = EEPROM[i];
Focus.printNumber (d);
Focus.printSpace ();
}
break;
case UPLOAD:
Serial.println ();
} else {
for (uint16_t i = 0; i < EEPROM.length (); i++) {
uint8_t d = Serial.parseInt ();
EEPROM.update (i, d);
}
}
break;
}
case FREE:
Serial.println (EEPROM.length () - EEPROMSettings.used ());
break;

Loading…
Cancel
Save