shared

Dependencies:   mbed-rtos mbed

Fork of Boboobooo by kao yi

camera_api.cpp

Committer:
backman
Date:
2014-06-03
Revision:
1:82bc25a7b68b
Parent:
0:68c173249c01
Child:
2:c51647d3c14d

File content as of revision 1:82bc25a7b68b:

#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';
           
          }
           
           
           
           }