cansat
Dependencies: BMP085 JPEGCamera SDFileSystem mbed
Fork of SaibiCansat2014 by
Revision 9:3a2d25f4700b, committed 2014-07-18
- Comitter:
- TakashiSasaki
- Date:
- Fri Jul 18 01:52:44 2014 +0000
- Parent:
- 8:3230ddd3a3d1
- Child:
- 10:337ccaaec39c
- Commit message:
- processPicture writes data to xbee
Changed in this revision
--- a/FastJpegCamera.h Thu Jul 17 23:30:16 2014 +0000 +++ b/FastJpegCamera.h Fri Jul 18 01:52:44 2014 +0000 @@ -5,13 +5,16 @@ #define FILENAME "/sd/pict%03d.jpg" +#define min(x, y) ((x) < (y)) ? (x) : (y) + class FastJpegCamera : public JPEGCamera { public: DigitalOut myled1; //show successful picture was taken int baudrate; Serial pc; + Serial& xbee; - FastJpegCamera(PinName tx, PinName rx) : JPEGCamera(tx,rx), baudrate(38400), pc(USBTX, USBRX), myled1(LED1){ + FastJpegCamera(PinName tx, PinName rx, Serial& xbee) : JPEGCamera(tx,rx), baudrate(38400), pc(USBTX, USBRX), myled1(LED1), xbee(xbee){ this->baud115200(); }; @@ -53,6 +56,28 @@ pc.printf("%02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4]); }; + bool processPicture() { + if (state == PROCESSING) { + if (address < imageSize) { + char data[1024]; + int size = readData(data, min(sizeof(data), imageSize - address), address); + int ret = fwrite(data, size, 1, fp); + if (ret > 0) + address += size; + if (ret == 0 || address >= imageSize) { + stopPictures(); + fclose(fp); + wait(0.1); // ???? + state = ret > 0 ? READY : ERROR; + }//if + for(int i=0; i<sizeof data; ++i){ + xbee.putc(data[i]); + }//for + }//if + }//if + return state == PROCESSING || state == READY; + }//processPicture + void shoot(int i){ if (!this->isReady()) { @@ -84,6 +109,7 @@ myled1 = 0; };//shoot + };//FastJpegCamera #endif
--- a/camera.cpp Thu Jul 17 23:30:16 2014 +0000 +++ b/camera.cpp Fri Jul 18 01:52:44 2014 +0000 @@ -21,7 +21,7 @@ printf("%s\n", __FILE__); //sourcefilename printout printf("start!!\n"); - FastJpegCamera camera(p9, p10); // TX, RX + JPEGCamera camera(p9, p10); // TX, RX LocalFileSystem local("local"); //save images on mbed Timer timer;
--- a/main.cpp Thu Jul 17 23:30:16 2014 +0000 +++ b/main.cpp Fri Jul 18 01:52:44 2014 +0000 @@ -39,6 +39,7 @@ int main() { pc.printf("main() started. pc.baud is 9600 at this time."); //pc.baud(9600); + xbee.baud(115200); myled = 1; int readings[3] = {0, 0, 0}; @@ -68,7 +69,7 @@ } wait(.001); - FastJpegCamera fast_jpeg_camera(p9, p10); + FastJpegCamera fast_jpeg_camera(p9, p10, xbee); //Measurement mode.