Dependents:   WeatherStation

Files at this revision

API Documentation at this revision

Comitter:
okini3939
Date:
Fri Oct 07 14:53:44 2011 +0000
Parent:
2:64bc38078592
Commit message:

Changed in this revision

ILinterpreter.cpp Show annotated file Show diff for this revision Revisions of this file
ILinterpreter.h Show annotated file Show diff for this revision Revisions of this file
diff -r 64bc38078592 -r ed09123d603f ILinterpreter.cpp
--- a/ILinterpreter.cpp	Tue Jun 28 15:47:31 2011 +0000
+++ b/ILinterpreter.cpp	Fri Oct 07 14:53:44 2011 +0000
@@ -1,3 +1,9 @@
+/*
+ * Instruction List interpreter library
+ * Copyright (c) 2011 Hiroshi Suga
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+
 /** @file
  * @brief Instruction List interpreter
  */
@@ -64,7 +70,7 @@
         value = tim->tm_year + 1900;
         break;
     case 'm':
-        value = tim->tm_mon;
+        value = tim->tm_mon + 1;
         break;
     case 'd':
         value = tim->tm_mday;
@@ -94,9 +100,9 @@
     case 'T': // Timer
         if (keynum >= IL_TIMER_NUM) break;
         if (il[i].expression == EXP_NULL) {
-            value = io->timer_flg[keynum] && io->timer_cnt[keynum] >= io->timer_set[keynum];
+            value = io->timer_flg[keynum] && io->timer_set[keynum] && io->timer_cnt[keynum] >= io->timer_set[keynum];
         } else {
-            value = io->timer_cnt[keynum];
+            value = (float)io->timer_cnt[keynum] / 10.0;
         }
         break;
 
@@ -213,6 +219,9 @@
     addr = 0;
     inout.sec = time(NULL);
     inout_tmp = inout;
+#ifdef DEBUG
+    printf("timer0=%d(%d) timer1=%d(%d)\r\n", inout.timer_cnt[0], inout.timer_set[0], inout.timer_cnt[1], inout.timer_set[1]);
+#endif
 
     // mnemonic decode
     for(i = 0; i < il_count; i ++) {
@@ -293,9 +302,6 @@
 
     inout_old = inout_tmp;
 
-#ifdef DEBUG
-    printf("timer0=%d(%d) timer1=%d(%d)\r\n", inout.timer_cnt[0], inout.timer_set[0], inout.timer_cnt[1], inout.timer_set[1]);
-#endif
     return 0;
 }
 
@@ -401,11 +407,11 @@
     for (i = 0; i < il_count; i ++) {
       if (il[i].mnemonic == MNE_DEF) {
         switch (il[i].key) {
-        case 't': // Timer
+        case 'T': // Timer
             inout.timer_set[il[i].keynum] = (int)il[i].value * 10;
             break;
 
-        case 'c': // Counter
+        case 'C': // Counter
             inout.count_set[il[i].keynum] = (int)il[i].value;
             break;
         }
@@ -414,7 +420,7 @@
 
     fclose(fp);
 
-    return 0;
+    return il_count;
 }
 
 int ILinterpreter::push (int dat) {
diff -r 64bc38078592 -r ed09123d603f ILinterpreter.h
--- a/ILinterpreter.h	Tue Jun 28 15:47:31 2011 +0000
+++ b/ILinterpreter.h	Fri Oct 07 14:53:44 2011 +0000
@@ -1,3 +1,9 @@
+/*
+ * Instruction List interpreter library
+ * Copyright (c) 2011 Hiroshi Suga
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+
 /** @file
  * @brief Instruction List interpreter
  */