capstone_finish
Dependencies: BufferedSerial motor_sn7544
main.cpp@1:509676f3be32, 2012-02-17 (annotated)
- Committer:
- mio
- Date:
- Fri Feb 17 15:06:15 2012 +0000
- Revision:
- 1:509676f3be32
- Parent:
- 0:f3f80a0695ff
- Child:
- 2:e98408458d2b
Hflip Vflip init param support.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mio | 0:f3f80a0695ff | 1 | // |
mio | 0:f3f80a0695ff | 2 | // OV7670 + FIFO AL422B camera board test |
mio | 0:f3f80a0695ff | 3 | // |
mio | 0:f3f80a0695ff | 4 | #include "mbed.h" |
mio | 0:f3f80a0695ff | 5 | #include "spilcd_qvga.h" |
mio | 0:f3f80a0695ff | 6 | #include "ov7670.h" |
mio | 0:f3f80a0695ff | 7 | #include <stdlib.h> |
mio | 0:f3f80a0695ff | 8 | |
mio | 0:f3f80a0695ff | 9 | // |
mio | 0:f3f80a0695ff | 10 | // SPILCD LG |
mio | 0:f3f80a0695ff | 11 | // |
mio | 0:f3f80a0695ff | 12 | SPILCD_QVGA lcd(p29, p30, p5, p6, p7) ; |
mio | 0:f3f80a0695ff | 13 | OV7670 camera( |
mio | 0:f3f80a0695ff | 14 | p28,p27, // SDA,SCL(I2C / SCCB) |
mio | 0:f3f80a0695ff | 15 | p21,p22,p20, // VSYNC,HREF,WEN(FIFO) |
mio | 0:f3f80a0695ff | 16 | //p18,p17,p16,p15,p11,p12,p14,p13, // D7-D0 |
mio | 0:f3f80a0695ff | 17 | Port0,0x07878000, |
mio | 0:f3f80a0695ff | 18 | p23,p24,p25) ; // RRST,OE,RCLK |
mio | 0:f3f80a0695ff | 19 | |
mio | 0:f3f80a0695ff | 20 | Serial pc(USBTX,USBRX) ; |
mio | 0:f3f80a0695ff | 21 | Timer t; |
mio | 0:f3f80a0695ff | 22 | |
mio | 1:509676f3be32 | 23 | #undef QQVGA |
mio | 1:509676f3be32 | 24 | |
mio | 0:f3f80a0695ff | 25 | #ifdef QQVGA |
mio | 0:f3f80a0695ff | 26 | # define SIZEX (160) |
mio | 0:f3f80a0695ff | 27 | # define SIZEY (120) |
mio | 0:f3f80a0695ff | 28 | #else |
mio | 0:f3f80a0695ff | 29 | # define SIZEX (320) |
mio | 0:f3f80a0695ff | 30 | # define SIZEY (240) |
mio | 0:f3f80a0695ff | 31 | #endif |
mio | 0:f3f80a0695ff | 32 | |
mio | 0:f3f80a0695ff | 33 | int main() { |
mio | 0:f3f80a0695ff | 34 | int last ; |
mio | 0:f3f80a0695ff | 35 | pc.baud(115200) ; |
mio | 0:f3f80a0695ff | 36 | camera.Reset() ; |
mio | 0:f3f80a0695ff | 37 | |
mio | 0:f3f80a0695ff | 38 | #ifdef QQVGA |
mio | 1:509676f3be32 | 39 | camera.InitQQVGA565(true,false) ; |
mio | 0:f3f80a0695ff | 40 | #else |
mio | 1:509676f3be32 | 41 | camera.InitQVGA565(true,false) ; |
mio | 0:f3f80a0695ff | 42 | #endif |
mio | 0:f3f80a0695ff | 43 | |
mio | 0:f3f80a0695ff | 44 | // CAPTURE and SEND LOOP |
mio | 0:f3f80a0695ff | 45 | t.start(); |
mio | 0:f3f80a0695ff | 46 | last = t.read_ms() ; |
mio | 0:f3f80a0695ff | 47 | while(1) |
mio | 0:f3f80a0695ff | 48 | { |
mio | 0:f3f80a0695ff | 49 | camera.CaptureNext() ; |
mio | 0:f3f80a0695ff | 50 | while(camera.CaptureDone() == false) ; |
mio | 0:f3f80a0695ff | 51 | printf("Caputure %d(ms)\r\n", t.read_ms() - last) ; |
mio | 0:f3f80a0695ff | 52 | last = t.read_ms() ; |
mio | 0:f3f80a0695ff | 53 | camera.ReadStart() ; |
mio | 0:f3f80a0695ff | 54 | lcd.Lcd_SetCursor(0,0); |
mio | 0:f3f80a0695ff | 55 | lcd.Lcd_WR_Start(); |
mio | 0:f3f80a0695ff | 56 | lcd.rsout(1) ; |
mio | 0:f3f80a0695ff | 57 | for (int y = 0;y < SIZEY;y++) { |
mio | 0:f3f80a0695ff | 58 | lcd.Lcd_SetCursor(y,0); |
mio | 0:f3f80a0695ff | 59 | lcd.Lcd_WR_Start(); |
mio | 0:f3f80a0695ff | 60 | for (int x = 0;x < SIZEX;x++) { |
mio | 0:f3f80a0695ff | 61 | lcd.csout(0) ; |
mio | 0:f3f80a0695ff | 62 | lcd.DataToWrite(camera.ReadOneWord()); |
mio | 0:f3f80a0695ff | 63 | lcd.csout(1) ; |
mio | 0:f3f80a0695ff | 64 | } |
mio | 0:f3f80a0695ff | 65 | } |
mio | 0:f3f80a0695ff | 66 | camera.ReadStop() ; |
mio | 0:f3f80a0695ff | 67 | lcd.rsout(0) ; |
mio | 0:f3f80a0695ff | 68 | printf("FIFO Read & Lcd Out %d(ms)\r\n", t.read_ms() - last) ; |
mio | 0:f3f80a0695ff | 69 | last = t.read_ms() ; |
mio | 0:f3f80a0695ff | 70 | } |
mio | 0:f3f80a0695ff | 71 | } |