Focus hooks shall follow the style guide more closely

Moved them to the a namespace much more fitting, and renamed the hooks too.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 7 years ago
parent c5980dc5a6
commit ae8cd514a2

@ -20,9 +20,10 @@
#include <Kaleidoscope-Focus.h> #include <Kaleidoscope-Focus.h>
#include "crc.h" #include "crc.h"
namespace FocusHooks { namespace kaleidoscope {
namespace eeprom_settings {
bool settings(const char *command) { bool settingsFocusHook(const char *command) {
enum { enum {
ISVALID, ISVALID,
GETVERSION, GETVERSION,
@ -43,23 +44,23 @@ bool settings(const char *command) {
switch (sub_command) { switch (sub_command) {
case ISVALID: case ISVALID:
Focus.printBool(EEPROMSettings.isValid()); Focus.printBool(::EEPROMSettings.isValid());
Serial.println(); Serial.println();
break; break;
case GETVERSION: case GETVERSION:
Serial.println(EEPROMSettings.version()); Serial.println(::EEPROMSettings.version());
break; break;
case CRC: case CRC:
Serial.print(::CRC.crc, HEX); Serial.print(::CRC.crc, HEX);
Serial.print(F("/")); Serial.print(F("/"));
Serial.println(EEPROMSettings.crc(), HEX); Serial.println(::EEPROMSettings.crc(), HEX);
break; break;
} }
return true; return true;
} }
bool eeprom(const char *command) { bool eepromFocusHook(const char *command) {
enum { enum {
CONTENTS, CONTENTS,
FREE, FREE,
@ -91,7 +92,7 @@ bool eeprom(const char *command) {
break; break;
} }
case FREE: case FREE:
Serial.println(EEPROM.length() - EEPROMSettings.used()); Serial.println(EEPROM.length() - ::EEPROMSettings.used());
break; break;
} }
@ -99,3 +100,5 @@ bool eeprom(const char *command) {
} }
} }
}

@ -20,16 +20,22 @@
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
namespace FocusHooks { namespace kaleidoscope {
bool settings(const char *command); namespace eeprom_settings {
bool eeprom(const char *command);
};
#define FOCUS_HOOK_SETTINGS FOCUS_HOOK(FocusHooks::settings, \ bool settingsFocusHook(const char *command);
"settings.valid?\n" \ bool eepromFocusHook(const char *command);
"settings.version\n" \
"settings.crc")
#define FOCUS_HOOK_EEPROM FOCUS_HOOK(FocusHooks::eeprom, \ }
"eeprom.free\n" \ }
"eeprom.contents")
#define FOCUS_HOOK_SETTINGS FOCUS_HOOK \
(kaleidoscope::eeprom_settings::settingsFocusHook, \
"settings.valid?\n" \
"settings.version\n" \
"settings.crc")
#define FOCUS_HOOK_EEPROM FOCUS_HOOK \
(kalediscope::eeprom_settings::eepromFocusHook, \
"eeprom.free\n" \
"eeprom.contents")

Loading…
Cancel
Save