|
|
|
@ -21,76 +21,76 @@
|
|
|
|
|
#include "crc.h"
|
|
|
|
|
|
|
|
|
|
namespace FocusHooks {
|
|
|
|
|
bool settings (const char *command) {
|
|
|
|
|
bool settings(const char *command) {
|
|
|
|
|
enum {
|
|
|
|
|
ISVALID,
|
|
|
|
|
GETVERSION,
|
|
|
|
|
CRC,
|
|
|
|
|
} subCommand;
|
|
|
|
|
|
|
|
|
|
if (strncmp_P (command, PSTR ("settings."), 9) != 0)
|
|
|
|
|
if (strncmp_P(command, PSTR("settings."), 9) != 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (strcmp_P (command + 9, PSTR ("valid?")) == 0)
|
|
|
|
|
if (strcmp_P(command + 9, PSTR("valid?")) == 0)
|
|
|
|
|
subCommand = ISVALID;
|
|
|
|
|
else if (strcmp_P (command + 9, PSTR ("version")) == 0)
|
|
|
|
|
else if (strcmp_P(command + 9, PSTR("version")) == 0)
|
|
|
|
|
subCommand = GETVERSION;
|
|
|
|
|
else if (strcmp_P (command + 9, PSTR ("crc")) == 0)
|
|
|
|
|
else if (strcmp_P(command + 9, PSTR("crc")) == 0)
|
|
|
|
|
subCommand = CRC;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
switch (subCommand) {
|
|
|
|
|
case ISVALID:
|
|
|
|
|
Focus.printBool (EEPROMSettings.isValid ());
|
|
|
|
|
Serial.println ();
|
|
|
|
|
Focus.printBool(EEPROMSettings.isValid());
|
|
|
|
|
Serial.println();
|
|
|
|
|
break;
|
|
|
|
|
case GETVERSION:
|
|
|
|
|
Serial.println (EEPROMSettings.version ());
|
|
|
|
|
Serial.println(EEPROMSettings.version());
|
|
|
|
|
break;
|
|
|
|
|
case CRC:
|
|
|
|
|
Serial.print (::CRC.crc, HEX);
|
|
|
|
|
Serial.print (F("/"));
|
|
|
|
|
Serial.println (EEPROMSettings.crc (), HEX);
|
|
|
|
|
Serial.print(::CRC.crc, HEX);
|
|
|
|
|
Serial.print(F("/"));
|
|
|
|
|
Serial.println(EEPROMSettings.crc(), HEX);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool eeprom (const char *command) {
|
|
|
|
|
bool eeprom(const char *command) {
|
|
|
|
|
enum {
|
|
|
|
|
CONTENTS,
|
|
|
|
|
FREE,
|
|
|
|
|
} subCommand;
|
|
|
|
|
|
|
|
|
|
if (strcmp_P (command, PSTR ("eeprom.contents")) == 0)
|
|
|
|
|
if (strcmp_P(command, PSTR("eeprom.contents")) == 0)
|
|
|
|
|
subCommand = CONTENTS;
|
|
|
|
|
else if (strcmp_P (command, PSTR ("eeprom.free")) == 0)
|
|
|
|
|
else if (strcmp_P(command, PSTR("eeprom.free")) == 0)
|
|
|
|
|
subCommand = FREE;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
switch (subCommand) {
|
|
|
|
|
case CONTENTS: {
|
|
|
|
|
if (Serial.peek () == '\n') {
|
|
|
|
|
for (uint16_t i = 0; i < EEPROM.length (); i++) {
|
|
|
|
|
if (Serial.peek() == '\n') {
|
|
|
|
|
for (uint16_t i = 0; i < EEPROM.length(); i++) {
|
|
|
|
|
uint8_t d = EEPROM[i];
|
|
|
|
|
Focus.printNumber (d);
|
|
|
|
|
Focus.printSpace ();
|
|
|
|
|
Focus.printNumber(d);
|
|
|
|
|
Focus.printSpace();
|
|
|
|
|
}
|
|
|
|
|
Serial.println ();
|
|
|
|
|
Serial.println();
|
|
|
|
|
} else {
|
|
|
|
|
for (uint16_t i = 0; i < EEPROM.length () && Serial.peek () != '\n'; i++) {
|
|
|
|
|
uint8_t d = Serial.parseInt ();
|
|
|
|
|
EEPROM.update (i, d);
|
|
|
|
|
for (uint16_t i = 0; i < EEPROM.length() && Serial.peek() != '\n'; i++) {
|
|
|
|
|
uint8_t d = Serial.parseInt();
|
|
|
|
|
EEPROM.update(i, d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case FREE:
|
|
|
|
|
Serial.println (EEPROM.length () - EEPROMSettings.used ());
|
|
|
|
|
Serial.println(EEPROM.length() - EEPROMSettings.used());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|