LEDの点滅や、ブザーのOn,Offの周期測定をおこなう。 搬送波の周期は測定できない(10ms周期以上のON,OFF)

Dependencies:   AQM0802A DigitalSw mbed

Files at this revision

API Documentation at this revision

Comitter:
suupen
Date:
Thu Jun 08 04:46:15 2017 +0000
Parent:
4:001603e48dc8
Commit message:
???;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
priodMsurement.cpp Show annotated file Show diff for this revision Revisions of this file
priodMsurement.h Show annotated file Show diff for this revision Revisions of this file
testSound.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Jun 06 13:15:07 2017 +0000
+++ b/main.cpp	Thu Jun 08 04:46:15 2017 +0000
@@ -21,9 +21,9 @@
 
 //DigitalIn demoLedSw(p20, PullUp);
 
-//DigitalSw startSw(p19);
-DigitalSw upSw(p8);
-DigitalSw downSw(p14);
+DigitalSw startSw(p25);
+DigitalSw upSw(p30);
+DigitalSw downSw(p29);
 
 int main()
 {
@@ -59,18 +59,23 @@
                 p = 0;
             }
         }
+
+        if(startSw.getOnEdge() == 1) {
+            priodMsurementRequest();
+            }
+
 #ifdef LCD
         point = p;
         if(true ==  surementData(&point, &hiPriod, &loPriod)) {
             lcd.cls();
-            lcd.printf("p = %2d  hi = %d\n",point, hiPriod);
-            lcd.printf("surement lo = %d",loPriod);
+            lcd.printf("p=%2d hi = %4d\n",point, hiPriod);
+            lcd.printf("mem  lo = %4d",loPriod);
             wait(0.2);
         } else {
             p = 0;
             lcd.cls();
-            lcd.printf("p = %2d  hi = %d\n",point, hiPriod);
-            lcd.printf("sample   lo = %d",loPriod);
+            lcd.printf("p=%2d hi = %4d\n",point, hiPriod);
+            lcd.printf("smp  lo = %4d",loPriod);
             wait(0.2);
         }
 #endif // LCD
--- a/priodMsurement.cpp	Tue Jun 06 13:15:07 2017 +0000
+++ b/priodMsurement.cpp	Thu Jun 08 04:46:15 2017 +0000
@@ -1,10 +1,6 @@
 #include "mbed.h"
 #include "priodMsurement.h"
 
-DigitalOut dbgPort (p19);
-DigitalOut dbg2Port (p18);
-
-
 Timer hiTimer;  // hi priod timer
 Timer loTimer; // low priod timer
 Timer aTimer;
@@ -19,6 +15,13 @@
 int8_t P_surement = 0;     // D_surement[ここ][] のポインタ
 #define Z_nonSurement (-1)  // D_surementの最終位置(不定値)
 
+bool F_start = false; // 測定開始要求 false:なし true:あり
+void priodMsurementRequest(void)
+{
+    F_start = true;
+    }
+
+
 int8_t beforeLevel = -1; // 0:Lo 1:Hi -1:timeOut(non Pluse)
 
 #define Z_initialSurement (-1)// surementPut()への初期化指示
@@ -40,7 +43,7 @@
     }
 }
 
-InterruptIn lightIn(p22);
+InterruptIn lightIn(p18);
 DigitalOut monitor(LED4);
 bool surementData(int8_t *p, int32_t *hiPriod, int32_t *loPriod)
 {
@@ -69,11 +72,12 @@
         beforeLevel = 1;
         printf("hi = %d,  lo = %d\r\n",hiCompleteTime, loCompleteTime);
     }
-    if(beforeLevel == -1) {
-//    if((beforeLevel == -1) && (F_start == true)) {
+//    if(beforeLevel == -1) {
+    if((beforeLevel == -1) && (F_start == true)) {
         printf("start\r\n");
         surementPut(Z_initialSurement, (int32_t)Z_initialSurement);
         beforeLevel = 1;
+        F_start = false;
     }
     monitor = 1;
 }
@@ -84,8 +88,8 @@
     if(beforeLevel == 1) {
         hiCompleteTime = hiTimer.read_ms();
         surementPut(Z_hiSurement, hiCompleteTime);
+    beforeLevel = 0;
     }
-    beforeLevel = 0;
     monitor = 0;
 }
 
--- a/priodMsurement.h	Tue Jun 06 13:15:07 2017 +0000
+++ b/priodMsurement.h	Thu Jun 08 04:46:15 2017 +0000
@@ -8,6 +8,8 @@
 void priodMsurementInitalize(void);
 void priodMsurementMain(void);
 bool surementData(int8_t *p, int32_t *hiPriod, int32_t *loPriod);
+void priodMsurementRequest(void);
+
 
 
 #endif // PRIODMSUREMENT_H
\ No newline at end of file
--- a/testSound.cpp	Tue Jun 06 13:15:07 2017 +0000
+++ b/testSound.cpp	Thu Jun 08 04:46:15 2017 +0000
@@ -4,8 +4,8 @@
 void tickSound(void);
 Ticker tickSounder;
 
-DigitalOut dbgSoundPort(p25);
-DigitalOut testSound(p26);
+DigitalOut dbgSoundPort(p22);
+DigitalOut testSound(p21);
 
 Timer timerTestSound;
 bool brinkRequestSound = false;