SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Revision:
5:577b582e4fe9
Parent:
3:c8867972ffc7
Child:
6:0682e1c90119
diff -r c8867972ffc7 -r 577b582e4fe9 main.cpp
--- a/main.cpp	Wed Feb 01 00:35:48 2017 +0000
+++ b/main.cpp	Fri Feb 03 03:59:42 2017 +0000
@@ -1,39 +1,32 @@
 #include "mbed.h"
+
 #include "Camera.h"
-#include "USBHID.h"
- 
-//We declare a USBHID device. Input out output reports have a length of 8 bytes
-USBHID hid(8, 8);
- 
-//This report will contain data to be sent
-HID_REPORT send_report;
-HID_REPORT recv_report;
- 
-Serial pc(USBTX, USBRX);
- 
+
+#include "USBHIDServer.h"
+
+DigitalOut led(LED1, 1);
+
 int main(void) {
-    Camera cam;
-    send_report.length = 8;
- 
-    while (1) {
-        //Fill the report
-        for (int i = 0; i < send_report.length; i++) {
-            send_report.data[i] = rand() & 0xff;
+    //Camera cam;
+    USBHIDServer server;
+    unsigned int testCount = 0;
+    unsigned int testCount2 = 0;
+    char buf[5];
+    
+    while (1) 
+    {
+        led = 0;
+        server.Update(0.0f);
+        testCount++;
+        if(testCount >= 10000)
+        {
+            testCount2++;
+            sprintf(buf, "%d", testCount2);
+            //server.PushUnreliableMsg('D', "Test Message!");
+            server.PushUnreliableMsg('D', buf);
+            testCount = 0;
         }
-            
-        //Send the report
-        hid.send(&send_report);
-        
-        //try to read a msg
-        if(hid.readNB(&recv_report)) {
-            pc.printf("recv: ");
-            for(int i = 0; i < recv_report.length; i++) {
-                pc.printf("%d ", recv_report.data[i]);
-            }
-            pc.printf("\r\n");
-        }
-        
-        wait(0.1);
+        //wait(0.01);
     }
 }