QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Revision:
7:c75d5e5e6bfc
Child:
8:28b866df62cf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/handle/handleCamera.cpp	Tue Apr 01 15:52:08 2014 +0000
@@ -0,0 +1,41 @@
+#include "takeImage.h"
+
+void ImageHandle::setup(){
+    //char* version = cam.getVersion();
+    uint8_t targetSize=VC0706_160x120;//VC0706_640x480;//VC0706_160x120;
+    cam.setImageSize(targetSize);
+    uint8_t realSize=cam.getImageSize();
+}
+
+void ImageHandle::take(){
+    if (! cam.takePicture()) {
+        USB::getSerial().printf("Failed to snap!\n");
+        while(1){}
+    }
+    int size=cam.frameLength();
+    USB::getSerial().printf("Image Start\n",size);
+    int i;
+    for(i=0;i<size;){
+        // read 32 bytes at a time;
+        uint8_t bytesToRead = 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]);}
+        i+=bytesRead;
+    }
+    USB::getSerial().printf("Image End\n",size);
+}
+
+bool ImageHandle::check(){
+    return true;
+}
+
+void ImageHandle::run(){
+    if(!initialized){
+        initialized=true;
+        setup();
+    }
+    if(check()){
+        take();
+    }
+}
\ No newline at end of file