]> cloudbase.mooo.com Git - irmp.git/blobdiff - irmp.c
Version 2.9.4: added ACP24 protocol
[irmp.git] / irmp.c
diff --git a/irmp.c b/irmp.c
index ee462c3665200f0ede418a76995308ec6f954806..9c394365afd1b91991da391d213b17a8356f7117 100644 (file)
--- a/irmp.c
+++ b/irmp.c
@@ -3,7 +3,7 @@
  *\r
  * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de\r
  *\r
- * $Id: irmp.c,v 1.175 2015/05/29 08:23:56 fm Exp $\r
+ * $Id: irmp.c,v 1.176 2015/06/15 10:30:08 fm Exp $\r
  *\r
  * Supported AVR mikrocontrollers:\r
  *\r
 #define PENTAX_0_PAUSE_LEN_MIN                  ((uint_fast8_t)(F_INTERRUPTS * PENTAX_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
 #define PENTAX_0_PAUSE_LEN_MAX                  ((uint_fast8_t)(F_INTERRUPTS * PENTAX_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
 \r
+#define ACP24_START_BIT_PULSE_LEN_MIN           ((uint_fast8_t)(F_INTERRUPTS * ACP24_START_BIT_PULSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)\r
+#define ACP24_START_BIT_PULSE_LEN_MAX           ((uint_fast8_t)(F_INTERRUPTS * ACP24_START_BIT_PULSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)\r
+#define ACP24_START_BIT_PAUSE_LEN_MIN           ((uint_fast8_t)(F_INTERRUPTS * ACP24_START_BIT_PAUSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)\r
+#define ACP24_START_BIT_PAUSE_LEN_MAX           ((uint_fast8_t)(F_INTERRUPTS * ACP24_START_BIT_PAUSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)\r
+#define ACP24_PULSE_LEN_MIN                     ((uint_fast8_t)(F_INTERRUPTS * ACP24_PULSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)\r
+#define ACP24_PULSE_LEN_MAX                     ((uint_fast8_t)(F_INTERRUPTS * ACP24_PULSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)\r
+#define ACP24_1_PAUSE_LEN_MIN                   ((uint_fast8_t)(F_INTERRUPTS * ACP24_1_PAUSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)\r
+#define ACP24_1_PAUSE_LEN_MAX                   ((uint_fast8_t)(F_INTERRUPTS * ACP24_1_PAUSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)\r
+#define ACP24_0_PAUSE_LEN_MIN                   ((uint_fast8_t)(F_INTERRUPTS * ACP24_0_PAUSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)\r
+#define ACP24_0_PAUSE_LEN_MAX                   ((uint_fast8_t)(F_INTERRUPTS * ACP24_0_PAUSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)\r
+\r
 #define RADIO1_START_BIT_PULSE_LEN_MIN          ((uint_fast8_t)(F_INTERRUPTS * RADIO1_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
 #define RADIO1_START_BIT_PULSE_LEN_MAX          ((uint_fast8_t)(F_INTERRUPTS * RADIO1_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
 #define RADIO1_START_BIT_PAUSE_LEN_MIN          ((uint_fast8_t)(F_INTERRUPTS * RADIO1_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
@@ -592,6 +603,7 @@ static const char proto_merlin[]        PROGMEM = "MERLIN";
 static const char proto_pentax[]        PROGMEM = "PENTAX";\r
 static const char proto_fan[]           PROGMEM = "FAN";\r
 static const char proto_s100[]          PROGMEM = "S100";\r
+static const char proto_acp24[]         PROGMEM = "ACP24";\r
 \r
 static const char proto_radio1[]        PROGMEM = "RADIO1";\r
 \r
@@ -644,6 +656,7 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM =
     proto_pentax,\r
     proto_fan,\r
     proto_s100,\r
+    proto_acp24,\r
     proto_radio1\r
 };\r
 \r
@@ -1883,6 +1896,31 @@ static const PROGMEM IRMP_PARAMETER pentax_param =
 \r
 #endif\r
 \r
