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

Dependencies:   AQM0802A DigitalSw mbed

Revision:
1:d4291fd3a94c
Parent:
0:c5384fa0fc28
Child:
2:f22110fb3925
--- a/testLed.cpp	Sat May 20 01:33:48 2017 +0000
+++ b/testLed.cpp	Sat May 20 12:23:42 2017 +0000
@@ -1,125 +1,96 @@
 #include "mbed.h"
 #include "testLed.h"
 
+void tick(void);
+Ticker ticker;
+DigitalOut myled3(LED3);
+
 DigitalOut testLed(LED1);
 
 Timer timerTestLed;
 bool brinkRequest = false;
 
+
+
 void testLedInitalize(void)
 {
     timerTestLed.start();
     timerTestLed.reset();
     brinkRequest = false;
 
+    ticker.attach_us(&tick, 1000);
 }
 
 uint8_t brinkPosition = 0;  // brinkPattern[][ここ]
 uint16_t brinkPriod = 0;    // 点滅時間 1/1 ([ms]/count)
+bool testLedLevel = false;  // false:Off true:On
 uint32_t brinkPattern[][2] = {
-    {1,10},
-    {0,10},
-    
     {1,100},
     {0,100},
-    
-    {1,10},
-    {0,10},
-    
-    {1,100},
-    {0,100},
-    
-    {1,10},
-    {0,10},
-    
+
+    {1,500},
+    {0,500},
+
     {1,100},
     {0,100},
-    
-    {1,10},
-    {0,10},
-    
+
+    {1,500},
+    {0,500},
+
     {1,100},
     {0,100},
-    
-    {1,10},
-    {0,10},
-    
-    {1,200},
-    {0,300},
-    
+
+    {1,500},
+    {0,500},
+
     {1,100},
     {0,100},
-    
-    {1,10},
-    {0,10},
-    
-    {1,200},
-    {0,300},
-    
+
     {1,100},
     {0,100},
-    
-    {1,10},
-    {0,10},
-    
-    {1,200},
-    {0,300},
-    
+
+    {1,100},
+    {0,500},
+
     {1,100},
-    {0,100},
-    
-    {1,10},
-    {0,10},
-    
-    {1,200},
-    {0,300},
-    
+    {0,500},
+
     {1,100},
-    {0,100},
-    
-    {1,10},
-    {0,10},
-    
-    {1,200},
-    {0,300},
-    
+    {0,500},
+
     {1,100},
-    {0,100},
-    
-    {1,10},
-    {0,10},
-    
-    {1,200},
-    {0,300},
-    
+    {0,500},
+
     {1,100},
-    {0,100},
-    
-    {1,10},
-    {0,10},
-    
-    {1,200},
-    {0,300},
-    
-    {1,100},
-    {0,100},
-    
-    {1,10},
-    {0,10},
-    
-    {1,200},
-    {0,300},
-    
+    {0,500},
+
+    {1,500},
+    {0,500},
+
+
+
     {2,0}       // end
 };
 
+void tick(void)
+{
+    myled3 = !myled3;
+    if(testLedLevel == true) {
+        testLed = !testLed;
+    } else {
+        testLed = 0;
+    }
+}
+
+
+
 bool testLedMain(bool request)
 {
     if(brinkRequest == false) {
         if(request == true) {
             brinkRequest = true;
             brinkPosition = 0;
-            testLed = brinkPattern[brinkPosition][0];
+            testLedLevel = brinkPattern[brinkPosition][0];
             brinkPriod = brinkPattern[brinkPosition][1];
 
             timerTestLed.reset();
@@ -130,12 +101,12 @@
         if(timerTestLed.read_ms() > brinkPriod) {
             brinkPosition++;
             if(brinkPattern[brinkPosition][0] == 2) {
-                testLed = 0;
+                testLedLevel = 0;
                 brinkRequest = false;
             } else {
-                testLed = brinkPattern[brinkPosition][0];
+                testLedLevel = brinkPattern[brinkPosition][0];
                 brinkPriod = brinkPattern[brinkPosition][1];
-            timerTestLed.reset();
+                timerTestLed.reset();
 
             }
         }