cansat_B 2019 / Mbed 2 deprecated camera-pic-xbee

Dependencies:   mbed JPEGCamera

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "JPEGCamera.h"
00003 #include <stdio.h>
00004 #include <base64.h>
00005 
00006 LocalFileSystem local("local");
00007 
00008 Serial pc(USBTX,USBRX);
00009 JPEGCamera camera(p9,p10);//TX,RX
00010 Serial xbee(p13,p14);
00011 
00012 int main(){
00013     
00014     Timer timer;
00015     timer.start();
00016     camera.setPictureSize(JPEGCamera::SIZE320x240);
00017 
00018     FILE *fp;
00019     base64 *bs;
00020     int c;
00021     
00022     for (int i = 0; i < 1; i++) {
00023         if (camera.isReady()) {
00024             char filename[32];
00025             sprintf(filename, "/local/pict%03d.jpg",i);
00026             printf("Picture: %s ",filename);
00027             if (camera.takePicture(filename)) {
00028                 while (camera.isProcessing()) {
00029                     camera.processPicture();
00030                 }
00031             } else {
00032                 printf("take picture failed\r\n");
00033             }
00034         } else {
00035             printf("camera is not ready\r\n");
00036         }
00037     }
00038     printf("time = %f\n", timer.read());
00039     
00040         
00041     xbee.printf("xbee connected!\r\n");
00042     bs = new base64();
00043     bs->Encode("/local/PICT000.jpg","/local/d.txt");
00044         
00045         
00046     if((fp=fopen("/local/d.txt","r"))!=NULL)
00047     {
00048         while ((c=fgetc(fp))!=EOF){
00049             xbee.printf("%c",c);
00050         }
00051         fclose(fp);
00052     }
00053     return 0;
00054 }
00055