]> cloudbase.mooo.com Git - irmp.git/blobdiff - irmp.c
Version 3.0.5: added support of non-standard NEC repetition frames with pause of...
[irmp.git] / irmp.c
diff --git a/irmp.c b/irmp.c
index 3b97afc50043762c1921a9ac131af6631e0be48b..27c31be1e10ac037198441d3f609ecb89eb8ab9f 100644 (file)
--- a/irmp.c
+++ b/irmp.c
@@ -3,7 +3,7 @@
  *\r
  * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de\r
  *\r
- * $Id: irmp.c,v 1.187 2016/09/09 07:53:29 fm Exp $\r
+ * $Id: irmp.c,v 1.190 2016/12/16 09:18:11 fm Exp $\r
  *\r
  * Supported AVR mikrocontrollers:\r
  *\r
 #define MITSU_HEAVY_0_PAUSE_LEN_MIN             ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
 #define MITSU_HEAVY_0_PAUSE_LEN_MAX             ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
 \r
+#define VINCENT_START_BIT_PULSE_LEN_MIN         ((uint_fast8_t)(F_INTERRUPTS * VINCENT_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define VINCENT_START_BIT_PULSE_LEN_MAX         ((uint_fast8_t)(F_INTERRUPTS * VINCENT_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#define VINCENT_START_BIT_PAUSE_LEN_MIN         ((uint_fast8_t)(F_INTERRUPTS * VINCENT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define VINCENT_START_BIT_PAUSE_LEN_MAX         ((uint_fast8_t)(F_INTERRUPTS * VINCENT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#define VINCENT_PULSE_LEN_MIN                   ((uint_fast8_t)(F_INTERRUPTS * VINCENT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
+#define VINCENT_PULSE_LEN_MAX                   ((uint_fast8_t)(F_INTERRUPTS * VINCENT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
+#define VINCENT_1_PAUSE_LEN_MIN                 ((uint_fast8_t)(F_INTERRUPTS * VINCENT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
+#define VINCENT_1_PAUSE_LEN_MAX                 ((uint_fast8_t)(F_INTERRUPTS * VINCENT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
+#define VINCENT_0_PAUSE_LEN_MIN                 ((uint_fast8_t)(F_INTERRUPTS * VINCENT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
+#define VINCENT_0_PAUSE_LEN_MAX                 ((uint_fast8_t)(F_INTERRUPTS * VINCENT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
+\r
 #define PANASONIC_START_BIT_PULSE_LEN_MIN       ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
 #define PANASONIC_START_BIT_PULSE_LEN_MAX       ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
 #define PANASONIC_START_BIT_PAUSE_LEN_MIN       ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
@@ -635,6 +646,7 @@ static const char proto_acp24[]         PROGMEM = "ACP24";
 static const char proto_technics[]      PROGMEM = "TECHNICS";\r
 static const char proto_panasonic[]     PROGMEM = "PANASONIC";\r
 static const char proto_mitsu_heavy[]   PROGMEM = "MITSU_HEAVY";\r
+static const char proto_vincent[]       PROGMEM = "VINCENT";\r
 \r
 static const char proto_radio1[]        PROGMEM = "RADIO1";\r
 \r
@@ -691,6 +703,7 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM =
     proto_technics,\r
     proto_panasonic,\r
     proto_mitsu_heavy,\r
+    proto_vincent,\r
     proto_radio1\r
 };\r
 \r
@@ -1336,6 +1349,31 @@ static const PROGMEM IRMP_PARAMETER mitsu_heavy_param =
 \r
 #endif\r
 \r
+#if IRMP_SUPPORT_VINCENT_PROTOCOL == 1\r
+\r
+static const PROGMEM IRMP_PARAMETER vincent_param =\r
+{\r
+    IRMP_VINCENT_PROTOCOL,                                              // protocol:        ir protocol\r
+    VINCENT_PULSE_LEN_MIN,                                              // pulse_1_len_min: minimum length of pulse with bit value 1\r
+    VINCENT_PULSE_LEN_MAX,                                              // pulse_1_len_max: maximum length of pulse with bit value 1\r
+    VINCENT_1_PAUSE_LEN_MIN,                                            // pause_1_len_min: minimum length of pause with bit value 1\r
+    VINCENT_1_PAUSE_LEN_MAX,                                            // pause_1_len_max: maximum length of pause with bit value 1\r
+    VINCENT_PULSE_LEN_MIN,                                              // pulse_0_len_min: minimum length of pulse with bit value 0\r
+    VINCENT_PULSE_LEN_MAX,                                              // pulse_0_len_max: maximum length of pulse with bit value 0\r
+    VINCENT_0_PAUSE_LEN_MIN,                                            // pause_0_len_min: minimum length of pause with bit value 0\r
+    VINCENT_0_PAUSE_LEN_MAX,                                            // pause_0_len_max: maximum length of pause with bit value 0\r
+    VINCENT_ADDRESS_OFFSET,                                             // address_offset:  address offset\r
+    VINCENT_ADDRESS_OFFSET + VINCENT_ADDRESS_LEN,                       // address_end:     end of address\r
+    VINCENT_COMMAND_OFFSET,                                             // command_offset:  command offset\r
+    VINCENT_COMMAND_OFFSET + VINCENT_COMMAND_LEN,                       // command_end:     end of command\r
+    VINCENT_COMPLETE_DATA_LEN,                                          // complete_len:    complete length of frame\r
+    VINCENT_STOP_BIT,                                                   // stop_bit:        flag: frame has stop bit\r
+    VINCENT_LSB,                                                        // lsb_first:       flag: LSB first\r
+    VINCENT_FLAGS                                                       // flags:           some flags\r
+};\r
+\r
+#endif\r
+\r
 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1\r
 \r
 static const PROGMEM IRMP_PARAMETER recs80_param =\r
