2017年度の製作を開始します。

Dependencies:   BufferedSoftSerial2 SDFileSystem-RTOS mbed mbed-rtos INA226_ver1

Fork of keiki2016ver5 by albatross

Branch:
SDandCadenceThread
Revision:
71:c06da87572f1
Parent:
70:763d62c486ca
Child:
72:bb664e4378a0
--- a/main.cpp	Fri Jun 16 07:34:32 2017 +0000
+++ b/main.cpp	Fri Jun 16 08:06:21 2017 +0000
@@ -34,7 +34,8 @@
 }
 //-------------------------------------------------------
 
-SDFileSystem sd(p5, p6, p7, p8, "sd");
+//SDFileSystem sd(p5, p6, p7, p8, "sd");
+LocalFileSystem local("local");
 FILE* fp;
 
 //RawSerial pc(USBTX,USBRX);
@@ -73,7 +74,7 @@
 //DigitalOut led3(LED3);
 DigitalOut led4(LED4);
 I2C InaI2c(p9,p10);
-INA226 VCmonitor(InaI2c,0x9C);
+//INA226 VCmonitor(InaI2c,0x9C);
 AnalogIn mgPin(p20);
 AnalogIn mgPin2(p16);
 
@@ -206,11 +207,11 @@
 //-----------------------------------------------------------
     unsigned short val;
     val = 0;
-    if(VCmonitor.rawRead(0x00,&val) != 0) {
-        printf("VCmonitor READ ERROR\n");
-        while(1) {}
-    }
-    VCmonitor.setCurrentCalibration();
+//    if(VCmonitor.rawRead(0x00,&val) != 0) {
+//        printf("VCmonitor READ ERROR\n");
+//        while(1) {}
+//    }
+//    VCmonitor.setCurrentCalibration();
 }
 
 void FusokukeiInit()
@@ -308,8 +309,8 @@
 
 void SdInit()
 {
-    mkdir("/sd/mydir", 0777);
-    fp = fopen("/sd/mydir/sdtest2.csv", "w");
+//    mkdir("/local/mydir", 0777);
+    fp = fopen("/local/filetest.csv", "w");
     if(fp == NULL) {
         printf("Could not open file for write\n");
         return;
@@ -320,26 +321,26 @@
 
 void SDprintf(const void* arg)
 {
-  //  SdInit();
+    SdInit();
     while(1) {
         updateCadence(V,mgPin.read() * 3300.0,mgPin2.read() * 3300.0);
         //  pc.printf("V:%5.5f  mgPin:%5.5f     mgPin2:%5.5f",V,mgPin.read() * 3300.0,mgPin2.read() * 3300.0);
-      //  if(write_datas_index == SD_WRITE_NUM-1) {
-//            fp = fopen("/sd/mydir/data.csv", "a");
-//            if(fp == NULL) {
-//                error("Could not open file for write!!\n");
-//            }
-//            for(int i = 0; i < SD_WRITE_NUM; i++) {
-//                for(int j = 0; j < WRITE_DATAS_NUM; j++) {
-//                    fprintf(fp,"%f,", writeDatas[i][j]);
-//                }
-//                fprintf(fp,"\n");
-//            }
-//
-//            fclose(fp);
-//
-//            write_datas_index=0;
-//        }
+        if(write_datas_index == SD_WRITE_NUM-1) {
+            fp = fopen("/local/data.csv", "a");
+            if(fp == NULL) {
+                error("Could not open file for write!!\n");
+            }
+            for(int i = 0; i < SD_WRITE_NUM; i++) {
+                for(int j = 0; j < WRITE_DATAS_NUM; j++) {
+                    fprintf(fp,"%f,", writeDatas[i][j]);
+                }
+                fprintf(fp,"\n");
+            }
+
+            fclose(fp);
+
+            write_datas_index=0;
+        }
         Thread::wait(100);
     }
 }
@@ -455,9 +456,9 @@
     int VCcounter = 0;
     while(1) {
         if(VCcounter%20 == 0 ) {
-            if( VCmonitor.getVoltage(&V) == 0) {
-                pc.printf("e:%f\n",V);
-            }
+//            if( VCmonitor.getVoltage(&V) == 0) {
+//                pc.printf("e:%f\n",V);
+//            }
         }
         VCcounter++;