From fc59d1f64be8384f50c3499b5f3f45a673a4a16d Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 5 Apr 2017 10:25:34 +0200 Subject: [PATCH] Focus: Merge the eeprom.dump and eeprom.upload commands Fixes #2. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/EEPROM-Settings-Focus.cpp | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Kaleidoscope/EEPROM-Settings-Focus.cpp b/src/Kaleidoscope/EEPROM-Settings-Focus.cpp index 2fcdcdd9..916dc1b3 100644 --- a/src/Kaleidoscope/EEPROM-Settings-Focus.cpp +++ b/src/Kaleidoscope/EEPROM-Settings-Focus.cpp @@ -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: - for (uint16_t i = 0; i < EEPROM.length (); i++) { - uint8_t d = EEPROM[i]; - Focus.printNumber (d); - Focus.printSpace (); - } - break; - case UPLOAD: - for (uint16_t i = 0; i < EEPROM.length (); i++) { - uint8_t d = Serial.parseInt (); - EEPROM.update (i, d); + 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 (); + } + 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;