diff --git a/app/src/main/java/se/liu/vikro145/bluetoothcontrol/CommandButton.java b/app/src/main/java/se/liu/vikro145/bluetoothcontrol/CommandButton.java index 17e8292d0b5217b0343e98c86c6c3dfb34807617..b6c3d4fdd9c21540d0d273e8cfeaa7aea9d4c35d 100644 --- a/app/src/main/java/se/liu/vikro145/bluetoothcontrol/CommandButton.java +++ b/app/src/main/java/se/liu/vikro145/bluetoothcontrol/CommandButton.java @@ -9,7 +9,8 @@ import java.util.Timer; import java.util.TimerTask; public class CommandButton { - public static int RESEND_TIME = 100; // Time in ms for commands to be re-sent to Arduino + final private static int RESEND_TIME = 100; // Time in ms for commands to be re-sent to Arduino + final private static int TIME_BEFORE_STOP = 100; private Button btn; private String cmd; @@ -92,6 +93,15 @@ public class CommandButton { sendArduinoCmdTask = new SendArduinoCmd(); timer = new Timer(); + + // Send stop command when button is no longer pressed + String cmdText = "s"; + + // Debug + System.out.println("Sending command: " + cmdText); + + // Send command to Arduino board + connectedThread.write(cmdText); } return true;