나중에 급하게 PID 알고리즘을 적용해 짜본 코드... 시간이 충분치 않아서 그냥 원래 있던 코드를 수정해서 하기로 했기에 버려진 코드지만, 교수님께 참고용으로 Publish를 했다.

Dependencies:   mbed Adafruit_GFX

Revision:
0:c4c874d702f9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteIR/TransmitterIR.h	Sat Jun 15 20:39:39 2019 +0000
@@ -0,0 +1,83 @@
+/**
+ * IR transmitter (Version 0.0.4)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#ifndef _TRANSMITTER_IR_H_
+#define _TRANSMITTER_IR_H_
+
+#include <mbed.h>
+
+#include "RemoteIR.h"
+
+/**
+ * IR transmitter class.
+ */
+class TransmitterIR {
+public:
+
+    /**
+     * Constructor.
+     *
+     * @param txpin Pin for transmit IR signal.
+     */
+    explicit TransmitterIR(PinName txpin);
+
+    /**
+     * Destructor.
+     */
+    ~TransmitterIR();
+
+    typedef enum {
+        Idle,
+        Leader,
+        Data,
+        Trailer
+    } State;
+
+    /**
+     * Get state.
+     *
+     * @return Current state.
+     */
+    State getState(void);
+
+    /**
+     * Set data.
+     *
+     * @param format Format.
+     * @param buf Buffer of a data.
+     * @param bitlength Bit length of the data.
+     *
+     * @return Data bit length.
+     */
+    int setData(RemoteIR::Format format, uint8_t *buf, int bitlength);
+
+private:
+
+    typedef struct {
+        State state;
+        int bitcount;
+        int leader;
+        int data;
+        int trailer;
+    } work_t;
+
+    typedef struct {
+        RemoteIR::Format format;
+        int bitlength;
+        uint8_t buffer[64];
+    } data_t;
+
+    PwmOut tx;
+    Ticker ticker;
+    data_t data;
+    work_t work;
+
+    void tick();
+
+};
+
+#endif
\ No newline at end of file