Toma de foto y descomprimir en HEX
Dependencies: JPEGCamera SDFileSystem mbed
Fork of SaibiCansat2014 by
FastJpegCamera.h
- Committer:
- TakashiSasaki
- Date:
- 2014-07-17
- Revision:
- 8:3230ddd3a3d1
- Parent:
- 7:cc8080b31ac5
- Child:
- 9:3a2d25f4700b
File content as of revision 8:3230ddd3a3d1:
#ifndef FAST_JPEG_CAMERA_H #define FAST_JPEG_CAMERA_H #include "JPEGCamera/JPEGCamera.h" #define FILENAME "/sd/pict%03d.jpg" class FastJpegCamera : public JPEGCamera { public: DigitalOut myled1; //show successful picture was taken int baudrate; Serial pc; FastJpegCamera(PinName tx, PinName rx) : JPEGCamera(tx,rx), baudrate(38400), pc(USBTX, USBRX), myled1(LED1){ this->baud115200(); }; void baud115200(){ char buf[7] = {0x56, 0x00, 0x24, 0x03, 0x01, 0x0d, 0xa6}; //char buf[5] = {0x56, 0x00, 0x34, 0x0d, 0xa6}; //int ret = sendReceive(buf, sizeof buf, 5); for (int i = 0; i < sizeof buf; i++) putc(buf[i]); wait(0.5); this->baudrate = 115200; this->baud(this->baudrate); wait(4); //this->reset(); receive(buf, 5, 500); pc.printf("%02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4]); }; void baud57600(){ char buf[7] = {0x56, 0x00, 0x24, 0x03, 0x01, 0x1c, 0x4c}; int ret = sendReceive(buf, sizeof buf, 5); wait(0.5); this->reset(); this->baudrate = 57600; this->baud(this->baudrate); }; void baud38400(){ char buf[7] = {0x56, 0x00, 0x24, 0x03, 0x01, 0x2a, 0xf2}; //int ret = sendReceive(buf, sizeof buf, 5); for (int i = 0; i < sizeof buf; i++) putc(buf[i]); wait(0.5); //this->reset(); this->baudrate = 38400; this->baud(this->baudrate); wait(4); //this->reset(); receive(buf, 5, 500); pc.printf("%02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4]); }; void shoot(int i){ if (!this->isReady()) { pc.printf("show camera is not ready\n"); //myled4 = 1; //show camera is not ready //wait(2.0); //myled4 = 0; return; }//if char filename[32]; sprintf(filename, FILENAME, i); printf("Picture: %s ", filename); myled1 = 1; if (this->takePicture(filename)) { while (this->isProcessing()) { this->processPicture(); }//while //myled1 = 1; //show successful picture was taken //wait(2.0); //myled1 = 0; } else { pc.printf("shot %s\n", filename); //myled3 = 1; //show picture take failed //wait(2.0); //myled3 = 0; }//if this->stopPictures(); myled1 = 0; };//shoot };//FastJpegCamera #endif