*\r
* Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de\r
*\r
- * $Id: irmp.c,v 1.62 2010/06/23 10:48:58 fm Exp $\r
+ * $Id: irmp.c,v 1.73 2010/06/26 18:13:11 fm Exp $\r
*\r
* ATMEGA88 @ 8 MHz\r
*\r
*\r
*---------------------------------------------------------------------------------------------------------------------------------------------------\r
*\r
+ * SIEMENS:\r
+ * --------\r
+ *\r
+ * SIEMENS frame: 1 start bit + 22 data bits + no stop bit\r
+ * SIEMENS data: 13 address bits + 1 repeat bit + 7 data bits + 1 unknown bit\r
+ *\r
+ * start bit data "0": data "1":\r
+ * -------_______ _______------- -------_______\r
+ * 250us 250us 250us 250us 250us 250us\r
+ *\r
+ *---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ *\r
* PANASONIC (older protocol, yet not implemented, see also MATSUSHITA, timing very similar)\r
* -----------------------------------------------------------------------------------------\r
*\r
#define IRMP_TIMEOUT_TIME_MS 16500L // timeout after 16.5 ms darkness\r
\r
#if (F_INTERRUPTS * IRMP_TIMEOUT_TIME_MS) / 1000000 >= 254\r
-#define IRMP_TIMEOUT_LEN (uint16_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)\r
typedef uint16_t PAUSE_LEN;\r
#else\r
-#define IRMP_TIMEOUT_LEN (uint8_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)\r
typedef uint8_t PAUSE_LEN;\r
#endif\r
\r
+#define IRMP_TIMEOUT_LEN (PAUSE_LEN)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)\r
#define IRMP_KEY_REPETITION_LEN (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec\r
\r
#define MIN_TOLERANCE_00 1.0 // -0%\r
#define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
#define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
#define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
-#define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) // 10% is too big (uint8_t)\r
+#define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX ((PAUSE_LEN)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) // value must be below IRMP_TIMEOUT\r
#define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
#define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
#define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
\r
#ifdef ANALYZE\r
\r
-// main function - for unix/linux + windows only!\r
-// AVR: see main.c!\r
-// Compile it under linux with:\r
-// cc irmp.c -o irmp\r
-//\r
-// usage: ./irmp [-v|-s|-a|-l|-p] < file\r
-// options:\r
-// -v verbose\r
-// -s silent\r
-// -a analyze\r
-// -l list pulse/pauses\r
-// -p print timings\r
+/*---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ * main functions - for Unix/Linux + Windows only!\r
+ *\r
+ * AVR: see main.c!\r
+ *\r
+ * Compile it under linux with:\r
+ * cc irmp.c -o irmp\r
+ *\r
+ * usage: ./irmp [-v|-s|-a|-l|-p] < file\r
+ *\r
+ * options:\r
+ * -v verbose\r
+ * -s silent\r
+ * -a analyze\r
+ * -l list pulse/pauses\r
+ * -p print timings\r
+ *---------------------------------------------------------------------------------------------------------------------------------------------------\r
+ */\r
\r
static void\r
print_timings (void)\r
{\r
+ printf ("IRMP_TIMEOUT_LEN: %d\n", IRMP_TIMEOUT_LEN);\r
+ printf ("IRMP_KEY_REPETITION_LEN %d\n", IRMP_KEY_REPETITION_LEN);\r
+ puts ("");\r
printf ("PROTOCOL S S-PULSE S-PAUSE PULSE-0 PAUSE-0 PULSE-1 PAUSE-1\n");\r
printf ("====================================================================================\n");\r
printf ("SIRCS 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",\r
BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,\r
BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);\r
\r
+ printf ("BANG_OLUFSEN 2 %3d - %3d %3d - %3d\n",\r
+ BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,\r
+ BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);\r
+\r
printf ("BANG_OLUFSEN 3 %3d - %3d %3d - %3d\n",\r
BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,\r
BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);\r
#define KEY_STOP 0x86 // keycode = 0x0076\r
#define KEY_MAIL 0x87 // keycode = 0x0077\r
#define KEY_FAVORITES 0x88 // keycode = 0x0078\r
-#define KEY_NEW_PAGE 0x99 // keycode = 0x0079\r
-#define KEY_SETUP 0x9A // keycode = 0x007a\r
-#define KEY_FONT 0x9B // keycode = 0x007b\r
-#define KEY_ON_OFF 0x9C // keycode = 0x007c\r
-\r
-#define KEY_INSERT 0xA0 // keycode = 0x004b\r
-#define KEY_DELETE 0xA1 // keycode = 0x004c\r
-#define KEY_LEFT 0xA2 // keycode = 0x004f\r
-#define KEY_HOME 0xA3 // keycode = 0x0050\r
-#define KEY_END 0xA4 // keycode = 0x0051\r
-#define KEY_UP 0xA5 // keycode = 0x0053\r
-#define KEY_DOWN 0xA6 // keycode = 0x0054\r
-#define KEY_PAGE_UP 0xA7 // keycode = 0x0055\r
-#define KEY_PAGE_DOWN 0xA8 // keycode = 0x0056\r
-#define KEY_RIGHT 0xA9 // keycode = 0x0059\r
+#define KEY_NEW_PAGE 0x89 // keycode = 0x0079\r
+#define KEY_SETUP 0x8A // keycode = 0x007a\r
+#define KEY_FONT 0x8B // keycode = 0x007b\r
+#define KEY_PRINT 0x8C // keycode = 0x007c\r
+#define KEY_ON_OFF 0x8E // keycode = 0x007c\r
+\r
+#define KEY_INSERT 0x90 // keycode = 0x004b\r
+#define KEY_DELETE 0x91 // keycode = 0x004c\r
+#define KEY_LEFT 0x92 // keycode = 0x004f\r
+#define KEY_HOME 0x93 // keycode = 0x0050\r
+#define KEY_END 0x94 // keycode = 0x0051\r
+#define KEY_UP 0x95 // keycode = 0x0053\r
+#define KEY_DOWN 0x96 // keycode = 0x0054\r
+#define KEY_PAGE_UP 0x97 // keycode = 0x0055\r
+#define KEY_PAGE_DOWN 0x98 // keycode = 0x0056\r
+#define KEY_RIGHT 0x99 // keycode = 0x0059\r
+#define KEY_MOUSE_1 0x9E // keycode = 0x0400\r
+#define KEY_MOUSE_2 0x9F // keycode = 0x0800\r
\r
static uint8_t\r
get_fdc_key (uint16_t cmd)\r
case 0x0055: key = KEY_PAGE_UP; break;\r
case 0x0056: key = KEY_PAGE_DOWN; break;\r
case 0x0059: key = KEY_RIGHT; break;\r
+ case 0x0400: key = KEY_MOUSE_1; break;\r
+ case 0x0800: key = KEY_MOUSE_2; break;\r
\r
default:\r
{\r
{\r
key = key_table[cmd] - 'a' + 1;\r
}\r
+ else\r
+ {\r
+ key = key_table[cmd];\r
+ }\r
}\r
else\r
{\r
\r
if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0)\r
{\r
- if (key >= 32 && key < 0x7F)\r
+ if ((key >= 0x20 && key < 0x7F) || key >= 0xA0)\r
{\r
- printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = %c\n",\r
+ printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = '%c'\n",\r
irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, key);\r
}\r
+ else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F)) // function keys\r
+ {\r
+ char * p = (char *) NULL;\r
+\r
+ switch (key)\r
+ {\r
+ case '\t' : p = "TAB"; break;\r
+ case '\r' : p = "CR"; break;\r
+ case KEY_ESCAPE : p = "ESCAPE"; break;\r
+ case KEY_MENUE : p = "MENUE"; break;\r
+ case KEY_BACK : p = "BACK"; break;\r
+ case KEY_FORWARD : p = "FORWARD"; break;\r
+ case KEY_ADDRESS : p = "ADDRESS"; break;\r
+ case KEY_WINDOW : p = "WINDOW"; break;\r
+ case KEY_1ST_PAGE : p = "1ST_PAGE"; break;\r
+ case KEY_STOP : p = "STOP"; break;\r
+ case KEY_MAIL : p = "MAIL"; break;\r
+ case KEY_FAVORITES : p = "FAVORITES"; break;\r
+ case KEY_NEW_PAGE : p = "NEW_PAGE"; break;\r
+ case KEY_SETUP : p = "SETUP"; break;\r
+ case KEY_FONT : p = "FONT"; break;\r
+ case KEY_PRINT : p = "PRINT"; break;\r
+ case KEY_ON_OFF : p = "ON_OFF"; break;\r
+\r
+ case KEY_INSERT : p = "INSERT"; break;\r
+ case KEY_DELETE : p = "DELETE"; break;\r
+ case KEY_LEFT : p = "LEFT"; break;\r
+ case KEY_HOME : p = "HOME"; break;\r
+ case KEY_END : p = "END"; break;\r
+ case KEY_UP : p = "UP"; break;\r
+ case KEY_DOWN : p = "DOWN"; break;\r
+ case KEY_PAGE_UP : p = "PAGE_UP"; break;\r
+ case KEY_PAGE_DOWN : p = "PAGE_DOWN"; break;\r
+ case KEY_RIGHT : p = "RIGHT"; break;\r
+ case KEY_MOUSE_1 : p = "KEY_MOUSE_1"; break;\r
+ case KEY_MOUSE_2 : p = "KEY_MOUSE_2"; break;\r
+ default : p = "<UNKNWON>"; break;\r
+ }\r
+\r
+ printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = %s\n",\r
+ irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, p);\r
+ }\r
else\r
{\r
printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x\n",\r