diff --git a/ino/takeup/takeup.ino b/ino/takeup/takeup.ino index 65bb38f..48e7320 100644 --- a/ino/takeup/takeup.ino +++ b/ino/takeup/takeup.ino @@ -93,7 +93,7 @@ void loop() { } if (cmdChar != 'z') { - cmd(cmdChar); + cmd(cmdChar, 0); } cmdChar = 'z'; @@ -103,7 +103,7 @@ void loop() { } if (cmdChar != 'z') { - cmd(cmdChar); + cmd(cmdChar, 1); } cmdChar = 'z'; @@ -116,11 +116,11 @@ void loop() { } } -void cmd (char which) { +void cmd (char which, int source) { if (which == Fcmd && !Frunning) { - forward(); + forward(source); } else if (which == Bcmd && !Brunning) { - backward(); + backward(source); } else if (which == cmd_debug) { debug(); } else if (which == cmd_connect) { @@ -130,15 +130,25 @@ void cmd (char which) { } } -void forward () { +void forward (int source) { log("forward()"); + if (source == 0) { + Serial.println(Fcmd); + } else if (source == 1) { + softSerial.write(Fcmd); + } Ftime = timer; set_speed(Fmotor, frameSpeed); clockwise(Fmotor); } -void backward () { +void backward (int source) { log("backward()"); + if (source == 0) { + Serial.println(Bcmd); + } else if (source == 1) { + softSerial.write(Bcmd); + } Btime = timer; set_speed(Bmotor, frameSpeed); counter_clockwise(Bmotor); @@ -294,9 +304,9 @@ void btnCmd (int index, int time) { int multiple = floor(time / buttonPress); if (multiple > ButtonMultiple[index]) { if (index == Fmotor) { - cmd(Fcmd); + cmd(Fcmd, 0); } else if (index == Bmotor) { - cmd(Bcmd); + cmd(Bcmd, 0); } ButtonMultiple[index] = multiple; }