QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Committer:
dylanembed123
Date:
Thu Apr 03 17:15:29 2014 +0000
Revision:
9:da906eeac51e
Parent:
8:28b866df62cf
Child:
12:e42985e3ea64
Fix compile errors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stearnsc 8:28b866df62cf 1 #include "handleCamera.h"
dylanembed123 7:c75d5e5e6bfc 2
dylanembed123 7:c75d5e5e6bfc 3 void ImageHandle::setup(){
dylanembed123 7:c75d5e5e6bfc 4 //char* version = cam.getVersion();
dylanembed123 7:c75d5e5e6bfc 5 uint8_t targetSize=VC0706_160x120;//VC0706_640x480;//VC0706_160x120;
dylanembed123 7:c75d5e5e6bfc 6 cam.setImageSize(targetSize);
dylanembed123 7:c75d5e5e6bfc 7 uint8_t realSize=cam.getImageSize();
dylanembed123 7:c75d5e5e6bfc 8 }
dylanembed123 7:c75d5e5e6bfc 9
dylanembed123 7:c75d5e5e6bfc 10 void ImageHandle::take(){
dylanembed123 7:c75d5e5e6bfc 11 if (! cam.takePicture()) {
dylanembed123 7:c75d5e5e6bfc 12 USB::getSerial().printf("Failed to snap!\n");
dylanembed123 7:c75d5e5e6bfc 13 while(1){}
dylanembed123 7:c75d5e5e6bfc 14 }
dylanembed123 7:c75d5e5e6bfc 15 int size=cam.frameLength();
dylanembed123 7:c75d5e5e6bfc 16 USB::getSerial().printf("Image Start\n",size);
dylanembed123 7:c75d5e5e6bfc 17 int i;
dylanembed123 7:c75d5e5e6bfc 18 for(i=0;i<size;){
dylanembed123 7:c75d5e5e6bfc 19 // read 32 bytes at a time;
dylanembed123 9:da906eeac51e 20 uint8_t bytesToRead = std::min(64, size-i); // change 32 to 64 for a speedup but may not work with all setups!
dylanembed123 7:c75d5e5e6bfc 21 uint8_t bytesRead=0;
dylanembed123 7:c75d5e5e6bfc 22 uint8_t* buffer = cam.readPicture(bytesToRead,&bytesRead);
dylanembed123 7:c75d5e5e6bfc 23 for(int a=0;a<bytesRead;a++){USB::getSerial().putc(buffer[a]);}
dylanembed123 7:c75d5e5e6bfc 24 i+=bytesRead;
dylanembed123 7:c75d5e5e6bfc 25 }
dylanembed123 7:c75d5e5e6bfc 26 USB::getSerial().printf("Image End\n",size);
dylanembed123 7:c75d5e5e6bfc 27 }
dylanembed123 7:c75d5e5e6bfc 28
dylanembed123 7:c75d5e5e6bfc 29 bool ImageHandle::check(){
dylanembed123 7:c75d5e5e6bfc 30 return true;
dylanembed123 7:c75d5e5e6bfc 31 }
dylanembed123 7:c75d5e5e6bfc 32
dylanembed123 7:c75d5e5e6bfc 33 void ImageHandle::run(){
dylanembed123 7:c75d5e5e6bfc 34 if(!initialized){
dylanembed123 7:c75d5e5e6bfc 35 initialized=true;
dylanembed123 7:c75d5e5e6bfc 36 setup();
dylanembed123 7:c75d5e5e6bfc 37 }
dylanembed123 7:c75d5e5e6bfc 38 if(check()){
dylanembed123 7:c75d5e5e6bfc 39 take();
dylanembed123 7:c75d5e5e6bfc 40 }
dylanembed123 7:c75d5e5e6bfc 41 }