@ -33,24 +33,37 @@ namespace raise {
# define RAISE_FIRMWARE_VERSION "<unknown>"
# define RAISE_FIRMWARE_VERSION "<unknown>"
# endif
# endif
EventHandlerResult Focus : : onFocusEvent ( const char * command ) {
EventHandlerResult Focus : : onFocusEvent ( const char * input ) {
if ( : : Focus . handleHelp ( command , PSTR ( " hardware.version \r \n hardware.side_power \r \n hardware.side_ver \r \n hardware.sled_ver \r \n hardware.sled_current \r \n hardware.layout \r \n hardware.joint \r \n hardware.keyscan \r \n hardware.crc_errors \r \n hardware.firmware " ) ) )
const char * cmd_version = PSTR ( " hardware.version " ) ;
return EventHandlerResult : : OK ;
const char * cmd_side_power = PSTR ( " hardware.side_power " ) ;
const char * cmd_side_ver = PSTR ( " hardware.side_ver " ) ;
if ( strncmp_P ( command , PSTR ( " hardware. " ) , 9 ) ! = 0 )
const char * cmd_sled_ver = PSTR ( " hardware.sled_ver " ) ;
return EventHandlerResult : : OK ;
const char * cmd_sled_current = PSTR ( " hardware.sled_current " ) ;
const char * cmd_layout = PSTR ( " hardware.layout " ) ;
if ( strcmp_P ( command + 9 , PSTR ( " version " ) ) = = 0 ) {
const char * cmd_joint = PSTR ( " hardware.joint " ) ;
const char * cmd_keyscan = PSTR ( " hardware.keyscan " ) ;
const char * cmd_crc_errors = PSTR ( " hardware.crc_errors " ) ;
const char * cmd_firmware = PSTR ( " hardware.firmware " ) ;
if ( : : Focus . inputMatchesHelp ( input ) )
return : : Focus . printHelp ( cmd_version ,
cmd_side_power ,
cmd_side_ver ,
cmd_sled_ver ,
cmd_sled_current ,
cmd_layout ,
cmd_joint ,
cmd_keyscan ,
cmd_crc_errors ,
cmd_firmware ) ;
if ( : : Focus . inputMatchesCommand ( input , cmd_version ) ) {
: : Focus . send ( " Dygma Raise " ) ;
: : Focus . send ( " Dygma Raise " ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
}
} else if ( : : Focus . inputMatchesCommand ( input , cmd_firmware ) ) {
if ( strcmp_P ( command + 9 , PSTR ( " firmware " ) ) = = 0 ) {
: : Focus . send ( RAISE_FIRMWARE_VERSION ) ;
: : Focus . send ( RAISE_FIRMWARE_VERSION ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
}
} else if ( : : Focus . inputMatchesCommand ( input , cmd_side_power ) ) {
if ( strcmp_P ( command + 9 , PSTR ( " side_power " ) ) = = 0 ) {
if ( : : Focus . isEOL ( ) ) {
if ( : : Focus . isEOL ( ) ) {
: : Focus . send ( Runtime . device ( ) . side . getPower ( ) ) ;
: : Focus . send ( Runtime . device ( ) . side . getPower ( ) ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
@ -60,33 +73,25 @@ EventHandlerResult Focus::onFocusEvent(const char *command) {
Runtime . device ( ) . side . setPower ( power ) ;
Runtime . device ( ) . side . setPower ( power ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
}
}
}
} else if ( : : Focus . inputMatchesCommand ( input , cmd_side_ver ) ) {
if ( strcmp_P ( command + 9 , PSTR ( " side_ver " ) ) = = 0 ) {
: : Focus . send ( " left: " ) ;
: : Focus . send ( " left: " ) ;
: : Focus . send ( Runtime . device ( ) . side . leftVersion ( ) ) ;
: : Focus . send ( Runtime . device ( ) . side . leftVersion ( ) ) ;
: : Focus . send ( " \r \n right: " ) ;
: : Focus . send ( " \r \n right: " ) ;
: : Focus . send ( Runtime . device ( ) . side . rightVersion ( ) ) ;
: : Focus . send ( Runtime . device ( ) . side . rightVersion ( ) ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
}
} else if ( : : Focus . inputMatchesCommand ( input , cmd_crc_errors ) ) {
if ( strcmp_P ( command + 9 , PSTR ( " crc_errors " ) ) = = 0 ) {
: : Focus . send ( " left: " ) ;
: : Focus . send ( " left: " ) ;
: : Focus . send ( Runtime . device ( ) . side . leftCRCErrors ( ) ) ;
: : Focus . send ( Runtime . device ( ) . side . leftCRCErrors ( ) ) ;
: : Focus . send ( " \r \n right: " ) ;
: : Focus . send ( " \r \n right: " ) ;
: : Focus . send ( Runtime . device ( ) . side . rightCRCErrors ( ) ) ;
: : Focus . send ( Runtime . device ( ) . side . rightCRCErrors ( ) ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
}
} else if ( : : Focus . inputMatchesCommand ( input , cmd_sled_ver ) ) {
if ( strcmp_P ( command + 9 , PSTR ( " sled_ver " ) ) = = 0 ) {
: : Focus . send ( " left: " ) ;
: : Focus . send ( " left: " ) ;
: : Focus . send ( Runtime . device ( ) . side . leftSLEDVersion ( ) ) ;
: : Focus . send ( Runtime . device ( ) . side . leftSLEDVersion ( ) ) ;
: : Focus . send ( " \r \n right: " ) ;
: : Focus . send ( " \r \n right: " ) ;
: : Focus . send ( Runtime . device ( ) . side . rightSLEDVersion ( ) ) ;
: : Focus . send ( Runtime . device ( ) . side . rightSLEDVersion ( ) ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
}
} else if ( : : Focus . inputMatchesCommand ( input , cmd_sled_current ) ) {
if ( strcmp_P ( command + 9 , PSTR ( " sled_current " ) ) = = 0 ) {
if ( : : Focus . isEOL ( ) ) {
if ( : : Focus . isEOL ( ) ) {
: : Focus . send ( " left: " ) ;
: : Focus . send ( " left: " ) ;
: : Focus . send ( Runtime . device ( ) . side . leftSLEDCurrent ( ) ) ;
: : Focus . send ( Runtime . device ( ) . side . leftSLEDCurrent ( ) ) ;
@ -99,20 +104,14 @@ EventHandlerResult Focus::onFocusEvent(const char *command) {
Runtime . device ( ) . side . setSLEDCurrent ( current ) ;
Runtime . device ( ) . side . setSLEDCurrent ( current ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
}
}
}
} else if ( : : Focus . inputMatchesCommand ( input , cmd_layout ) ) {
if ( strcmp_P ( command + 9 , PSTR ( " layout " ) ) = = 0 ) {
static const auto ANSI = Runtime . device ( ) . settings . Layout : : ANSI ;
static const auto ANSI = Runtime . device ( ) . settings . Layout : : ANSI ;
: : Focus . send ( Runtime . device ( ) . settings . layout ( ) = = ANSI ? " ANSI " : " ISO " ) ;
: : Focus . send ( Runtime . device ( ) . settings . layout ( ) = = ANSI ? " ANSI " : " ISO " ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
}
} else if ( : : Focus . inputMatchesCommand ( input , cmd_joint ) ) {
if ( strcmp_P ( command + 9 , PSTR ( " joint " ) ) = = 0 ) {
: : Focus . send ( Runtime . device ( ) . settings . joint ( ) ) ;
: : Focus . send ( Runtime . device ( ) . settings . joint ( ) ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;
}
} else if ( : : Focus . inputMatchesCommand ( input , cmd_keyscan ) ) {
if ( strcmp_P ( command + 9 , PSTR ( " keyscan " ) ) = = 0 ) {
if ( : : Focus . isEOL ( ) ) {
if ( : : Focus . isEOL ( ) ) {
: : Focus . send ( Runtime . device ( ) . settings . keyscanInterval ( ) ) ;
: : Focus . send ( Runtime . device ( ) . settings . keyscanInterval ( ) ) ;
return EventHandlerResult : : EVENT_CONSUMED ;
return EventHandlerResult : : EVENT_CONSUMED ;