+#if IRMP_SUPPORT_ACP24_PROTOCOL == 1\r
+\r
+static const PROGMEM IRMP_PARAMETER acp24_param =\r
+{\r
+    IRMP_ACP24_PROTOCOL,                                                // protocol:        ir protocol\r
+    ACP24_PULSE_LEN_MIN,                                                // pulse_1_len_min: minimum length of pulse with bit value 1\r
+    ACP24_PULSE_LEN_MAX,                                                // pulse_1_len_max: maximum length of pulse with bit value 1\r
+    ACP24_1_PAUSE_LEN_MIN,                                              // pause_1_len_min: minimum length of pause with bit value 1\r
+    ACP24_1_PAUSE_LEN_MAX,                                              // pause_1_len_max: maximum length of pause with bit value 1\r
+    ACP24_PULSE_LEN_MIN,                                                // pulse_0_len_min: minimum length of pulse with bit value 0\r
+    ACP24_PULSE_LEN_MAX,                                                // pulse_0_len_max: maximum length of pulse with bit value 0\r
+    ACP24_0_PAUSE_LEN_MIN,                                              // pause_0_len_min: minimum length of pause with bit value 0\r
+    ACP24_0_PAUSE_LEN_MAX,                                              // pause_0_len_max: maximum length of pause with bit value 0\r
+    ACP24_ADDRESS_OFFSET,                                               // address_offset:  address offset\r
+    ACP24_ADDRESS_OFFSET + ACP24_ADDRESS_LEN,                           // address_end:     end of address\r
+    ACP24_COMMAND_OFFSET,                                               // command_offset:  command offset\r
+    ACP24_COMMAND_OFFSET + ACP24_COMMAND_LEN,                           // command_end:     end of command\r
+    ACP24_COMPLETE_DATA_LEN,                                            // complete_len:    complete length of frame\r
+    ACP24_STOP_BIT,                                                     // stop_bit:        flag: frame has stop bit\r
+    ACP24_LSB,                                                          // lsb_first:       flag: LSB first\r
+    ACP24_FLAGS                                                         // flags:           some flags\r
+};\r
+\r
+#endif\r
+\r
 #if IRMP_SUPPORT_RADIO1_PROTOCOL == 1\r
 \r
 static const PROGMEM IRMP_PARAMETER radio1_param =\r
@@ -2224,6 +2262,45 @@ static uint_fast8_t  parity;                                                // n
 static void\r
 irmp_store_bit (uint_fast8_t value)\r
 {\r
+#if IRMP_SUPPORT_ACP24_PROTOCOL == 1\r
+    if (irmp_param.protocol == IRMP_ACP24_PROTOCOL)                                                 // squeeze 64 bits into 16 bits:\r
+    {\r
+        if (value)\r
+        {\r
+            // ACP24-Frame:\r
+            //           1         2         3         4         5         6\r
+            // 0123456789012345678901234567890123456789012345678901234567890123456789\r
+            // N VVMMM    ? ???    t vmA x                 y                     TTTT\r
+            //\r
+            // irmp_data_p->command:\r
+            //\r
+            //         5432109876543210\r
+            //         NAVVvMMMmtxyTTTT\r
+\r
+            switch (irmp_bit)\r
+            {\r
+                case  0: irmp_tmp_command |= (1<<15); break;                                        // N\r
+                case  2: irmp_tmp_command |= (1<<13); break;                                        // V\r
+                case  3: irmp_tmp_command |= (1<<12); break;                                        // V\r
+                case  4: irmp_tmp_command |= (1<<10); break;                                        // M\r
+                case  5: irmp_tmp_command |= (1<< 9); break;                                        // M\r
+                case  6: irmp_tmp_command |= (1<< 8); break;                                        // M\r
+                case 20: irmp_tmp_command |= (1<< 6); break;                                        // t\r
+                case 22: irmp_tmp_command |= (1<<11); break;                                        // v\r
+                case 23: irmp_tmp_command |= (1<< 7); break;                                        // m\r
+                case 24: irmp_tmp_command |= (1<<14); break;                                        // A\r
+                case 26: irmp_tmp_command |= (1<< 5); break;                                        // x\r
+                case 44: irmp_tmp_command |= (1<< 4); break;                                        // y\r
+                case 66: irmp_tmp_command |= (1<< 3); break;                                        // T\r
+                case 67: irmp_tmp_command |= (1<< 2); break;                                        // T\r
+                case 68: irmp_tmp_command |= (1<< 1); break;                                        // T\r
+                case 69: irmp_tmp_command |= (1<< 0); break;                                        // T\r
+            }\r
+        }\r
+    }\r
+    else\r
+#endif // IRMP_SUPPORT_ACP24_PROTOCOL\r
+\r
 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1\r
     if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL)\r
     {\r
@@ -2260,7 +2337,11 @@ irmp_store_bit (uint_fast8_t value)
             }\r
         }\r
     }\r
