OV7670 without FIFO, SCCB protocol rewritten.

Dependents:   mycame wd_camera

Files at this revision

API Documentation at this revision

Comitter:
sylvainkritter
Date:
Tue Feb 16 14:37:26 2016 +0000
Parent:
0:2530e24fafa1
Commit message:
clean up

Changed in this revision

ov7670s.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ov7670s.cpp	Tue Feb 16 14:27:19 2016 +0000
+++ b/ov7670s.cpp	Tue Feb 16 14:37:26 2016 +0000
@@ -204,62 +204,8 @@
 
     }
 }
-/*
-void OV7670::searchpat(int th)
-{
-    int i,j,k, l, maxi, maxj;
-    int  car, tt,n0,n;
-    int max ;
-    max =th;
-    n0=0;
-    Time.start();
-    for (n=0; n<=nv; n++) {
-        for (i =0 ; i < nl-nlta; i++) {
-            for (j=0; j<nc-ncta; j++) {
-                tt=0;
-                for (k=0; k<nlta; k++) {
-                    for (l=0; l<ncta; l++) {
-                        car= bankta[k][l][n]-banktc[i+k][j+l];
-                        tt=tt+car*car;
-                        if (tt>th) {
-                            k =nlta;
-                            l=ncta;
-                        }
-                    }
-                }
-                max=tt;
-                // pc.printf("1  n: %d max: %d time: %f \r\n",n0,max, Time.read());
 
-                if (max<th) {
-                    maxi=i;
-                    maxj=j;
-                    n0=n;
-                    i=nl;
-                    j=nc;
-                    n=nv;
-                    // pc.printf("2  line: %d, column: %d, n: %d max: %d time: %f \r\n",maxi,maxj,n0,max, Time.read());
-                }
-            }
-        }
-    }
-    Time.stop();
-    TFT.Bitmap(160,120,160,120,bank);
-    if (tt<th) {
-        pc.printf("line: %d, column: %d, n: %d max: %d time: %f \r\n",maxi,maxj,n0,max, Time.read());
-        TFT.locate(160,20);
-        printf("Pat found %3.2f s",Time.read());
-        TFT.locate(160+maxj+(ncta/2),240-maxi-(nlta/2));
-        printf("X");
-        TFT.rect(160+maxj,240-maxi-nlta,160+maxj+ncta,240-maxi,Red);
-    } else {
-        TFT.locate(160,20);
-        printf("Not found %3.2f s",Time.read());
-        pc.printf("not found time: %4f n:%d max: %d \r\n",Time.read(), n0,max);
-    }
-    Time.reset();
-}
 
-*/
 // capture request
 void OV7670::CaptureNext(void)
 {
@@ -555,99 +501,4 @@
     }
 
     return 1;
-}
-
-
-/*
-int OV7670::BMP_tofile(unsigned int x, unsigned int y, const char *Name_BMP)
-{
-
-#define OffsetPixelWidth    18
-#define OffsetPixelHeigh    22
-#define OffsetFileSize      34
-#define OffsetPixData       10
-#define OffsetBPP           28
-
-    char filename[50];
-    unsigned char BMP_Header[54];
-    unsigned short BPP_t;
-    unsigned int PixelWidth,PixelHeigh,start_data;
-    unsigned int    i,off;
-    int padd,j;
-    unsigned short *line;
-
-    // get the filename
-    i=0;
-    while (*Name_BMP!='\0') {
-        filename[i++]=*Name_BMP++;
-    }
-    filename[i] = 0;
-
-    FILE *Image = fopen((const char *)&filename[0], "rb");  // open the bmp file
-    if (!Image) {
-        return(0);      // error file not found !
-    }
-
-    fread(&BMP_Header[0],1,54,Image);      // get the BMP Header
-
-    if (BMP_Header[0] != 0x42 || BMP_Header[1] != 0x4D) {  // check magic byte
-        fclose(Image);
-        return(-1);     // error no BMP file
-    }
-
-    BPP_t = BMP_Header[OffsetBPP] + (BMP_Header[OffsetBPP + 1] << 8);
-    if (BPP_t != 0x0010) {
-        fclose(Image);
-        return(-2);     // error no 16 bit BMP
-    }
-
-    PixelHeigh = BMP_Header[OffsetPixelHeigh] + (BMP_Header[OffsetPixelHeigh + 1] << 8) + (BMP_Header[OffsetPixelHeigh + 2] << 16) + (BMP_Header[OffsetPixelHeigh + 3] << 24);
-    PixelWidth = BMP_Header[OffsetPixelWidth] + (BMP_Header[OffsetPixelWidth + 1] << 8) + (BMP_Header[OffsetPixelWidth + 2] << 16) + (BMP_Header[OffsetPixelWidth + 3] << 24);
-    if (PixelHeigh > TFT.height() + y || PixelWidth > TFT.width() + x) {
-        fclose(Image);
-        return(-3);      // to big
-    }
-
-    start_data = BMP_Header[OffsetPixData] + (BMP_Header[OffsetPixData + 1] << 8) + (BMP_Header[OffsetPixData + 2] << 16) + (BMP_Header[OffsetPixData + 3] << 24);
-
-    line = (unsigned short *) malloc (2 * PixelWidth); // we need a buffer for a line
-    if (line == NULL) {
-        return(-4);         // error no memory
-    }
-
-    // the bmp lines are padded to multiple of 4 bytes
-    padd = -1;
-    do {
-        padd ++;
-    } while ((PixelWidth * 2 + padd)%4 != 0);
-
-    // GraphicsDisplay.window(x, y,PixelWidth ,PixelHeigh);
-    //GraphicsDisplay.wr_cmd(0x2C);  // send pixel
-    //GraphicsDisplay.spi_16(1);
-    int compt=38400;
-    unsigned char c,c1;
-    for (j = PixelHeigh - 1; j >= 0; j--) {               //Lines bottom up
-        off = j * (PixelWidth  * 2 + padd) + start_data;   // start of line
-        fseek(Image, off ,SEEK_SET);
-        fread(line,1,PixelWidth * 2,Image);       // read a line - slow
-        //   for (i = 0; i < PixelWidth; i++) {        // copy pixel data to TFT
-        for (int i = PixelWidth-1; i >=0; i--) {        // copy pixel data to TFT
-            compt = compt -1;
-            c=line[i]&0x00FF;
-            c1=line[i]>>8;
-            bank[compt] =c1      ;
-            compt = compt -1;
-            bank[compt] =c;          // one 16 bit pixel
-        }
-    }
-    //spi_bsy();
-    //_cs = 1;
-    //spi_16(0);
-    free (line);
-    fclose(Image);
-    //WindowMax();
-    return(1);
-}
-
-*/
-
+}
\ No newline at end of file