Test Code for OV7670 Camera module. The images are sent over ethernet link.

Dependencies:   EthernetInterface mbed-rtos mbed ov7670

You can find more information in this page: https://mbed.org/users/edodm85/notebook/ov7670-camera-and-ethernet-stream/

Files at this revision

API Documentation at this revision

Comitter:
edodm85
Date:
Sat Jul 20 16:36:31 2013 +0000
Parent:
0:2208b72b1ba1
Child:
2:d6b38a4512eb
Commit message:
updated "for" condition

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Jul 15 20:51:31 2013 +0000
+++ b/main.cpp	Sat Jul 20 16:36:31 2013 +0000
@@ -1,6 +1,6 @@
 /*
  * Author: Edoardo De Marchi
- * Date: 15/07/13
+ * Date: 20/07/13
  * Notes: OV7670 camera with Ethernet Connection
 */
 
@@ -19,10 +19,8 @@
     led1 = 0;               
     led2 = 0;        // mbed status       
     led3 = 0;        // Ethernet link enable/disable      
-    led4 = 0;               
-    
-    
-    
+    led4 = 0;        // Snap status       
+      
     //ETHERNET
     eth.init(ip, mask, gateway);
     eth.connect();
@@ -41,7 +39,6 @@
 int main (void) 
 {
     Init();
-
     t.start();
     
     while (true)
@@ -58,9 +55,9 @@
     while (true) 
     {
         led3 = 1;
-        ////printf("\r\nWait for new connection...\r\n");
+        //printf("\r\nWait for new connection...\r\n");
         server.accept(client);
-        //printf("Connection from: %s\r\n", client.get_address());
+        printf("Connection from: %s\r\n", client.get_address());
         while (true) 
         {
             led3 = 0;
@@ -170,6 +167,20 @@
                     sprintf(bufferTX, "Tot time acq + send (mbed): %dms\r\n", t2-t1);
                     client.send_all(bufferTX, sizeof(bufferTX));
                     memset(bufferTX, 0, sizeof(bufferTX));
+            }else
+            if(strcmp("reg", bufferRX) == 0)              
+            {
+                    int n = 0;
+                    int g = 0;
+                    int c = 650;
+                    for (int i=0;i<201;i++) 
+                    {
+                        n = snprintf(bufferTX+g, c, "%02X", camera.ReadReg(i));
+                        g = g + n; 
+                        c = c - n - 1;                                          
+                    }                    
+                    client.send_all(bufferTX, sizeof(bufferTX));                       
+                    memset(bufferTX, 0, sizeof(bufferTX));     
             }    
             memset(bufferRX, 0, sizeof(bufferRX));           
 }
@@ -189,9 +200,9 @@
         int p = 0;         
         if(format == 'b')                       // B&W  
         {  
-            for(int x = 0; x<resolution/9600; x++)
+            for(int x = 0; x<resolution/sizeof(bufferTX); x++)
             {
-                for(int q = 0; q<9600; q++)
+                for(int q = 0; q<sizeof(bufferTX); q++)
                 { 
                        // Read in the first half of the image
                        if(resolution != VGA)
@@ -205,9 +216,9 @@
         
         if(format == 'y' || format == 'r')          // Color
         {
-            for(int x = 0; x<(resolution/9600)*2; x++)
+            for(int x = 0; x<(resolution/sizeof(bufferTX))*2; x++)
             {
-                for(int q = 0; q<9600/2; q++)
+                for(int q = 0; q<sizeof(bufferTX)/2; q++)
                 {
                        p = q*2;         
                        // Read in the first half of the image
@@ -226,6 +237,6 @@
                 // Now wait for the image to finish being captured
         while (camera.CaptureDone() == false);
         
-        //pc.printf("Snap_done\r\n");   
+        //printf("Snap_done\r\n");   
         led4 = 0;
 }
\ No newline at end of file