+    else\r
 #endif\r
+    {\r
+        ;\r
+    }\r
 \r
 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1\r
     if (irmp_bit == 0 && irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL)\r
@@ -2694,6 +2775,20 @@ irmp_ISR (void)
                     else\r
 #endif // IRMP_SUPPORT_ROOMBA_PROTOCOL == 1\r
 \r
+#if IRMP_SUPPORT_ACP24_PROTOCOL == 1\r
+                    if (irmp_pulse_time >= ACP24_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ACP24_START_BIT_PULSE_LEN_MAX &&\r
+                        irmp_pause_time >= ACP24_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ACP24_START_BIT_PAUSE_LEN_MAX)\r
+                    {\r
+#ifdef ANALYZE\r
+                        ANALYZE_PRINTF ("protocol = ACP24, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                                        ACP24_START_BIT_PULSE_LEN_MIN, ACP24_START_BIT_PULSE_LEN_MAX,\r
+                                        ACP24_START_BIT_PAUSE_LEN_MIN, ACP24_START_BIT_PAUSE_LEN_MAX);\r
+#endif // ANALYZE\r
+                        irmp_param_p = (IRMP_PARAMETER *) &acp24_param;\r
+                    }\r
+                    else\r
+#endif // IRMP_SUPPORT_ROOMBA_PROTOCOL == 1\r
+\r
 #if IRMP_SUPPORT_PENTAX_PROTOCOL == 1\r
                     if (irmp_pulse_time >= PENTAX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= PENTAX_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= PENTAX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= PENTAX_START_BIT_PAUSE_LEN_MAX)\r
@@ -4812,7 +4907,7 @@ print_spectrum (char * text, int * buf, int is_pulse)
     double  average = 0;\r
     double  tolerance;\r
 \r
-    puts ("-------------------------------------------------------------------------------");\r
+    puts ("-----------------------------------------------------------------------------");\r
     printf ("%s:\n", text);\r
 \r
     for (i = 0; i < 256; i++)\r
@@ -5040,7 +5135,14 @@ next_tick (void)
                 printf ("%8.3fms ", (double) (time_counter * 1000) / F_INTERRUPTS);\r
             }\r
 \r
-            if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0)\r
+            if (irmp_data.protocol == IRMP_ACP24_PROTOCOL)\r
+            {\r
+                uint16_t    temp = (irmp_data.command & 0x000F) + 15;\r
+\r
+                printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, temp=%d",\r
+                        irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, temp);\r
+            }\r
+            else if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0)\r
             {\r
                 if ((key >= 0x20 && key < 0x7F) || key >= 0xA0)\r
                 {\r
@@ -5288,7 +5390,7 @@ main (int argc, char ** argv)
                 char *          p;\r
                 int             idx = -1;\r
 \r
-                puts ("-------------------------------------------------------------------");\r
+                puts ("----------------------------------------------------------------------");\r
                 putchar (ch);\r
 \r
 \r
@@ -5378,7 +5480,7 @@ main (int argc, char ** argv)
         print_spectrum ("START PAUSES", start_pauses, FALSE);\r
         print_spectrum ("PULSES", pulses, TRUE);\r
         print_spectrum ("PAUSES", pauses, FALSE);\r
-        puts ("-------------------------------------------------------------------------------");\r
+        puts ("-----------------------------------------------------------------------------");\r
     }\r
     return 0;\r
 }\r