Colin Stearns
/
qcControl
QC Control software
Fork of dgps by
Diff: handle/handleCamera.cpp
- Revision:
- 12:e42985e3ea64
- Parent:
- 9:da906eeac51e
- Child:
- 13:a6d3cf2b018e
--- a/handle/handleCamera.cpp Sat Apr 05 17:49:57 2014 +0000 +++ b/handle/handleCamera.cpp Sat Apr 05 22:27:18 2014 +0000 @@ -1,7 +1,8 @@ #include "handleCamera.h" void ImageHandle::setup(){ - //char* version = cam.getVersion(); + char* version = cam.getVersion(); + outputDevice.printf("Version %s\n",version); uint8_t targetSize=VC0706_160x120;//VC0706_640x480;//VC0706_160x120; cam.setImageSize(targetSize); uint8_t realSize=cam.getImageSize(); @@ -9,21 +10,25 @@ void ImageHandle::take(){ if (! cam.takePicture()) { - USB::getSerial().printf("Failed to snap!\n"); + outputDevice.printf("Failed to snap!\n"); while(1){} } + unsigned int sID=getPS().getSuperID(); + getPS().sendPacket(sID,NULL,0,PT_IMAGE); int size=cam.frameLength(); - USB::getSerial().printf("Image Start\n",size); + outputDevice.printf("Image Start\n",size); int i; for(i=0;i<size;){ // read 32 bytes at a time; uint8_t bytesToRead = std::min(64, size-i); // change 32 to 64 for a speedup but may not work with all setups! uint8_t bytesRead=0; - uint8_t* buffer = cam.readPicture(bytesToRead,&bytesRead); - for(int a=0;a<bytesRead;a++){USB::getSerial().putc(buffer[a]);} + char* buffer = (char*)cam.readPicture(bytesToRead,&bytesRead); + getPS().sendPacket(sID,buffer,bytesRead); + //for(int a=0;a<bytesRead;a++){outputDevice.putc(buffer[a]);} i+=bytesRead; } - USB::getSerial().printf("Image End\n",size); + outputDevice.printf("Image End\n",size); + getPS().sendPacket(sID,NULL,0,PT_END); } bool ImageHandle::check(){ @@ -33,9 +38,11 @@ void ImageHandle::run(){ if(!initialized){ initialized=true; + outputDevice.printf("Setup cam\n"); setup(); } if(check()){ take(); + while(true){} } } \ No newline at end of file