diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2011-11-18 21:55:22 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2011-11-18 21:55:22 +0100 |
commit | 91cff6f6d1db8c9ae4f241a5a58838ce1ad456e3 (patch) | |
tree | bf59e00564a3e21b6d95da66f97ae92b3dfc7e3e | |
parent | c0df64a187ea150ac775151022ed2d60cd063e91 (diff) | |
download | onkyo-ri-91cff6f6d1db8c9ae4f241a5a58838ce1ad456e3.tar.gz onkyo-ri-91cff6f6d1db8c9ae4f241a5a58838ce1ad456e3.tar.xz onkyo-ri-91cff6f6d1db8c9ae4f241a5a58838ce1ad456e3.zip |
added ir proto and key definitions
-rw-r--r-- | onkyo_ri.pde | 36 | ||||
-rw-r--r-- | signals.h | 71 |
2 files changed, 86 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; } diff --git a/signals.h b/signals.h new file mode 100644 index 0000000..f9a823b --- /dev/null +++ b/signals.h @@ -0,0 +1,71 @@ +#ifndef SIGNALS_H +#define SIGNALS_H + +typedef struct { + int header[2]; + int values[2][2]; + + int prebits; + long pre; + + int trail[1]; + + int bits; +} ir_t; + + +ir_t onkyo = { + {300, 100}, + { {100, 100}, {100, 200} }, + 0, + 0, + { 100 }, + 12 +}; + +ir_t pioneer = { + {850, 430}, + { {50, 60}, {50, 160} }, + 16, + 0x45BA, + { 50 }, + 16 +}; + +typedef struct { + long from; + long to; +} ir_map_t; + +ir_map_t ir_map[] = { + { 0x0600, 0x708F }, // CDR_Forward + { 0x0601, 0xF00F }, // CDR_Rewind + { 0x0604, 0x38C7 }, // CDR_On + // { 0x0605, 0x0 }, // CDR_Eject? + // { 0x0606, 0x0 }, // CDR_Display + { 0x0607, 0x52AD }, // CDR_Random + // { 0x0608, 0x0 }, // CDR_Memory? + // { 0x0609, 0x0 }, // CDR_Clear + { 0x060A, 0x30CF }, // CDR_Repeat + { 0x060E, 0x807F }, // CDR_1 + { 0x060F, 0x40BF }, // CDR_2 + { 0x0610, 0xC03F }, // CDR_3 + { 0x0611, 0x20DF }, // CDR_4 + { 0x0612, 0xA05F }, // CDR_5 + { 0x0613, 0x609F }, // CDR_6 + { 0x0614, 0xE01F }, // CDR_7 + { 0x0615, 0x10EF }, // CDR_8 + { 0x0616, 0x906F }, // CDR_9 + { 0x0617, 0x00FF }, // CDR_0 + { 0x0618, 0x6A95 }, // CDR_Digits + { 0x0619, 0x7A85 }, // CDR_PlayMode (Hi-Lite) + // { 0x061A, 0x0 }, // CDR_Rec? + { 0x061B, 0xE817 }, // CDR_Play + { 0x061C, 0x6897 }, // CDR_Stop + { 0x061D, 0x08F7 }, // CDR_NextChapter + { 0x061E, 0x8877 }, // CDR_PrevChapter + { 0x061F, 0x18E7 }, // CDR_Pause + // { 0x068F, 0x0 }, // CDR_Standby? +}; + +#endif |