Add a way to figure out the used & free EEPROM amount

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

@ -60,6 +60,7 @@ namespace FocusHooks {
bool eeprom (const char *command) {
enum {
FREE,
DUMP,
UPLOAD,
} subCommand;
@ -68,6 +69,8 @@ namespace FocusHooks {
subCommand = DUMP;
else if (strcmp_P (command, PSTR ("eeprom.upload")) == 0)
subCommand = UPLOAD;
else if (strcmp_P (command, PSTR ("eeprom.free")) == 0)
subCommand = FREE;
else
return false;
@ -87,6 +90,9 @@ namespace FocusHooks {
EEPROM.update (i, d);
}
break;
case FREE:
Serial.println (EEPROM.length () - EEPROMSettings.used ());
break;
}
return true;

@ -31,5 +31,6 @@ namespace FocusHooks {
"settings.crc")
#define FOCUS_HOOK_EEPROM FOCUS_HOOK(FocusHooks::eeprom, \
"eeprom.free\n" \
"eeprom.dump\n" \
"eeprom.upload")

@ -82,6 +82,11 @@ namespace KaleidoscopePlugins {
_isValid = false;
}
uint16_t
EEPROMSettings::used (void) {
return nextStart;
}
void
EEPROMSettings::update (void) {
settings.crc = CRC.crc;

@ -37,6 +37,7 @@ namespace KaleidoscopePlugins {
static uint16_t requestSlice (uint16_t size);
static void seal (void);
static uint16_t crc (void);
static uint16_t used (void);
private:
static uint16_t nextStart;

Loading…
Cancel
Save