diff --git a/src/Kaleidoscope-EEPROM-Settings.h b/src/Kaleidoscope-EEPROM-Settings.h index f2735e3b..ca5fb963 100644 --- a/src/Kaleidoscope-EEPROM-Settings.h +++ b/src/Kaleidoscope-EEPROM-Settings.h @@ -19,3 +19,4 @@ #pragma once #include +#include diff --git a/src/Kaleidoscope/EEPROM-Settings-Focus.cpp b/src/Kaleidoscope/EEPROM-Settings-Focus.cpp new file mode 100644 index 00000000..d7193b14 --- /dev/null +++ b/src/Kaleidoscope/EEPROM-Settings-Focus.cpp @@ -0,0 +1,51 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-EEPROM-Settings -- Basic EEPROM settings plugin for Kaleidoscope. + * Copyright (C) 2017 Gergely Nagy + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +namespace FocusHooks { + bool settings (const char *command) { + enum { + ISVALID, + GETVERSION, + } subCommand; + + if (strncmp_P (command, PSTR ("settings."), 9) != 0) + return false; + + if (strcmp_P (command + 9, PSTR ("valid?")) == 0) + subCommand = ISVALID; + else if (strcmp_P (command + 9, PSTR ("version")) == 0) + subCommand = GETVERSION; + else + return false; + + switch (subCommand) { + case ISVALID: + Serial.println (EEPROMSettings.isValid () ? F("yes") : F("no")); + break; + case GETVERSION: + Serial.println (EEPROMSettings.version ()); + break; + } + + Serial.read (); + + return true; + } +}; diff --git a/src/Kaleidoscope/EEPROM-Settings-Focus.h b/src/Kaleidoscope/EEPROM-Settings-Focus.h new file mode 100644 index 00000000..67667e82 --- /dev/null +++ b/src/Kaleidoscope/EEPROM-Settings-Focus.h @@ -0,0 +1,33 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-EEPROM-Settings -- Basic EEPROM settings plugin for Kaleidoscope. + * Copyright (C) 2017 Gergely Nagy + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include + +namespace FocusHooks { + bool settings (const char *command); +}; + +#define FOCUS_HOOK_SETTINGS FOCUS_HOOK(FocusHooks::settings, \ + "settings.valid?\n" \ + "---------------\n" \ + "Return whether the EEPROM settings are valid, or not.\n\n" \ + "settings.version\n" \ + "----------------\n" \ + "Return the version of the EEPROM settings.")