kao yi
/
Bov3
wu
Fork of CCC by
Diff: camera_api.cpp
- Revision:
- 1:82bc25a7b68b
- Parent:
- 0:68c173249c01
- Child:
- 2:c51647d3c14d
diff -r 68c173249c01 -r 82bc25a7b68b camera_api.cpp --- a/camera_api.cpp Sun May 25 12:41:59 2014 +0000 +++ b/camera_api.cpp Tue Jun 03 15:53:55 2014 +0000 @@ -0,0 +1,91 @@ +#include "mbed.h" +#include "camera_api.h" + +#define clk 2 //ms + + + BX_camera::BX_camera(char cam){ + + + cam_clk= new DigitalOut(PTE1) ; + + si = new DigitalOut(PTD7); + + line_Cam = new FastAnalogIn(PTD5); + + + + + + + } + + +void BX_camera::read(void){ + + + w_f_v=0x0000; + b_f_v=0xffff; + + + + *si=1; + *cam_clk=1; + + wait_us(30); // tune here + *si=0; + *cam_clk=0; + + + + line_Cam->enable(); + + + //input 128 + + for(int i=0;i<128;i++){ + *cam_clk=1; + wait_us(5); + + + line_image[i]=line_Cam->read_u16(); + + + // big small + if(line_image[i] > w_f_v) + w_f_v=line_image[i]; + else if(line_image[i] < b_f_v ) + b_f_v = line_image[i]; + + + + + *cam_clk=0; + wait_us(5); + + + } + + + line_Cam->disable(); + + + + //filter + + for(int i=0;i<128;i++){ + + + if( (line_image[i]-b_f_v) < (w_f_v - line_image[i] ) ) + sign_line_image[i]=' '; + else + sign_line_image[i]='O'; + + if(i==0) + sign_line_image[i]='X'; + + } + + + + } \ No newline at end of file