Toma de foto y descomprimir en HEX
Dependencies: JPEGCamera SDFileSystem mbed
Fork of SaibiCansat2014 by
Diff: FastJpegCamera.h
- Revision:
- 6:9824d4e2f29b
- Child:
- 7:cc8080b31ac5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FastJpegCamera.h Thu Jul 17 23:01:41 2014 +0000 @@ -0,0 +1,83 @@ +#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->baud38400(); + }; + + 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]); + 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); + wait(0.5); + //this->reset(); + this->baudrate = 38400; + this->baud(this->baudrate); + pc.printf("%02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4]); + }; + + void shoot(int i){ + + if (!this->isReady()) { + 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 { + printf("take picture picture\n"); + //myled3 = 1; //show picture take failed + //wait(2.0); + //myled3 = 0; + }//if + myled1 = 0; + };//shoot + +};//FastJpegCamera + +#endif