Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 12:5833495063f7, committed 2019-06-12
- Comitter:
- kmsmile2
- Date:
- Wed Jun 12 08:05:57 2019 +0000
- Parent:
- 11:268cc2ab63bd
- Commit message:
- remotIR;
Changed in this revision
--- a/ReceiverIR.cpp Mon Sep 20 00:54:59 2010 +0000
+++ b/ReceiverIR.cpp Wed Jun 12 08:05:57 2019 +0000
@@ -22,7 +22,7 @@
evt.fall(this, &ReceiverIR::isr_fall);
evt.rise(this, &ReceiverIR::isr_rise);
evt.mode(PullUp);
- ticker.attach_us(this, &ReceiverIR::isr_wdt, 10 * 1000);
+ ticker.attach_us(this, &ReceiverIR::isr_wdt, 10 * 1000); // 0.1초
}
/**
@@ -73,19 +73,19 @@
return nbits;
}
-void ReceiverIR::init_state(void) {
+void ReceiverIR::init_state(void) { // init_state function
work.c1 = -1;
work.c2 = -1;
work.c3 = -1;
work.d1 = -1;
work.d2 = -1;
work.state = Idle;
- data.format = RemoteIR::UNKNOWN;
+ data.format = RemoteIR::UNKNOWN; // 코드 방식 미정, 모
data.bitcount = 0;
timer.stop();
timer.reset();
for (int i = 0; i < sizeof(data.buffer); i++) {
- data.buffer[i] = 0;
+ data.buffer[i] = 0; // 8바이트 buffer 0으로 초기화
}
}
@@ -126,7 +126,7 @@
work.c3 = timer.read_us();
int a = work.c2 - work.c1;
int b = work.c3 - work.c2;
- if (InRange(a, RemoteIR::TUS_NEC * 16) && InRange(b, RemoteIR::TUS_NEC * 8)) {
+ if (InRange(a, RemoteIR::TUS_NEC * 16) && InRange(b, RemoteIR::TUS_NEC * 8)) { // 9 sec, 4.5 sec
/*
* NEC.
*/
@@ -172,11 +172,11 @@
case Receiving:
if (RemoteIR::NEC == data.format) {
work.d2 = timer.read_us();
- int a = work.d2 - work.d1;
- if (InRange(a, RemoteIR::TUS_NEC * 3)) {
- data.buffer[data.bitcount / 8] |= (1 << (data.bitcount % 8));
- } else if (InRange(a, RemoteIR::TUS_NEC * 1)) {
- data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8));
+ int a = work.d2 - work.d1; // a = rising 했다가 falling 하는 그 사이 시간
+ if (InRange(a, RemoteIR::TUS_NEC * 3)) { // 1인 경우
+ data.buffer[data.bitcount / 8] |= (1 << (data.bitcount % 8)); // 무조건 1을 만들겠다
+ } else if (InRange(a, RemoteIR::TUS_NEC * 1)) { // 0인 경우
+ data.buffer[data.bitcount / 8] &= ~(1 << (data.bitcount % 8)); // 무조건 0을 만들겠다
}
data.bitcount++;
#if 0
@@ -232,6 +232,7 @@
}
break;
case Received:
+ code = data.buffer[2];
break;
default:
break;
--- a/ReceiverIR.h Mon Sep 20 00:54:59 2010 +0000
+++ b/ReceiverIR.h Wed Jun 12 08:05:57 2019 +0000
@@ -57,15 +57,18 @@
*/
int getData(RemoteIR::Format *format, uint8_t *buf, int bitlength);
-private:
-
- typedef struct {
+ typedef struct { // 구조체
RemoteIR::Format format;
int bitcount;
uint8_t buffer[64];
} data_t;
- typedef struct {
+ data_t data;
+ int code;
+
+private:
+
+ typedef struct { // 구조체
State state;
int c1;
int c2;
@@ -73,13 +76,13 @@
int d1;
int d2;
} work_t;
+
InterruptIn evt; /**< Interrupt based input for input. */
Timer timer; /**< Timer for WDT. */
Ticker ticker; /**< Tciker for tick. */
Timeout timeout; /**< Timeout for tail. */
- data_t data;
work_t work;
void init_state(void);
--- a/RemoteIR.h Mon Sep 20 00:54:59 2010 +0000
+++ b/RemoteIR.h Wed Jun 12 08:05:57 2019 +0000
@@ -11,7 +11,7 @@
class RemoteIR {
public:
- typedef enum {
+ typedef enum { // 코드 방식
UNKNOWN,
NEC,
NEC_REPEAT,
@@ -23,6 +23,7 @@
static const int TUS_NEC = 562;
static const int TUS_AEHA = 425;
static const int TUS_SONY = 600;
+
private:
RemoteIR();