@ -24,32 +24,43 @@ namespace eeprom {
EventHandlerResult FocusSettingsCommand : : onFocusEvent ( const char * command ) {
EventHandlerResult FocusSettingsCommand : : onFocusEvent ( const char * command ) {
enum {
enum {
ISVALID ,
DEFAULT_LAYER ,
GETVERSION ,
IS_VALID ,
GET_VERSION ,
CRC ,
CRC ,
} sub_command ;
} sub_command ;
if ( : : Focus . handleHelp ( command , PSTR ( " settings. valid?\n settings.version \n settings.crc " ) ) )
if ( : : Focus . handleHelp ( command , PSTR ( " settings. defaultLayer\n settings. valid?\n settings.version \n settings.crc " ) ) )
return EventHandlerResult : : OK ;
return EventHandlerResult : : OK ;
if ( strncmp_P ( command , PSTR ( " settings. " ) , 9 ) ! = 0 )
if ( strncmp_P ( command , PSTR ( " settings. " ) , 9 ) ! = 0 )
return EventHandlerResult : : OK ;
return EventHandlerResult : : OK ;
if ( strcmp_P ( command + 9 , PSTR ( " valid? " ) ) = = 0 )
if ( strcmp_P ( command + 9 , PSTR ( " defaultLayer " ) ) = = 0 )
sub_command = ISVALID ;
sub_command = DEFAULT_LAYER ;
else if ( strcmp_P ( command + 9 , PSTR ( " valid? " ) ) = = 0 )
sub_command = IS_VALID ;
else if ( strcmp_P ( command + 9 , PSTR ( " version " ) ) = = 0 )
else if ( strcmp_P ( command + 9 , PSTR ( " version " ) ) = = 0 )
sub_command = GETVERSION ;
sub_command = GET _ VERSION;
else if ( strcmp_P ( command + 9 , PSTR ( " crc " ) ) = = 0 )
else if ( strcmp_P ( command + 9 , PSTR ( " crc " ) ) = = 0 )
sub_command = CRC ;
sub_command = CRC ;
else
else
return EventHandlerResult : : OK ;
return EventHandlerResult : : OK ;
switch ( sub_command ) {
switch ( sub_command ) {
case ISVALID :
case DEFAULT_LAYER : {
if ( Serial . peek ( ) = = ' \n ' ) {
Serial . println ( : : EEPROMSettings . default_layer ( ) ) ;
} else {
: : EEPROMSettings . default_layer ( Serial . parseInt ( ) ) ;
}
break ;
}
case IS_VALID :
: : Focus . printBool ( : : EEPROMSettings . isValid ( ) ) ;
: : Focus . printBool ( : : EEPROMSettings . isValid ( ) ) ;
Serial . println ( ) ;
Serial . println ( ) ;
break ;
break ;
case GETVERSION :
case GET _ VERSION:
Serial . println ( : : EEPROMSettings . version ( ) ) ;
Serial . println ( : : EEPROMSettings . version ( ) ) ;
break ;
break ;
case CRC :
case CRC :