一秒ごとにスイッチのon/off回数を数えるプログラムです。 タイムスタンプのエラーで困ってます。

Dependencies:   Pswitch_Lib TextLCD mbed

Revision:
0:252c31119664
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Feb 09 12:59:04 2014 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "TextLCD.h"
+#include "Pswitch.h"
+
+TextLCD lcd(p24,p26,p27,p28,p29,p30);
+DigitalOut myled(LED1);
+Pswitch mgsw(p8);
+Ticker wari;
+LocalFileSystem local("local");
+int offset_JAPAN = 32400; //JSTのためのオフセット
+
+int main() {//unix timestamm
+set_time(1391948455+offset_JAPAN); // Set RTC time to Mon, 18 Apr 2011 13:00:00
+
+}
+
+
+int rpm=0,count=0;
+volatile bool flag;
+
+void time() {
+    flag=1;
+}
+
+void LFS() {
+    char time[16];
+lcd.locate(0,0);
+    rpm=count*60/2;
+    time_t seconds; time(&seconds);
+    strftime(time, 16, "%H:%M:%S\n", localtime(&seconds));
+    FILE *fp = fopen("/local/out.txt", "a");
+    fprintf(fp,"rpm=%4d,count=%4d,%s",rpm,count,time);
+    fclose(fp);
+    lcd.printf ("count=%4d,%s\r\n",count,time);
+    count=0;
+}
+
+int main2() {
+    wari.attach(&time, 1.0);
+
+    while (1) {
+        if (mgsw.count()>0) {
+
+            myled=1;
+            count++;
+            if (flag==1) {
+                LFS();
+                flag=0;
+            }
+        } else {
+            myled=0;
+        }
+        //lcd.printf("%4d",count);
+    }
+}
\ No newline at end of file