summaryrefslogtreecommitdiffstats
path: root/onkyo_ri.pde
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2011-11-18 21:55:22 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2011-11-18 21:55:22 +0100
commit91cff6f6d1db8c9ae4f241a5a58838ce1ad456e3 (patch)
treebf59e00564a3e21b6d95da66f97ae92b3dfc7e3e /onkyo_ri.pde
parentc0df64a187ea150ac775151022ed2d60cd063e91 (diff)
downloadonkyo-ri-91cff6f6d1db8c9ae4f241a5a58838ce1ad456e3.tar.gz
onkyo-ri-91cff6f6d1db8c9ae4f241a5a58838ce1ad456e3.tar.xz
onkyo-ri-91cff6f6d1db8c9ae4f241a5a58838ce1ad456e3.zip
added ir proto and key definitions
Diffstat (limited to 'onkyo_ri.pde')
-rw-r--r--onkyo_ri.pde36
1 files changed, 15 insertions, 21 deletions
diff --git a/onkyo_ri.pde b/onkyo_ri.pde
index 89adcfc..2a6aa7b 100644
--- a/onkyo_ri.pde
+++ b/onkyo_ri.pde
@@ -24,14 +24,9 @@ MD = 71808
#define RESOLUTION 20
#define FUZZINESS 20
-int header[] = {300, 100};
-int values[2][2] = { {100, 100}, {100, 200} };
-int trail[] = { 100 };
-uint8_t bits = 12;
-
uint8_t raw[2];
-uint64_t listenForIR(void);
+uint64_t listenForIR(ir_t *proto);
int getPulseLength();
int getPulseLengthInRange(int expected);
@@ -42,7 +37,7 @@ void setup(void) {
}
void loop(void) {
- uint64_t code = listenForIR();
+ uint64_t code = listenForIR(&onkyo);
Serial.println(code, HEX);
}
@@ -82,36 +77,35 @@ int getPulseLengthInRange(int expected) {
return length;
}
-uint64_t listenForIR(void) {
+uint64_t listenForIR(ir_t *proto) {
int length;
uint64_t code;
- uint8_t i;
+ uint8_t i, j, k;
+ bool found;
start:
code = 0;
- for (i = 0; i < ARRAY_LEN(header); i++) {
- length = getPulseLengthInRange(header[i]);
+ for (i = 0; i < ARRAY_LEN(proto->header); i++) {
+ length = getPulseLengthInRange(proto->header[i]);
- if ((length == 0) || (length < 0))
+ if (length <= 0)
goto start;
}
- for (uint8_t j = 0; j < bits; j++) {
+ for (j = 0; j < proto->bits; j++) {
for (i = 0; i < ARRAY_LEN(raw); i++) {
raw[i] = getPulseLength();
- if ((raw[i] == 0) || (raw[i] < 0))
+ if (raw[i] <= 0)
goto start;
}
- bool found;
-
- for (uint8_t k = 0; k < ARRAY_LEN(values); k++) {
+ for (k = 0; k < ARRAY_LEN(proto->values); k++) {
found = true;
for (i = 0; i < ARRAY_LEN(raw); i++) {
- if (!inRange(raw[i], values[k][i])) {
+ if (!inRange(raw[i], proto->values[k][i])) {
found = false;
break;
}
@@ -132,10 +126,10 @@ start:
}
}
- for (i = 0; i < ARRAY_LEN(trail); i++) {
- length = getPulseLengthInRange(trail[i]);
+ for (i = 0; i < ARRAY_LEN(proto->trail); i++) {
+ length = getPulseLengthInRange(proto->trail[i]);
- if ((length == 0) || (length < 0))
+ if (length <= 0)
goto start;
}