Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem mbed
Fork of SDFileSystem_HelloWorld by
Diff: main.cpp
- Revision:
- 2:a44adae14658
- Parent:
- 0:bdbd3d6fc5d5
- Child:
- 3:b7f9b01dde7a
--- a/main.cpp Tue May 16 05:18:55 2017 +0000
+++ b/main.cpp Sat Mar 10 05:26:06 2018 +0000
@@ -3,17 +3,26 @@
SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
-int main() {
- printf("Hello World!\n");
-
- mkdir("/sd/mydir", 0777);
+int main(){
+ float Data[7] = {0};
+ printf("Hello!\r\n");
+
+ /* ファイルオープン */
+ FILE *bp = fopen("/sd/mydir/data.bin","rb");
+ FILE *fp = fopen("/sd/mydir/data.txt","w");
+
+ fprintf(fp,"time,acc[x],acc[y],acc[z],gyr[x],gyr[y],gyr[z]\n");
- FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
- if(fp == NULL) {
- error("Could not open file for write\n");
+ /* 読み出したデータが0個でなければテキストファイルに書き込み */
+ while(fread(&Data,sizeof(float),7,bp) != 0){
+ printf("please wait\r"); //時間がかかったとき用
+ fprintf(fp,"%f,%f,%f,%f,%f,%f,%f\n",Data[0],Data[1],Data[2],Data[3],Data[4],Data[5],Data[6]);
}
- fprintf(fp, "Hello fun SD Card World!");
- fclose(fp);
-
- printf("Goodbye World!\n");
-}
+
+ /* ファイルクローズ */
+ fclose(bp);
+ fclose(fp);
+
+ printf("\nBye\r\n");
+ return 0;
+}
\ No newline at end of file
