画像を2枚撮影
Diff: main.cpp
- Revision:
- 3:6462ae80537b
- Parent:
- 2:7745e694124f
--- a/main.cpp Thu Nov 21 13:13:26 2019 +0000 +++ b/main.cpp Mon Nov 25 08:11:32 2019 +0000 @@ -1,5 +1,11 @@ #include "mbed.h" #include "JPEGCamera.h" +#include <stdio.h> +#include "base64.h" + +LocalFileSystem local("local"); +Serial pc(USBTX,USBRX); +Serial xbee(p9, p10); int main() { JPEGCamera camera(p13, p14); // TX, RX @@ -8,7 +14,7 @@ timer.start(); camera.setPictureSize(JPEGCamera::SIZE320x240); - for (int i = 0; i < 2; i++) { + for (int i = 0; i < 10; i++) { if (camera.isReady()) { char filename[32]; sprintf(filename, "/local/pict%03d.jpg", i); @@ -16,13 +22,30 @@ if (camera.takePicture(filename)) { while (camera.isProcessing()) { camera.processPicture(); + FILE *fp; + base64 *bs; + int c; + xbee.printf("xbee connected!\r\n"); + bs = new base64(); + bs->Encode("/local/PICT000.jpg","/local/d.txt"); + if((fp=fopen("/local/d.txt","r"))!=NULL) + + { + while ((c=fgetc(fp))!=EOF){ + xbee.printf("%c",c); + } + fclose(fp); } - } else { + } + }else { printf("take picture failed\n"); } } else { printf("camera is not ready\n"); } + wait(60); } printf("time = %f\n", timer.read()); -} \ No newline at end of file + + return 0; +}