From 44a93faeefd4f0193b62e78e3db2ed9ddb41c067 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Viktor=20R=C3=B6nnb=C3=A4ck?= <vikro145@student.liu.se>
Date: Sun, 19 Sep 2021 12:59:22 +0200
Subject: [PATCH] Final code for app

---
 .../liu/vikro145/bluetoothcontrol/CommandButton.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

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 17e8292..b6c3d4f 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;
-- 
GitLab