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

Dependencies:   AQM0802A DigitalSw mbed

Revision:
0:c5384fa0fc28
Child:
1:d4291fd3a94c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testLed.cpp	Sat May 20 01:33:48 2017 +0000
@@ -0,0 +1,144 @@
+#include "mbed.h"
+#include "testLed.h"
+
+DigitalOut testLed(LED1);
+
+Timer timerTestLed;
+bool brinkRequest = false;
+
+void testLedInitalize(void)
+{
+    timerTestLed.start();
+    timerTestLed.reset();
+    brinkRequest = false;
+
+}
+
+uint8_t brinkPosition = 0;  // brinkPattern[][ここ]
+uint16_t brinkPriod = 0;    // 点滅時間 1/1 ([ms]/count)
+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,100},
+    {0,100},
+    
+    {1,10},
+    {0,10},
+    
+    {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,100},
+    
+    {1,10},
+    {0,10},
+    
+    {1,200},
+    {0,300},
+    
+    {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,100},
+    
+    {1,10},
+    {0,10},
+    
+    {1,200},
+    {0,300},
+    
+    {1,100},
+    {0,100},
+    
+    {1,10},
+    {0,10},
+    
+    {1,200},
+    {0,300},
+    
+    {1,100},
+    {0,100},
+    
+    {1,10},
+    {0,10},
+    
+    {1,200},
+    {0,300},
+    
+    {2,0}       // end
+};
+
+bool testLedMain(bool request)
+{
+    if(brinkRequest == false) {
+        if(request == true) {
+            brinkRequest = true;
+            brinkPosition = 0;
+            testLed = brinkPattern[brinkPosition][0];
+            brinkPriod = brinkPattern[brinkPosition][1];
+
+            timerTestLed.reset();
+        } else {
+            // nothing
+        }
+    } else {
+        if(timerTestLed.read_ms() > brinkPriod) {
+            brinkPosition++;
+            if(brinkPattern[brinkPosition][0] == 2) {
+                testLed = 0;
+                brinkRequest = false;
+            } else {
+                testLed = brinkPattern[brinkPosition][0];
+                brinkPriod = brinkPattern[brinkPosition][1];
+            timerTestLed.reset();
+
+            }
+        }
+    }
+    return (brinkRequest);
+}
\ No newline at end of file