Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of dgps by
Diff: main.cpp
- Revision:
- 6:434d20e99e49
- Parent:
- 0:9c001c4e7bf4
- Child:
- 7:c75d5e5e6bfc
--- a/main.cpp Sun Feb 16 22:12:08 2014 +0000 +++ b/main.cpp Fri Feb 21 15:15:25 2014 +0000 @@ -1,10 +1,13 @@ #include "mbed.h" #include <string> #include <sstream> - +#include "usb.h" +#include "camera.h" +/* Serial pc(USBTX,USBRX); Serial xbee(p9,p10);//tx, rx Serial gps(p28,p27); +Serial camera(p13,p14); typedef struct { int latitude; //in .0001 minutes @@ -147,14 +150,44 @@ reading = true; } } - +*/ int main(){ - gps.baud(57600); - xbee.baud(9600); - pc.baud(57600); + //USB::getSerial().printf("------Starting Program------\n"); + Camera cam; + char* version = cam.getVersion(); + //USB::getSerial().printf("Camera Version:\n%s\n",version); + uint8_t targetSize=VC0706_640x480;//VC0706_160x120; + cam.setImageSize(targetSize); + uint8_t realSize=cam.getImageSize(); + //USB::getSerial().printf("Image Size | Target: %d, Real %d",targetSize,realSize); + if (! cam.takePicture()) { + USB::getSerial().printf("Failed to snap!\n"); + while(1){} + } else { + //USB::getSerial().printf("Picture taken!\n"); + } + int size=cam.frameLength(); + //USB::getSerial().printf("Image Size %d\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]);} + //USB::getSerial().write(buffer,bytesToRead); + //USB::getSerial().printf("Read: %d/%d - %d/%d\n",i,size,bytesRead,bytesToRead); + i+=bytesRead; + } + //USB::getSerial().printf("Done(%d)\n",i); + while(1){ + } +// gps.baud(57600); +// xbee.baud(9600); +// pc.baud(57600); // sendGpsCommand("PMTK301,1"); // while(true){pc.putc(gps.getc());} - gps.attach(&handleGpsData, Serial::RxIrq); +// gps.attach(&handleGpsData, Serial::RxIrq); // xbee.attach(&handleXbeeGps, Serial::RxIrq); }