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:
43:0d1886f4848a
Parent:
42:c4e1606087ff
Child:
44:15de535c4005
--- a/Hardwares/ArduCAM.cpp	Fri Mar 24 15:44:08 2017 +0000
+++ b/Hardwares/ArduCAM.cpp	Mon Mar 27 22:09:22 2017 +0000
@@ -107,6 +107,7 @@
     g_core.GetUSBServer().PushReliableMsg('D', "CameraInit Su");
     
     //ardu_cam_set_mode(MCU2LCD_MODE);
+    ardu_cam_spi_write_8(ARDUCHIP_CAP_CTRL, 0x00);
     ardu_cam_start_capture();
     
     wait(0.1);
@@ -126,7 +127,7 @@
 void ardu_cam_start_capture()
 {
     ardu_cam_spi_write_8(ARDUCHIP_FIFO, FIFO_CLEAR_MASK);
-    ardu_cam_spi_write_8(ARDUCHIP_CAP_CTRL, 0x00);
+    //wait(0.1);
     ardu_cam_spi_write_8(ARDUCHIP_FIFO, FIFO_START_MASK);
 }
 
@@ -180,20 +181,8 @@
     //ardu_cam_spi_set_burst();
 
     //ardu_cam_get_pixel(); //Get the first dummy pixel
-    //ardu_utft_set_xy(0, 0, 319, 239);
-    for (uint8_t i = 0; i < RESOLUTION_HEIGHT; ++i)
-    {
-        ardu_utft_set_xy(0, i + 20, 300, i + 20);
-        for (int j = 0; j < RESOLUTION_WIDTH; ++j)
-        {
-            uint8_t VH = ardu_cam_spi_read_8(SINGLE_FIFO_READ);
-            uint8_t VL = ardu_cam_spi_read_8(SINGLE_FIFO_READ);
-            
-            ardu_utft_write_DATA(VH, VL);
-        }
-    }
 
-/*
+
     for (uint8_t i = 0; i < RESOLUTION_HEIGHT; ++i)
     {
 #if defined(MANUAL_REDUCE_RESULOTION_BY2)
@@ -237,5 +226,25 @@
 #endif
         
     }
-*/
+
+}
+
+void ardu_cam_display_img_utft()
+{
+    ardu_cam_start_capture();
+    wait(0.2);
+    while(ardu_cam_get_fifo_length() < (RESOLUTION_WIDTH * RESOLUTION_HEIGHT * 2))
+    {
+    }
+    for (uint8_t i = 0; i < RESOLUTION_HEIGHT; ++i)
+    {
+        ardu_utft_set_xy(0, i + 20, 300, i + 20);
+        for (int j = 0; j < RESOLUTION_WIDTH; ++j)
+        {
+            uint8_t VH = ardu_cam_spi_read_8(SINGLE_FIFO_READ);
+            uint8_t VL = ardu_cam_spi_read_8(SINGLE_FIFO_READ);
+            
+            ardu_utft_write_DATA(VH, VL);
+        }
+    }
 }
\ No newline at end of file