IRMP_DATA* data = &irmp_data[act_data];\r
if (irmp_get_data(data))\r
{\r
- led(HIGH);\r
+ led(HIGH);\r
#if IRMP_PROTOCOL_NAMES == 1\r
Serial.print(irmp_protocol_names[data->protocol]);\r
Serial.print(" ");\r
data->flags = 0; // reset flags!\r
int result = irsnd_send_data(data, TRUE);\r
if (result != 1)\r
- {\r
- Serial.println("loop : irsnd_send_data ERROR");\r
- }\r
- else\r
- {\r
- if (++act_data >= 3)\r
- {\r
- act_data = 0;\r
- } \r
- }\r
+ {\r
+ Serial.println("loop : irsnd_send_data ERROR");\r
+ }\r
+ else\r
+ {\r
+ if (++act_data >= 3)\r
+ {\r
+ act_data = 0;\r
+ } \r
+ }\r
}\r
\r
if (Serial.available() == 18 && readAndCheck('P') && readAndCheck(':'))\r
data->protocol = readHex() * 16 + readHex();\r
\r
if (readAndCheck(' ') && readAndCheck('A') && readAndCheck(':'))\r
- {\r
- // read the address\r
- data->address = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();\r
-\r
- if (readAndCheck(' ') && readAndCheck('C') && readAndCheck(':'))\r
- {\r
- // read the address\r
- data->command = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();\r
-\r
- // send ir data\r
- data->flags = 0;\r
- int result = irsnd_send_data(data, TRUE);\r
- if (result)\r
- {\r
- Serial.print("Send IR data: ");\r
- Serial.print("P:");\r
- Serial.print(data->protocol, HEX);\r
- Serial.print(" A:");\r
- Serial.print(data->address, HEX);\r
- Serial.print(" C:");\r
- Serial.print(data->command, HEX);\r
- Serial.println("");\r
-\r
- if (++act_data >= 3)\r
- {\r
- act_data = 0;\r
- } \r
- }\r
- }\r
- }\r
+ {\r
+ // read the address\r
+ data->address = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();\r
+\r
+ if (readAndCheck(' ') && readAndCheck('C') && readAndCheck(':'))\r
+ {\r
+ // read the address\r
+ data->command = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();\r
+\r
+ // send ir data\r
+ data->flags = 0;\r
+ int result = irsnd_send_data(data, TRUE);\r
+ if (result)\r
+ {\r
+ Serial.print("Send IR data: ");\r
+ Serial.print("P:");\r
+ Serial.print(data->protocol, HEX);\r
+ Serial.print(" A:");\r
+ Serial.print(data->address, HEX);\r
+ Serial.print(" C:");\r
+ Serial.print(data->command, HEX);\r
+ Serial.println("");\r
+\r
+ if (++act_data >= 3)\r
+ {\r
+ act_data = 0;\r
+ } \r
+ }\r
+ }\r
+ }\r
}\r
}\r
\r
/* helper function: attachInterrupt wants void(), but irmp_ISR is uint8_t() */\r
void timerinterrupt()\r
{\r
- // only when tsop dont see the ir_led flashing\r
- irsnd_ISR(); // call irsnd ISR\r
- irmp_ISR(); // call irmp ISR\r
-\r
-/*\r
- // do not receive when sending (tsop see the ir_led)\r
- if (! irsnd_ISR()) // call irsnd ISR\r
- { // if not busy...\r
- irmp_ISR(); // call irmp ISR\r
+#if 1 // if TSOP receiver can't detect my own IR LED, call both functions:\r
+ irsnd_ISR(); // call irsnd ISR\r
+ irmp_ISR(); // call irmp ISR\r
+#else // if TSOP receiver also detects my own IR LED, don't receive while sending:\r
+ if (! irsnd_ISR()) // call irsnd ISR\r
+ { // if not busy...\r
+ irmp_ISR(); // call irmp ISR\r
}\r
-*/\r
+#endif\r
}\r
\r
static inline void led(int state)\r
int c = Serial.read();\r
if (c >= '0' && c <= '9')\r
{\r
- return c - '0';\r
+ return c - '0';\r
}\r
\r
c |= 0x20; // lowercase\r
\r
if (c >= 'a' && c <= 'f')\r
{\r
- return c + 10 - 'a';\r
+ return c + 10 - 'a';\r
}\r
\r
return -1;\r