change car control keys from f,b,r,l to w,s,d,a, :D
This commit is contained in:
@@ -26,11 +26,12 @@ fun main(args: Array<String>) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val fileConfig = readFileConfig()
|
val fileConfig = readFileConfig()
|
||||||
//if argument get in console, then its primary, else from config, else default
|
|
||||||
val host = getActualValue("host", clArgsConfig, fileConfig)
|
val host = getActualValue("host", clArgsConfig, fileConfig)
|
||||||
val port = getActualValue("port", clArgsConfig, fileConfig, "8888").toInt()
|
val port = getActualValue("port", clArgsConfig, fileConfig, "8888").toInt()
|
||||||
val mcuSystem = getActualValue("mcuSystem", clArgsConfig, fileConfig, "0x08000000")
|
val mcuSystem = getActualValue("mcuSystem", clArgsConfig, fileConfig, "0x08000000")
|
||||||
val flashFilePath = getActualValue("flash", clArgsConfig, fileConfig)
|
val flashFilePath = getActualValue("flash", clArgsConfig, fileConfig)
|
||||||
|
|
||||||
val actualValues = mapOf<String, String>(Pair("host", host), Pair("port", port.toString()), Pair("mcuSystem", mcuSystem), Pair("flash", flashFilePath))
|
val actualValues = mapOf<String, String>(Pair("host", host), Pair("port", port.toString()), Pair("mcuSystem", mcuSystem), Pair("flash", flashFilePath))
|
||||||
saveFileConfig(actualValues)
|
saveFileConfig(actualValues)
|
||||||
var fileBytes: ByteArray = ByteArray(0);
|
var fileBytes: ByteArray = ByteArray(0);
|
||||||
|
|||||||
@@ -19,19 +19,19 @@ class CarControl constructor(client: Client) {
|
|||||||
|
|
||||||
val directionBuilder = RouteP.Direction.newBuilder()
|
val directionBuilder = RouteP.Direction.newBuilder()
|
||||||
when (direction) {
|
when (direction) {
|
||||||
'f' -> {
|
'w' -> {
|
||||||
directionBuilder.setCommand(Command.forward)
|
directionBuilder.setCommand(Command.forward)
|
||||||
}
|
}
|
||||||
'b' -> {
|
's' -> {
|
||||||
directionBuilder.setCommand(Command.backward)
|
directionBuilder.setCommand(Command.backward)
|
||||||
}
|
}
|
||||||
'r' -> {
|
'd' -> {
|
||||||
directionBuilder.setCommand(Command.right)
|
directionBuilder.setCommand(Command.right)
|
||||||
}
|
}
|
||||||
'l' -> {
|
'a' -> {
|
||||||
directionBuilder.setCommand(Command.left)
|
directionBuilder.setCommand(Command.left)
|
||||||
}
|
}
|
||||||
's' -> {
|
'h' -> {
|
||||||
directionBuilder.setCommand(Command.stop)
|
directionBuilder.setCommand(Command.stop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.martiansoftware.jsap.JSAP
|
|||||||
* Created by user on 7/14/16.
|
* 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>) {
|
fun main(args: Array<String>) {
|
||||||
val jsap: JSAP = JSAP()
|
val jsap: JSAP = JSAP()
|
||||||
@@ -33,7 +33,7 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun initTextInterface(carControl: CarControl) {
|
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)
|
println(helpMessage)
|
||||||
|
|
||||||
while (true) {
|
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 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 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')
|
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(opthost)
|
||||||
jsap.registerParameter(optPort)
|
jsap.registerParameter(optPort)
|
||||||
jsap.registerParameter(optHelp)
|
jsap.registerParameter(optHelp)
|
||||||
|
|||||||
Reference in New Issue
Block a user