jpeg写真撮影&画像送信 +SD

Dependencies:   mbed jpeg_camera_example SDFileSystem xbee_image

Files at this revision

API Documentation at this revision

Comitter:
MatsumotoKouki
Date:
Tue Dec 03 06:25:07 2019 +0000
Parent:
0:e5488d96a74d
Commit message:
+sd;

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
xbee_main/main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e5488d96a74d -r f0695efb1315 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Tue Dec 03 06:25:07 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/MatsumotoKouki/code/SDFileSystem/#0355aae55cdc
diff -r e5488d96a74d -r f0695efb1315 xbee_main/main.cpp
--- a/xbee_main/main.cpp	Wed Nov 27 13:47:02 2019 +0000
+++ b/xbee_main/main.cpp	Tue Dec 03 06:25:07 2019 +0000
@@ -2,24 +2,18 @@
 #include "JPEGCamera.h"
 #include <stdio.h>
 #include "base64.h"
+#include "SDFileSystem.h"
 
-LocalFileSystem local("local");
+//LocalFileSystem local("local");
 Serial pc(USBTX,USBRX);
 Serial xbee(p9, p10);
-/*JPEGCamera camera(p13, p14); // TX, RX
-    //LocalFileSystem local("local");
-    Timer timer;
-    timer.start();
-    camera.setPictureSize(JPEGCamera::SIZE320x240);*/
+SDFileSystem sd(p5,p6,p7,p8,"sd");
 
 int main() {
     
-  /*  LocalFileSystem local("local");
-    Serial pc(USBTX,USBRX);
-    Serial xbee(p9, p10);*/
+ 
     
     JPEGCamera camera(p13, p14); // TX, RX
-    //LocalFileSystem local("local");
     Timer timer;
     timer.start();
     camera.setPictureSize(JPEGCamera::SIZE320x240);
@@ -36,35 +30,23 @@
 
     for (int k = 0; k < 10; k++) {
         if (camera.isReady()) {
-            char filename[32];
             
-            snprintf(filename,32, "%s%03d%s","/local/pict",k,".jpg");
+            char filename[25];
+            mkdir("/sd/mydir", 0777);
+            snprintf(filename,25, "%s%03d%s","/sd/mydir/pict",k,".jpg");
+             
             printf("Picture: %s ", filename);
+            //fprintf(fp,"%s",filename);
+              
+    
             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/PICTi.jpg","/local/d.txt");//000->ili8uni
-                    if((fp=fopen("/local/d.txt","r"))!=NULL)
-                    
-  {
-      while ((c=fgetc(fp))!=EOF){
-          xbee.printf("%c",c);
-      }
-      fclose(fp);
-                }*/
+              
             } 
-           /* FILE *fp;
-                    base64 *bs;
-                    int c;
-                    xbee.printf("xbee connected!\r\n");
-                    bs = new base64();*/
-                    bs->Encode(filename/*"/local/PICT000.jpg"*/,"/local/d.txt");//000->ili8uni
-                    if((fp=fopen("/local/d.txt","r"))!=NULL)
+           
+                    bs->Encode(filename,"/sd/mydir/d.txt");
+                    if((fp=fopen("/sd/mydir/d.txt","r"))!=NULL)
                     
   {
       while ((b=fgetc(fp))!=EOF){
@@ -72,6 +54,9 @@
       }
       fclose(fp);
                 }
+                if(fp == NULL) {
+        error("Could not open file for write\n");
+    }
             }else {
                 printf("take picture failed\n");
             }