sssssss

Dependencies:   mbed

Revision:
0:61a9b89ce451
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jul 09 07:42:47 2014 +0000
@@ -0,0 +1,147 @@
+//
+// OV7670 + FIFO AL422B camera board test
+//
+#include "mbed.h"
+#include "ov7670.h"
+
+ //OV7670 camera(PTE0,PTE1,PTD6,PTD7,PTE31,PTC17,PTC16,PTC13,PTC12,PTC6,PTC5,PTC4,PTC3,PTB8,PTB9,PTB10); 
+/*W*///OV7670 camera(PTE0,PTE1,PTD6,PTA17,PTD7,PTC17,PTC16,PTC13,PTC12,PTC6,PTC5,PTC4,PTC3,PTB8,PTB9,PTB10);
+OV7670 camera(PTE0,PTE1,PTD6,PTD7,PTE31,PortC,0x1e3c,PTB8,PTB9,PTB10); 
+Serial pc(USBTX,USBRX) ;
+
+
+#define SIZEX (160)
+#define SIZEY (120)
+
+int main() {
+    int i ;
+    pc.baud(115200) ;
+    pc.printf("Camera resetting..\r\n") ;
+
+    camera.Reset() ;
+
+    pc.printf("Before Init...\r\n") ;    
+    pc.printf("AD : +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F") ;
+    for (i=0;i<OV7670_REGMAX;i++) {
+        int data ;
+        data = camera.ReadReg(i) ; // READ REG
+        if ((i & 0x0F) == 0) {
+            pc.printf("\r\n%02X : ",i) ;
+        }
+        pc.printf("%02X ",data) ;
+    }
+    pc.printf("\r\n") ;
+
+    camera.InitQQVGA() ;
+
+    pc.printf("After Init...\r\n") ;    
+    pc.printf("AD : +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F") ;
+    for (i=0;i<OV7670_REGMAX;i++) {
+        int data ;
+        data = camera.ReadReg(i) ; // READ REG
+        if ((i & 0x0F) == 0) {
+            pc.printf("\r\n%02X : ",i) ;
+        }
+        pc.printf("%02X ",data) ;
+    }
+    pc.printf("\r\n") ;
+    
+    // CAPTURE and SEND LOOP
+    while(1)
+    {
+        pc.printf("Hit Any Key to send RGBx160x120 Capture Data.\r\n") ;
+        while(!pc.readable()) ;
+        pc.getc() ;
+        camera.CaptureNext() ;
+        while(camera.CaptureDone() == false) ;
+        pc.printf("*\r\n") ;
+        camera.ReadStart() ;
+        i = 0 ;
+        
+        
+        
+        for (int y = 0;y < SIZEY;y++) {
+           volatile int r,g,b,d1,d2 ;
+            for (int x = 0;x < SIZEX;x++) {
+               d1 = camera.ReadOneByte() ; // upper nibble is XXX , lower nibble is B
+                d2 = camera.ReadOneByte() ; // upper nibble is G   , lower nibble is R
+                b = (d1 & 0x0F) ;
+                g = (d2 & 0xF0) >> 4 ;
+                r = (d2 & 0x0F) ;
+                
+                
+          //      pc.printf("%d \r\n",r);
+          //       pc.printf("%d \r\n",g);
+          //        pc.printf("%d \r\n",b);
+          //        pc.printf(" ");
+                
+         //         wait_ms(1);
+                
+          //pc.printf("%",camera.ReadOneByte());
+           
+                  
+               pc.printf ("%1X %1X %1X \r\n",r,g,b) ;
+              //    pc.printf("%1X",r);           
+           
+           //   if(b<0x03)
+            //      pc.printf("O");
+            //  else
+            //      pc.printf(" ");    
+            
+            
+            /*
+                if( b  > 7 )
+                        pc.printf("O");
+               else 
+                      pc.printf(" ");
+              */      
+            
+            /*
+                if( b  > 12 )
+                        pc.printf("e");
+               else if( b  > 9 )
+                      pc.printf("d");    
+                else if( b  > 6 )
+                      pc.printf("c"); 
+                 else if( b  > 3 )
+                      pc.printf("b"); 
+                  else if( b  > 0x00 )       
+                        pc.printf("a");
+                  else
+                        pc.printf("X");      
+              */          
+                        
+                 /*        
+                   else if(b > 0x90 )
+                    pc.printf("9"); 
+                    else if( b  > 0x80 )
+                     pc.printf("8"); 
+                     else if( b  > 0x70 )
+                      pc.printf("7"); 
+                      else if( b  > 0x60 )
+                       pc.printf("6"); 
+                       else if(b  > 0x50 )
+                        pc.printf("5"); 
+                       
+                        else if( b  > 0x40 )
+                         pc.printf("4"); 
+                         else if(b  > 0x30 )
+                          pc.printf("3"); 
+                          else if( b  > 0x20 )
+                      pc.printf("2"); 
+                          else
+                           pc.printf("1"); 
+              
+            
+            */
+            
+            
+          //  pc.printf("%1X\r\n",camera.ReadOneByte());
+            
+           
+            }
+            pc.printf("\r\n") ;
+        }
+        camera.ReadStop() ;        
+    }
+}