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

Loading…
Cancel
Save