赤外線リモコンの送信をパルス幅にて行います。 IRRcevPulseWidthライブラリと合わせて使ってください。 Transmit IR control by pulse width. Please use it together with the IRRcevPulseWidth library.

Dependents:   IRLED_SendReceveDemo

Files at this revision

API Documentation at this revision

Comitter:
nameless129
Date:
Sun Dec 25 09:53:36 2016 +0000
Commit message:
first commit

Changed in this revision

IRSendPulseWidth.cpp Show annotated file Show diff for this revision Revisions of this file
IRSendPulseWidth.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IRSendPulseWidth.cpp	Sun Dec 25 09:53:36 2016 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+#include "IRSendPulseWidth.h"
+
+IRSendPulseWidth::IRSendPulseWidth(PinName output) : g_pwmoutLed(output)
+{
+    g_pwmoutLed.period_us(26);
+    g_pwmoutLed.write(0);
+}
+    
+void IRSendPulseWidth::sendSignal(uint16_t *sendDataArray,uint16_t sendDataN)
+{
+    int iCountHighLow = sendDataN;
+    for( int iIndexHighLow = 0; iIndexHighLow < iCountHighLow; iIndexHighLow++ )
+    {
+        g_pwmoutLed.write( 0.5 * (1 - (iIndexHighLow % 2)) );    // iIndexHighLow : even number -> 0.5, uneven number -> 0
+        wait_us( *(sendDataArray+iIndexHighLow) );
+    }
+    g_pwmoutLed.write(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IRSendPulseWidth.h	Sun Dec 25 09:53:36 2016 +0000
@@ -0,0 +1,17 @@
+#ifndef __IRSEND_PULSEWIDTH_H__
+#define __IRSEND_PULSEWIDTH_H__
+
+#include "mbed.h"
+
+
+class IRSendPulseWidth {
+public:
+    IRSendPulseWidth(PinName output);
+
+    void sendSignal(uint16_t *sendDataArray,uint16_t sendDataN);
+
+private:
+    PwmOut g_pwmoutLed;
+};
+
+#endif
\ No newline at end of file