@@ -2200,6 +2238,18 @@ irmp_get_data (IRMP_DATA * irmp_data_p)
                 }\r
                 break;\r
 #endif\r
+\r
+\r
+#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
+            case IRMP_VINCENT_PROTOCOL:\r
+                if ((irmp_command >> 8) == (irmp_command & 0x00FF))\r
+                {\r
+                    irmp_command &= 0xff;\r
+                    rtc = TRUE;\r
+                }\r
+                break;\r
+#endif\r
+\r
 #if IRMP_SUPPORT_BOSE_PROTOCOL == 1\r
             case IRMP_BOSE_PROTOCOL:\r
                 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))\r
@@ -3066,6 +3116,20 @@ irmp_ISR (void)
                     else\r
 #endif // IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1\r
 \r
+#if IRMP_SUPPORT_VINCENT_PROTOCOL == 1\r
+                    if (irmp_pulse_time >= VINCENT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= VINCENT_START_BIT_PULSE_LEN_MAX &&\r
+                        irmp_pause_time >= VINCENT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= VINCENT_START_BIT_PAUSE_LEN_MAX)\r
+                    {                                                           // it's VINCENT\r
+#ifdef ANALYZE\r
+                        ANALYZE_PRINTF ("protocol = VINCENT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                                        VINCENT_START_BIT_PULSE_LEN_MIN, VINCENT_START_BIT_PULSE_LEN_MAX,\r
+                                        VINCENT_START_BIT_PAUSE_LEN_MIN, VINCENT_START_BIT_PAUSE_LEN_MAX);\r
+#endif // ANALYZE\r
+                        irmp_param_p = (IRMP_PARAMETER *) &vincent_param;\r
+                    }\r
+                    else\r
+#endif // IRMP_SUPPORT_VINCENT_PROTOCOL == 1\r
+\r
 #if IRMP_SUPPORT_RADIO1_PROTOCOL == 1\r
                     if (irmp_pulse_time >= RADIO1_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RADIO1_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= RADIO1_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RADIO1_START_BIT_PAUSE_LEN_MAX)\r
@@ -3880,6 +3944,32 @@ irmp_ISR (void)
                             {\r
                                 irmp_bit++;\r
                             }\r
+#if IRMP_SUPPORT_NEC_PROTOCOL == 1\r
+                            else if ((irmp_param.protocol == IRMP_NEC_PROTOCOL || irmp_param.protocol == IRMP_NEC42_PROTOCOL) && irmp_bit == 0)\r
+                            {                                                               // it was a non-standard repetition frame\r
+#ifdef ANALYZE                                                                              // with 4500µs pause instead of 2250µs\r
+                                ANALYZE_PRINTF ("Detected non-standard repetition frame, switching to NEC repetition\n");\r
+#endif // ANALYZE\r
+                                if (key_repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX)\r
+                                {\r
+                                    irmp_param.stop_bit     = TRUE;                         // set flag\r
+                                    irmp_param.protocol     = IRMP_NEC_PROTOCOL;            // switch protocol\r
+                                    irmp_param.complete_len = irmp_bit;                     // patch length: 16 or 17\r
+                                    irmp_tmp_address = last_irmp_address;                   // address is last address\r
+                                    irmp_tmp_command = last_irmp_command;                   // command is last command\r
+                                    irmp_flags |= IRMP_FLAG_REPETITION;\r
+                                    key_repetition_len = 0;\r
+                                }\r
+                                else\r
+                                {\r
+#ifdef ANALYZE\r
+                                    ANALYZE_PRINTF ("ignoring NEC repetition frame: timeout occured, key_repetition_len = %d > %d\n",\r
+                                                    key_repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX);\r
+#endif // ANALYZE\r
+                                    irmp_ir_detected = FALSE;\r
+                                }\r
+                            }\r
+#endif // IRMP_SUPPORT_NEC_PROTOCOL == 1\r
 #if IRMP_SUPPORT_JVC_PROTOCOL == 1\r
                             else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17))      // it was a JVC stop bit\r
                             {\r