change car control keys from f,b,r,l to w,s,d,a, :D

This commit is contained in:
MaximZaitsev
2016-07-15 11:56:56 +03:00
parent 98bc116438
commit 1dd5d8c1c4
3 changed files with 10 additions and 9 deletions
+2 -1
View File
@@ -26,11 +26,12 @@ fun main(args: Array<String>) {
return
}
val fileConfig = readFileConfig()
//if argument get in console, then its primary, else from config, else default
val host = getActualValue("host", clArgsConfig, fileConfig)
val port = getActualValue("port", clArgsConfig, fileConfig, "8888").toInt()
val mcuSystem = getActualValue("mcuSystem", clArgsConfig, fileConfig, "0x08000000")
val flashFilePath = getActualValue("flash", clArgsConfig, fileConfig)
val actualValues = mapOf<String, String>(Pair("host", host), Pair("port", port.toString()), Pair("mcuSystem", mcuSystem), Pair("flash", flashFilePath))
saveFileConfig(actualValues)
var fileBytes: ByteArray = ByteArray(0);
@@ -19,19 +19,19 @@ class CarControl constructor(client: Client) {
val directionBuilder = RouteP.Direction.newBuilder()
when (direction) {
'f' -> {
'w' -> {
directionBuilder.setCommand(Command.forward)
}
'b' -> {
's' -> {
directionBuilder.setCommand(Command.backward)
}
'r' -> {
'd' -> {
directionBuilder.setCommand(Command.right)
}
'l' -> {
'a' -> {
directionBuilder.setCommand(Command.left)
}
's' -> {
'h' -> {
directionBuilder.setCommand(Command.stop)
}
}
+3 -3
View File
@@ -6,7 +6,7 @@ import com.martiansoftware.jsap.JSAP
* Created by user on 7/14/16.
*/
val correctDirectionValues: Array<Char> = arrayOf('f', 'b', 'l', 'r', 's');
val correctDirectionValues: Array<Char> = arrayOf('w', 's', 'a', 'd', 'h');
fun main(args: Array<String>) {
val jsap: JSAP = JSAP()
@@ -33,7 +33,7 @@ fun main(args: Array<String>) {
}
fun initTextInterface(carControl: CarControl) {
val helpMessage = "type f, b, l, r, s for command forward, backward, left, right, stop. to exit type q or quit ";
val helpMessage = "type w, s, a, d, h for command forward, backward, left, right, stop. to exit type q or quit ";
println(helpMessage)
while (true) {
@@ -63,7 +63,7 @@ fun setOptions(jsap: JSAP) {
val optPort = FlaggedOption("port").setStringParser(JSAP.INTEGER_PARSER).setDefault("8888").setRequired(false).setShortFlag('p').setLongFlag("port")
val optHelp = FlaggedOption("help").setStringParser(JSAP.BOOLEAN_PARSER).setRequired(false).setDefault("false").setLongFlag("help")
val optDirection = FlaggedOption("direction").setStringParser(JSAP.CHARACTER_PARSER).setRequired(false).setDefault("t").setShortFlag('d')
optDirection.setHelp("move direction: available values - one symbol:\n\"f (forward),b (backward),l (left),r (right),s (stop)\". example: -d f\nwithout argument used default \"t\" - running text interface")
optDirection.setHelp("move direction: available values - one symbol:\n\"w (forward),s (backward),a (left),f (right),h (stop)\". example: -d w\nwithout argument used default \"t\" - running text interface")
jsap.registerParameter(opthost)
jsap.registerParameter(optPort)
jsap.registerParameter(optHelp)