Seminar

Dependencies:   mbed ov7670class

Revision:
0:21c8b8b4abbe
Child:
1:8ad6f9c44937
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jan 27 16:17:58 2018 +0000
@@ -0,0 +1,70 @@
+#include "mbed.h"
+#include "ov7670s.h"
+
+OV7670 camera(
+    D14, D15,       // SDA,SCL(I2C / SCCB)
+    D9,D8,D10,   // VSYNC,HREF,pcclk
+    D7,D6,D5,D4,D3,D2,D1,D0,
+    A5) ; // RRST
+
+Serial pc(USBTX,USBRX);
+
+#define SIZEX (160)
+#define SIZEY (120)
+#define SIZE 19200
+
+unsigned char bank0 [SIZE];
+unsigned char *bank1 = (unsigned char *)(0x2007C000);
+
+int main()
+{
+
+
+
+    // Reset camera on power up
+    camera.Reset() ;
+
+    // Set up for 160*120 pixels RGB565
+    camera.InitQQVGA() ;
+
+    // Print message to screen
+    pc.printf("Hit Any Key to stop RGBx160x120 Capture Data.\r\n");
+
+    // Kick things off by capturing an image
+    camera.CaptureNext() ;
+    while (camera.CaptureDone() == false) ;
+
+    // Now enter the main loop
+    while (!pc.readable()) {
+
+        // Start reading in the image data from the camera hardware buffer
+        camera.ReadStart();
+
+        // Read in the first half of the image
+        for (int i = 0; i < SIZE; i++) {
+            bank0[i] =  camera.ReadOneByte();
+        }
+
+        // Read in the second half of the image
+        for (int i = 0; i < SIZE ; i++) {
+            bank1[i] =  camera.ReadOneByte();
+        }
+
+        // Stop reading the image
+        camera.ReadStop() ;
+
+        // Immediately request the next image to be captured (takes around 45ms)
+        camera.CaptureNext() ;
+
+        // Use this time to display the image on the screen
+        // Display the top half
+        TFT.Bitmap(0,0,160,60,bank1);
+        // Display the bottom half
+        TFT.Bitmap(0,60,160,60,bank0);
+
+        /* Note: we still have around 15ms left here to do other stuff */
+
+        // Now wait for the image to finish being captured
+        while (camera.CaptureDone() == false) ;
+    }
+}