소스 검색

Updated bluetooth

Tom Remeeus 11 년 전
부모
커밋
f49635ce74
1개의 변경된 파일37개의 추가작업 그리고 3개의 파일을 삭제
  1. 37 3
      Bluetooth.java

+ 37 - 3
Bluetooth.java

@@ -1,7 +1,7 @@
 package boebot;
 package boebot;
 import stamp.core.*;
 import stamp.core.*;
 
 
-public class Bluetooth
+public class Bluetooth extends Aansturing
 {
 {
   final static int SERIAL_RX_PIN  = CPU.pin14;
   final static int SERIAL_RX_PIN  = CPU.pin14;
   final static int SERIAL_TX_PIN  = CPU.pin15;
   final static int SERIAL_TX_PIN  = CPU.pin15;
@@ -40,13 +40,13 @@ public class Bluetooth
     }
     }
   }
   }
 
 
-  public char[] givenRoute()
+  private char[] givenRoute()
   {
   {
     char[] sendRoute = route;
     char[] sendRoute = route;
     return sendRoute;
     return sendRoute;
   }
   }
 
 
-  public char[] calculateRoute()
+  private char[] calculateRoute()
   {
   {
     char[] sendRoute = new char[40];
     char[] sendRoute = new char[40];
     int charTest = 0;
     int charTest = 0;
@@ -70,4 +70,38 @@ public class Bluetooth
 
 
     return sendRoute;
     return sendRoute;
   }
   }
+
+  public void remoteControl(int pin)
+  {
+    while (true)
+    {
+      if (rxUart.byteAvailable())
+      {
+        char command = (char)rxUart.receiveByte();
+        boolean IR = false;
+
+        switch (command)
+        {
+          case 'v':
+            super.vooruit();
+            break;
+          case 'a':
+            super.achteruit();
+            break;
+          case 'l':
+            super.turnleft();
+            break;
+          case 'r':
+            super.turnrechts();
+            break;
+          case 's':
+            super.stop();
+            break;
+          case 'i':
+            CPU.writePin(CPU.pins[pin], !IR);
+            break;
+        }
+      }
+    }
+  }
 }
 }