]> cloudbase.mooo.com Git - irmp.git/blob - irmp.c
libopencm3: Add IRMP_LOGGING
[irmp.git] / irmp.c
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irmp.c - infrared multi-protocol decoder, supports several remote control protocols
3 *
4 * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de
5 *
6 * $Id: irmp.c,v 1.192 2017/02/17 09:13:06 fm Exp $
7 *
8 * Supported AVR mikrocontrollers:
9 *
10 * ATtiny87, ATtiny167
11 * ATtiny45, ATtiny85
12 * ATtiny44, ATtiny84
13 * ATmega8, ATmega16, ATmega32
14 * ATmega162
15 * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284, ATmega1284P
16 * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *---------------------------------------------------------------------------------------------------------------------------------------------------
23 */
24
25 #include "irmp.h"
26
27 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRMP_SUPPORT_NOKIA_PROTOCOL == 1 || IRMP_SUPPORT_IR60_PROTOCOL == 1
28 # define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 1
29 #else
30 # define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 0
31 #endif
32
33 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 || IRMP_SUPPORT_RUWIDO_PROTOCOL == 1
34 # define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 1
35 #else
36 # define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 0
37 #endif
38
39 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || \
40 IRMP_SUPPORT_S100_PROTOCOL == 1 || \
41 IRMP_SUPPORT_RC6_PROTOCOL == 1 || \
42 IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 || \
43 IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 || \
44 IRMP_SUPPORT_IR60_PROTOCOL == 1 || \
45 IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1 || \
46 IRMP_SUPPORT_MERLIN_PROTOCOL == 1 || \
47 IRMP_SUPPORT_ORTEK_PROTOCOL == 1
48 # define IRMP_SUPPORT_MANCHESTER 1
49 #else
50 # define IRMP_SUPPORT_MANCHESTER 0
51 #endif
52
53 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1
54 # define IRMP_SUPPORT_SERIAL 1
55 #else
56 # define IRMP_SUPPORT_SERIAL 0
57 #endif
58
59 #define IRMP_KEY_REPETITION_LEN (uint_fast16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec
60
61 #define MIN_TOLERANCE_00 1.0 // -0%
62 #define MAX_TOLERANCE_00 1.0 // +0%
63
64 #define MIN_TOLERANCE_02 0.98 // -2%
65 #define MAX_TOLERANCE_02 1.02 // +2%
66
67 #define MIN_TOLERANCE_03 0.97 // -3%
68 #define MAX_TOLERANCE_03 1.03 // +3%
69
70 #define MIN_TOLERANCE_05 0.95 // -5%
71 #define MAX_TOLERANCE_05 1.05 // +5%
72
73 #define MIN_TOLERANCE_10 0.9 // -10%
74 #define MAX_TOLERANCE_10 1.1 // +10%
75
76 #define MIN_TOLERANCE_15 0.85 // -15%
77 #define MAX_TOLERANCE_15 1.15 // +15%
78
79 #define MIN_TOLERANCE_20 0.8 // -20%
80 #define MAX_TOLERANCE_20 1.2 // +20%
81
82 #define MIN_TOLERANCE_30 0.7 // -30%
83 #define MAX_TOLERANCE_30 1.3 // +30%
84
85 #define MIN_TOLERANCE_40 0.6 // -40%
86 #define MAX_TOLERANCE_40 1.4 // +40%
87
88 #define MIN_TOLERANCE_50 0.5 // -50%
89 #define MAX_TOLERANCE_50 1.5 // +50%
90
91 #define MIN_TOLERANCE_60 0.4 // -60%
92 #define MAX_TOLERANCE_60 1.6 // +60%
93
94 #define MIN_TOLERANCE_70 0.3 // -70%
95 #define MAX_TOLERANCE_70 1.7 // +70%
96
97 #define SIRCS_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
98 #define SIRCS_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
99 #define SIRCS_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
100 #if IRMP_SUPPORT_NETBOX_PROTOCOL // only 5% to avoid conflict with NETBOX:
101 # define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5))
102 #else // only 5% + 1 to avoid conflict with RC6:
103 # define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
104 #endif
105 #define SIRCS_1_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
106 #define SIRCS_1_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
107 #define SIRCS_0_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
108 #define SIRCS_0_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
109 #define SIRCS_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
110 #define SIRCS_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
111
112 #define NEC_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
113 #define NEC_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
114 #define NEC_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
115 #define NEC_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
116 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
117 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
118 #define NEC_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
119 #define NEC_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
120 #define NEC_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
121 #define NEC_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
122 #define NEC_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
123 #define NEC_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
124 // autodetect nec repetition frame within 50 msec:
125 // NEC seems to send the first repetition frame after 40ms, further repetition frames after 100 ms
126 #if 0
127 #define NEC_FRAME_REPEAT_PAUSE_LEN_MAX (uint_fast16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)
128 #else
129 #define NEC_FRAME_REPEAT_PAUSE_LEN_MAX (uint_fast16_t)(F_INTERRUPTS * 100.0e-3 * MAX_TOLERANCE_20 + 0.5)
130 #endif
131
132 #define SAMSUNG_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
133 #define SAMSUNG_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
134 #define SAMSUNG_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
135 #define SAMSUNG_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
136 #define SAMSUNG_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
137 #define SAMSUNG_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
138 #define SAMSUNG_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
139 #define SAMSUNG_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
140 #define SAMSUNG_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
141 #define SAMSUNG_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
142
143 #define SAMSUNGAH_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
144 #define SAMSUNGAH_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
145 #define SAMSUNGAH_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
146 #define SAMSUNGAH_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
147 #define SAMSUNGAH_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
148 #define SAMSUNGAH_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
149 #define SAMSUNGAH_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
150 #define SAMSUNGAH_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
151 #define SAMSUNGAH_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
152 #define SAMSUNGAH_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SAMSUNGAH_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
153
154 #define MATSUSHITA_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
155 #define MATSUSHITA_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
156 #define MATSUSHITA_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
157 #define MATSUSHITA_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
158 #define MATSUSHITA_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
159 #define MATSUSHITA_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
160 #define MATSUSHITA_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
161 #define MATSUSHITA_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
162 #define MATSUSHITA_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
163 #define MATSUSHITA_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
164
165 #define KASEIKYO_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
166 #define KASEIKYO_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
167 #define KASEIKYO_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
168 #define KASEIKYO_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
169 #define KASEIKYO_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
170 #define KASEIKYO_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
171 #define KASEIKYO_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
172 #define KASEIKYO_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
173 #define KASEIKYO_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
174 #define KASEIKYO_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
175
176 #define MITSU_HEAVY_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
177 #define MITSU_HEAVY_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
178 #define MITSU_HEAVY_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
179 #define MITSU_HEAVY_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
180 #define MITSU_HEAVY_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
181 #define MITSU_HEAVY_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
182 #define MITSU_HEAVY_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
183 #define MITSU_HEAVY_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
184 #define MITSU_HEAVY_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
185 #define MITSU_HEAVY_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
186
187 #define VINCENT_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * VINCENT_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
188 #define VINCENT_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * VINCENT_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
189 #define VINCENT_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * VINCENT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
190 #define VINCENT_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * VINCENT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
191 #define VINCENT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * VINCENT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
192 #define VINCENT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * VINCENT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
193 #define VINCENT_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * VINCENT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
194 #define VINCENT_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * VINCENT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
195 #define VINCENT_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * VINCENT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
196 #define VINCENT_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * VINCENT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
197
198 #define PANASONIC_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
199 #define PANASONIC_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
200 #define PANASONIC_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
201 #define PANASONIC_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
202 #define PANASONIC_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
203 #define PANASONIC_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
204 #define PANASONIC_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
205 #define PANASONIC_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
206 #define PANASONIC_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
207 #define PANASONIC_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
208
209 #define RECS80_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
210 #define RECS80_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
211 #define RECS80_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
212 #define RECS80_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
213 #define RECS80_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
214 #define RECS80_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
215 #define RECS80_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
216 #define RECS80_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
217 #define RECS80_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
218 #define RECS80_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
219
220
221 #if IRMP_SUPPORT_BOSE_PROTOCOL == 1 // BOSE conflicts with RC5, so keep tolerance for RC5 minimal here:
222 #define RC5_START_BIT_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
223 #define RC5_START_BIT_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
224 #else
225 #define RC5_START_BIT_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
226 #define RC5_START_BIT_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
227 #endif
228
229 #define RC5_BIT_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
230 #define RC5_BIT_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
231
232 #if IRMP_SUPPORT_BOSE_PROTOCOL == 1 // BOSE conflicts with S100, so keep tolerance for S100 minimal here:
233 #define S100_START_BIT_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * S100_BIT_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
234 #define S100_START_BIT_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * S100_BIT_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
235 #else
236 #define S100_START_BIT_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * S100_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
237 #define S100_START_BIT_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * S100_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
238 #endif
239
240 #define S100_BIT_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * S100_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
241 #define S100_BIT_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * S100_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
242
243 #define DENON_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
244 #define DENON_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
245 #define DENON_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
246 #define DENON_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
247 // RUWIDO (see t-home-mediareceiver-15kHz.txt) conflicts here with DENON
248 #define DENON_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
249 #define DENON_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
250 #define DENON_AUTO_REPETITION_PAUSE_LEN ((uint_fast16_t)(F_INTERRUPTS * DENON_AUTO_REPETITION_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
251
252 #define THOMSON_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
253 #define THOMSON_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
254 #define THOMSON_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
255 #define THOMSON_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
256 #define THOMSON_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
257 #define THOMSON_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
258
259 #define RC6_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
260 #define RC6_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
261 #define RC6_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
262 #define RC6_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
263 #define RC6_TOGGLE_BIT_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
264 #define RC6_TOGGLE_BIT_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
265 #define RC6_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
266 #define RC6_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_60 + 0.5) + 1) // pulses: 300 - 800
267 #define RC6_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
268 #define RC6_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1) // pauses: 300 - 600
269
270 #define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
271 #define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
272 #define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
273 #define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
274 #define RECS80EXT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
275 #define RECS80EXT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
276 #define RECS80EXT_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
277 #define RECS80EXT_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
278 #define RECS80EXT_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
279 #define RECS80EXT_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
280
281 #define NUBERT_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
282 #define NUBERT_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
283 #define NUBERT_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
284 #define NUBERT_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
285 #define NUBERT_1_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
286 #define NUBERT_1_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
287 #define NUBERT_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
288 #define NUBERT_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
289 #define NUBERT_0_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
290 #define NUBERT_0_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
291 #define NUBERT_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
292 #define NUBERT_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
293
294 #define FAN_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FAN_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
295 #define FAN_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FAN_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
296 #define FAN_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FAN_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
297 #define FAN_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FAN_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
298 #define FAN_1_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FAN_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
299 #define FAN_1_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FAN_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
300 #define FAN_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FAN_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
301 #define FAN_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FAN_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
302 #define FAN_0_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FAN_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
303 #define FAN_0_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FAN_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
304 #define FAN_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FAN_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
305 #define FAN_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FAN_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
306
307 #define SPEAKER_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
308 #define SPEAKER_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
309 #define SPEAKER_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
310 #define SPEAKER_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
311 #define SPEAKER_1_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
312 #define SPEAKER_1_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
313 #define SPEAKER_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
314 #define SPEAKER_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
315 #define SPEAKER_0_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
316 #define SPEAKER_0_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
317 #define SPEAKER_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
318 #define SPEAKER_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SPEAKER_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
319
320 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
321 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
322 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
323 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
324 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
325 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
326 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
327 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
328 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
329 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
330 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
331 #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
332 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
333 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
334 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
335 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
336 #define BANG_OLUFSEN_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
337 #define BANG_OLUFSEN_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
338 #define BANG_OLUFSEN_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
339 #define BANG_OLUFSEN_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
340 #define BANG_OLUFSEN_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
341 #define BANG_OLUFSEN_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
342 #define BANG_OLUFSEN_R_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
343 #define BANG_OLUFSEN_R_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
344 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
345 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
346
347 #define IR60_TIMEOUT_LEN ((uint_fast8_t)(F_INTERRUPTS * IR60_TIMEOUT_TIME * 0.5))
348 #define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
349 #define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
350 #define GRUNDIG_NOKIA_IR60_BIT_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
351 #define GRUNDIG_NOKIA_IR60_BIT_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
352 #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) + 1)
353 #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
354
355 #define SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
356 #define SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
357 #define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
358 #define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
359 #define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
360 #define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
361 #define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
362 #define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
363
364 #define FDC_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) // 5%: avoid conflict with NETBOX
365 #define FDC_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MAX_TOLERANCE_05 + 0.5))
366 #define FDC_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
367 #define FDC_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5))
368 #define FDC_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
369 #define FDC_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
370 #define FDC_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
371 #define FDC_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
372 #if 0
373 #define FDC_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) // could be negative: 255
374 #else
375 #define FDC_0_PAUSE_LEN_MIN (1) // simply use 1
376 #endif
377 #define FDC_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
378
379 #define RCCAR_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
380 #define RCCAR_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
381 #define RCCAR_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
382 #define RCCAR_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
383 #define RCCAR_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
384 #define RCCAR_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
385 #define RCCAR_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
386 #define RCCAR_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
387 #define RCCAR_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
388 #define RCCAR_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
389
390 #define JVC_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
391 #define JVC_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
392 #define JVC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * (JVC_FRAME_REPEAT_PAUSE_TIME - IRMP_TIMEOUT_TIME) * MIN_TOLERANCE_40 + 0.5) - 1) // HACK!
393 #define JVC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * (JVC_FRAME_REPEAT_PAUSE_TIME - IRMP_TIMEOUT_TIME) * MAX_TOLERANCE_70 + 0.5) - 1) // HACK!
394 #define JVC_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * JVC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
395 #define JVC_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * JVC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
396 #define JVC_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
397 #define JVC_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
398 #define JVC_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
399 #define JVC_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
400 // autodetect JVC repetition frame within 50 msec:
401 #define JVC_FRAME_REPEAT_PAUSE_LEN_MAX (uint_fast16_t)(F_INTERRUPTS * JVC_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)
402
403 #define NIKON_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
404 #define NIKON_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
405 #define NIKON_START_BIT_PAUSE_LEN_MIN ((uint_fast16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
406 #define NIKON_START_BIT_PAUSE_LEN_MAX ((uint_fast16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
407 #define NIKON_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
408 #define NIKON_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
409 #define NIKON_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NIKON_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
410 #define NIKON_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NIKON_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
411 #define NIKON_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
412 #define NIKON_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
413 #define NIKON_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
414 #define NIKON_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
415 #define NIKON_FRAME_REPEAT_PAUSE_LEN_MAX (uint_fast16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)
416
417 #define KATHREIN_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
418 #define KATHREIN_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
419 #define KATHREIN_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
420 #define KATHREIN_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
421 #define KATHREIN_1_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
422 #define KATHREIN_1_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
423 #define KATHREIN_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
424 #define KATHREIN_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
425 #define KATHREIN_0_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
426 #define KATHREIN_0_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
427 #define KATHREIN_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
428 #define KATHREIN_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
429 #define KATHREIN_SYNC_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_SYNC_BIT_PAUSE_LEN_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
430 #define KATHREIN_SYNC_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KATHREIN_SYNC_BIT_PAUSE_LEN_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
431
432 #define NETBOX_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NETBOX_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
433 #define NETBOX_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NETBOX_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
434 #define NETBOX_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * NETBOX_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
435 #define NETBOX_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * NETBOX_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
436 #define NETBOX_PULSE_LEN ((uint_fast8_t)(F_INTERRUPTS * NETBOX_PULSE_TIME))
437 #define NETBOX_PAUSE_LEN ((uint_fast8_t)(F_INTERRUPTS * NETBOX_PAUSE_TIME))
438 #define NETBOX_PULSE_REST_LEN ((uint_fast8_t)(F_INTERRUPTS * NETBOX_PULSE_TIME / 4))
439 #define NETBOX_PAUSE_REST_LEN ((uint_fast8_t)(F_INTERRUPTS * NETBOX_PAUSE_TIME / 4))
440
441 #define LEGO_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
442 #define LEGO_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
443 #define LEGO_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
444 #define LEGO_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
445 #define LEGO_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * LEGO_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
446 #define LEGO_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * LEGO_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
447 #define LEGO_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
448 #define LEGO_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
449 #define LEGO_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
450 #define LEGO_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
451
452 #define BOSE_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BOSE_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
453 #define BOSE_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BOSE_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
454 #define BOSE_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BOSE_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
455 #define BOSE_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BOSE_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
456 #define BOSE_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BOSE_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
457 #define BOSE_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BOSE_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
458 #define BOSE_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BOSE_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
459 #define BOSE_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BOSE_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
460 #define BOSE_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * BOSE_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
461 #define BOSE_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * BOSE_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
462 #define BOSE_FRAME_REPEAT_PAUSE_LEN_MAX (uint_fast16_t)(F_INTERRUPTS * 100.0e-3 * MAX_TOLERANCE_20 + 0.5)
463
464 #define A1TVBOX_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
465 #define A1TVBOX_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
466 #define A1TVBOX_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
467 #define A1TVBOX_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
468 #define A1TVBOX_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * A1TVBOX_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
469 #define A1TVBOX_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * A1TVBOX_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
470 #define A1TVBOX_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * A1TVBOX_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
471 #define A1TVBOX_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * A1TVBOX_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
472
473 #define MERLIN_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MERLIN_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
474 #define MERLIN_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MERLIN_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
475 #define MERLIN_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MERLIN_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
476 #define MERLIN_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MERLIN_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
477 #define MERLIN_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MERLIN_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
478 #define MERLIN_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MERLIN_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
479 #define MERLIN_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MERLIN_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
480 #define MERLIN_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MERLIN_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
481
482 #define ORTEK_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ORTEK_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
483 #define ORTEK_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ORTEK_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
484 #define ORTEK_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ORTEK_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
485 #define ORTEK_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ORTEK_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
486 #define ORTEK_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ORTEK_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
487 #define ORTEK_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ORTEK_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
488 #define ORTEK_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ORTEK_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
489 #define ORTEK_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ORTEK_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
490
491 #define TELEFUNKEN_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * TELEFUNKEN_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
492 #define TELEFUNKEN_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * TELEFUNKEN_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
493 #define TELEFUNKEN_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * (TELEFUNKEN_START_BIT_PAUSE_TIME) * MIN_TOLERANCE_10 + 0.5) - 1)
494 #define TELEFUNKEN_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * (TELEFUNKEN_START_BIT_PAUSE_TIME) * MAX_TOLERANCE_10 + 0.5) - 1)
495 #define TELEFUNKEN_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * TELEFUNKEN_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
496 #define TELEFUNKEN_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * TELEFUNKEN_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
497 #define TELEFUNKEN_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * TELEFUNKEN_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
498 #define TELEFUNKEN_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * TELEFUNKEN_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
499 #define TELEFUNKEN_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * TELEFUNKEN_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
500 #define TELEFUNKEN_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * TELEFUNKEN_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
501 // autodetect TELEFUNKEN repetition frame within 50 msec:
502 // #define TELEFUNKEN_FRAME_REPEAT_PAUSE_LEN_MAX (uint_fast16_t)(F_INTERRUPTS * TELEFUNKEN_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)
503
504 #define ROOMBA_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
505 #define ROOMBA_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
506 #define ROOMBA_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
507 #define ROOMBA_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
508 #define ROOMBA_1_PAUSE_LEN_EXACT ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_1_PAUSE_TIME + 0.5))
509 #define ROOMBA_1_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
510 #define ROOMBA_1_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
511 #define ROOMBA_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
512 #define ROOMBA_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
513 #define ROOMBA_0_PAUSE_LEN ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_0_PAUSE_TIME))
514 #define ROOMBA_0_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
515 #define ROOMBA_0_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
516 #define ROOMBA_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
517 #define ROOMBA_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ROOMBA_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
518
519 #define RCMM32_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCMM32_START_BIT_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
520 #define RCMM32_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCMM32_START_BIT_PULSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
521 #define RCMM32_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCMM32_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
522 #define RCMM32_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCMM32_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
523 #define RCMM32_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCMM32_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
524 #define RCMM32_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCMM32_PULSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
525 #define RCMM32_BIT_00_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCMM32_00_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
526 #define RCMM32_BIT_00_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCMM32_00_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
527 #define RCMM32_BIT_01_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCMM32_01_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
528 #define RCMM32_BIT_01_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCMM32_01_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
529 #define RCMM32_BIT_10_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCMM32_10_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
530 #define RCMM32_BIT_10_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCMM32_10_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
531 #define RCMM32_BIT_11_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RCMM32_11_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
532 #define RCMM32_BIT_11_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RCMM32_11_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
533
534 #define PENTAX_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PENTAX_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
535 #define PENTAX_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PENTAX_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
536 #define PENTAX_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PENTAX_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
537 #define PENTAX_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PENTAX_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
538 #define PENTAX_1_PAUSE_LEN_EXACT ((uint_fast8_t)(F_INTERRUPTS * PENTAX_1_PAUSE_TIME + 0.5))
539 #define PENTAX_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PENTAX_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
540 #define PENTAX_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PENTAX_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
541 #define PENTAX_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PENTAX_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
542 #define PENTAX_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PENTAX_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
543 #define PENTAX_0_PAUSE_LEN ((uint_fast8_t)(F_INTERRUPTS * PENTAX_0_PAUSE_TIME))
544 #define PENTAX_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PENTAX_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
545 #define PENTAX_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PENTAX_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
546 #define PENTAX_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PENTAX_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
547 #define PENTAX_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PENTAX_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
548
549 #define ACP24_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ACP24_START_BIT_PULSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)
550 #define ACP24_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ACP24_START_BIT_PULSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)
551 #define ACP24_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ACP24_START_BIT_PAUSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)
552 #define ACP24_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ACP24_START_BIT_PAUSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)
553 #define ACP24_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ACP24_PULSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)
554 #define ACP24_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ACP24_PULSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)
555 #define ACP24_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ACP24_1_PAUSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)
556 #define ACP24_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ACP24_1_PAUSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)
557 #define ACP24_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * ACP24_0_PAUSE_TIME * MIN_TOLERANCE_15 + 0.5) - 1)
558 #define ACP24_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * ACP24_0_PAUSE_TIME * MAX_TOLERANCE_15 + 0.5) + 1)
559
560 #define RADIO1_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RADIO1_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
561 #define RADIO1_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RADIO1_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
562 #define RADIO1_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RADIO1_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
563 #define RADIO1_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RADIO1_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
564 #define RADIO1_1_PAUSE_LEN_EXACT ((uint_fast8_t)(F_INTERRUPTS * RADIO1_1_PAUSE_TIME + 0.5))
565 #define RADIO1_1_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RADIO1_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
566 #define RADIO1_1_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RADIO1_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
567 #define RADIO1_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RADIO1_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
568 #define RADIO1_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RADIO1_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
569 #define RADIO1_0_PAUSE_LEN ((uint_fast8_t)(F_INTERRUPTS * RADIO1_0_PAUSE_TIME))
570 #define RADIO1_0_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RADIO1_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
571 #define RADIO1_0_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RADIO1_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
572 #define RADIO1_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RADIO1_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
573 #define RADIO1_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RADIO1_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
574
575 #define AUTO_FRAME_REPETITION_LEN (uint_fast16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint_fast16_t!
576
577 #ifdef ANALYZE
578 # define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } }
579 # define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } }
580 # define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } }
581 # define ANALYZE_ONLY_NORMAL_PRINTF(...) { if (! silent && !verbose) { printf (__VA_ARGS__); } }
582 # define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } }
583 static int silent;
584 static int time_counter;
585 static int verbose;
586
587 /******************************* not every PIC compiler knows variadic macros :-(
588 #else
589 # define ANALYZE_PUTCHAR(a)
590 # define ANALYZE_ONLY_NORMAL_PUTCHAR(a)
591 # define ANALYZE_PRINTF(...)
592 # define ANALYZE_ONLY_NORMAL_PRINTF(...)
593 # endif
594 # define ANALYZE_NEWLINE()
595 *********************************/
596 #endif
597
598 #if IRMP_USE_CALLBACK == 1
599 static void (*irmp_callback_ptr) (uint_fast8_t);
600 #endif // IRMP_USE_CALLBACK == 1
601
602 #define PARITY_CHECK_OK 1
603 #define PARITY_CHECK_FAILED 0
604
605 /*---------------------------------------------------------------------------------------------------------------------------------------------------
606 * Protocol names
607 *---------------------------------------------------------------------------------------------------------------------------------------------------
608 */
609 #if defined(UNIX_OR_WINDOWS) || IRMP_PROTOCOL_NAMES == 1
610 static const char proto_unknown[] PROGMEM = "UNKNOWN";
611 static const char proto_sircs[] PROGMEM = "SIRCS";
612 static const char proto_nec[] PROGMEM = "NEC";
613 static const char proto_samsung[] PROGMEM = "SAMSUNG";
614 static const char proto_matsushita[] PROGMEM = "MATSUSH";
615 static const char proto_kaseikyo[] PROGMEM = "KASEIKYO";
616 static const char proto_recs80[] PROGMEM = "RECS80";
617 static const char proto_rc5[] PROGMEM = "RC5";
618 static const char proto_denon[] PROGMEM = "DENON";
619 static const char proto_rc6[] PROGMEM = "RC6";
620 static const char proto_samsung32[] PROGMEM = "SAMSG32";
621 static const char proto_apple[] PROGMEM = "APPLE";
622 static const char proto_recs80ext[] PROGMEM = "RECS80EX";
623 static const char proto_nubert[] PROGMEM = "NUBERT";
624 static const char proto_bang_olufsen[] PROGMEM = "BANG OLU";
625 static const char proto_grundig[] PROGMEM = "GRUNDIG";
626 static const char proto_nokia[] PROGMEM = "NOKIA";
627 static const char proto_siemens[] PROGMEM = "SIEMENS";
628 static const char proto_fdc[] PROGMEM = "FDC";
629 static const char proto_rccar[] PROGMEM = "RCCAR";
630 static const char proto_jvc[] PROGMEM = "JVC";
631 static const char proto_rc6a[] PROGMEM = "RC6A";
632 static const char proto_nikon[] PROGMEM = "NIKON";
633 static const char proto_ruwido[] PROGMEM = "RUWIDO";
634 static const char proto_ir60[] PROGMEM = "IR60";
635 static const char proto_kathrein[] PROGMEM = "KATHREIN";
636 static const char proto_netbox[] PROGMEM = "NETBOX";
637 static const char proto_nec16[] PROGMEM = "NEC16";
638 static const char proto_nec42[] PROGMEM = "NEC42";
639 static const char proto_lego[] PROGMEM = "LEGO";
640 static const char proto_thomson[] PROGMEM = "THOMSON";
641 static const char proto_bose[] PROGMEM = "BOSE";
642 static const char proto_a1tvbox[] PROGMEM = "A1TVBOX";
643 static const char proto_ortek[] PROGMEM = "ORTEK";
644 static const char proto_telefunken[] PROGMEM = "TELEFUNKEN";
645 static const char proto_roomba[] PROGMEM = "ROOMBA";
646 static const char proto_rcmm32[] PROGMEM = "RCMM32";
647 static const char proto_rcmm24[] PROGMEM = "RCMM24";
648 static const char proto_rcmm12[] PROGMEM = "RCMM12";
649 static const char proto_speaker[] PROGMEM = "SPEAKER";
650 static const char proto_lgair[] PROGMEM = "LGAIR";
651 static const char proto_samsung48[] PROGMEM = "SAMSG48";
652 static const char proto_merlin[] PROGMEM = "MERLIN";
653 static const char proto_pentax[] PROGMEM = "PENTAX";
654 static const char proto_fan[] PROGMEM = "FAN";
655 static const char proto_s100[] PROGMEM = "S100";
656 static const char proto_acp24[] PROGMEM = "ACP24";
657 static const char proto_technics[] PROGMEM = "TECHNICS";
658 static const char proto_panasonic[] PROGMEM = "PANASONIC";
659 static const char proto_mitsu_heavy[] PROGMEM = "MITSU_HEAVY";
660 static const char proto_vincent[] PROGMEM = "VINCENT";
661 static const char proto_samsungah[] PROGMEM = "SAMSUNGAH";
662
663 static const char proto_radio1[] PROGMEM = "RADIO1";
664
665 const char * const
666 irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM =
667 {
668 proto_unknown,
669 proto_sircs,
670 proto_nec,
671 proto_samsung,
672 proto_matsushita,
673 proto_kaseikyo,
674 proto_recs80,
675 proto_rc5,
676 proto_denon,
677 proto_rc6,
678 proto_samsung32,
679 proto_apple,
680 proto_recs80ext,
681 proto_nubert,
682 proto_bang_olufsen,
683 proto_grundig,
684 proto_nokia,
685 proto_siemens,
686 proto_fdc,
687 proto_rccar,
688 proto_jvc,
689 proto_rc6a,
690 proto_nikon,
691 proto_ruwido,
692 proto_ir60,
693 proto_kathrein,
694 proto_netbox,
695 proto_nec16,
696 proto_nec42,
697 proto_lego,
698 proto_thomson,
699 proto_bose,
700 proto_a1tvbox,
701 proto_ortek,
702 proto_telefunken,
703 proto_roomba,
704 proto_rcmm32,
705 proto_rcmm24,
706 proto_rcmm12,
707 proto_speaker,
708 proto_lgair,
709 proto_samsung48,
710 proto_merlin,
711 proto_pentax,
712 proto_fan,
713 proto_s100,
714 proto_acp24,
715 proto_technics,
716 proto_panasonic,
717 proto_mitsu_heavy,
718 proto_vincent,
719 proto_samsungah,
720 proto_radio1
721 };
722
723 #endif
724
725 /*---------------------------------------------------------------------------------------------------------------------------------------------------
726 * Logging
727 *---------------------------------------------------------------------------------------------------------------------------------------------------
728 */
729 #if IRMP_LOGGING == 1 // logging via UART
730
731 #if defined(ARM_STM32F4XX)
732 # define STM32_GPIO_CLOCK RCC_AHB1Periph_GPIOA // UART2 on PA2
733 # define STM32_UART_CLOCK RCC_APB1Periph_USART2
734 # define STM32_GPIO_PORT GPIOA
735 # define STM32_GPIO_PIN GPIO_Pin_2
736 # define STM32_GPIO_SOURCE GPIO_PinSource2
737 # define STM32_UART_AF GPIO_AF_USART2
738 # define STM32_UART_COM USART2
739 # define STM32_UART_BAUD 115200 // 115200 Baud
740 # include "stm32f4xx_usart.h"
741 #elif defined(ARM_STM32F10X)
742 # define STM32_UART_COM USART3 // UART3 on PB10
743 #elif defined(LIBOPENCM3) //
744 # include <libopencm3/stm32/usart.h>
745 # define STM32_UART_COM USART2 // UART2 on PA2
746 # define STM32_UART_GPIO_PORT GPIOA
747 # define STM32_UART_GPIO_PIN GPIO2
748 # define STM32_UART_COM_RCC RCC_USART2
749 # define STM32_UART_GPIO_RCC RCC_GPIOA
750 # define STM32_UART_BAUD 115200 // 115200 Baud
751 #elif defined(ARDUINO) // Arduino Serial implementation
752 # if defined(USB_SERIAL)
753 # include "usb_serial.h"
754 # else
755 # error USB_SERIAL not defined in ARDUINO Environment
756 # endif
757 #else
758 # if IRMP_EXT_LOGGING == 1 // use external logging
759 # include "irmpextlog.h"
760 # else // normal UART log (IRMP_EXT_LOGGING == 0)
761 # define BAUD 9600L
762 # ifndef UNIX_OR_WINDOWS
763 # include <util/setbaud.h>
764 # endif
765
766 #ifdef UBRR0H
767
768 #define UART0_UBRRH UBRR0H
769 #define UART0_UBRRL UBRR0L
770 #define UART0_UCSRA UCSR0A
771 #define UART0_UCSRB UCSR0B
772 #define UART0_UCSRC UCSR0C
773 #define UART0_UDRE_BIT_VALUE (1<<UDRE0)
774 #define UART0_UCSZ1_BIT_VALUE (1<<UCSZ01)
775 #define UART0_UCSZ0_BIT_VALUE (1<<UCSZ00)
776 #ifdef URSEL0
777 #define UART0_URSEL_BIT_VALUE (1<<URSEL0)
778 #else
779 #define UART0_URSEL_BIT_VALUE (0)
780 #endif
781 #define UART0_TXEN_BIT_VALUE (1<<TXEN0)
782 #define UART0_UDR UDR0
783 #define UART0_U2X U2X0
784
785 #else
786
787 #define UART0_UBRRH UBRRH
788 #define UART0_UBRRL UBRRL
789 #define UART0_UCSRA UCSRA
790 #define UART0_UCSRB UCSRB
791 #define UART0_UCSRC UCSRC
792 #define UART0_UDRE_BIT_VALUE (1<<UDRE)
793 #define UART0_UCSZ1_BIT_VALUE (1<<UCSZ1)
794 #define UART0_UCSZ0_BIT_VALUE (1<<UCSZ0)
795 #ifdef URSEL
796 #define UART0_URSEL_BIT_VALUE (1<<URSEL)
797 #else
798 #define UART0_URSEL_BIT_VALUE (0)
799 #endif
800 #define UART0_TXEN_BIT_VALUE (1<<TXEN)
801 #define UART0_UDR UDR
802 #define UART0_U2X U2X
803
804 #endif //UBRR0H
805 #endif //IRMP_EXT_LOGGING
806 #endif //ARM_STM32F4XX
807
808 /*---------------------------------------------------------------------------------------------------------------------------------------------------
809 * Initialize UART
810 * @details Initializes UART
811 *---------------------------------------------------------------------------------------------------------------------------------------------------
812 */
813 void
814 irmp_uart_init (void)
815 {
816 #ifndef UNIX_OR_WINDOWS
817 #if defined(ARM_STM32F4XX)
818 GPIO_InitTypeDef GPIO_InitStructure;
819 USART_InitTypeDef USART_InitStructure;
820
821 // Clock enable vom TX Pin
822 RCC_AHB1PeriphClockCmd(STM32_GPIO_CLOCK, ENABLE);
823
824 // Clock enable der UART
825 RCC_APB1PeriphClockCmd(STM32_UART_CLOCK, ENABLE);
826
827 // UART Alternative-Funktion mit dem IO-Pin verbinden
828 GPIO_PinAFConfig(STM32_GPIO_PORT,STM32_GPIO_SOURCE,STM32_UART_AF);
829
830 // UART als Alternative-Funktion mit PushPull
831 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
832 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
833 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
834 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
835
836 // TX-Pin
837 GPIO_InitStructure.GPIO_Pin = STM32_GPIO_PIN;
838 GPIO_Init(STM32_GPIO_PORT, &GPIO_InitStructure);
839
840 // Oversampling
841 USART_OverSampling8Cmd(STM32_UART_COM, ENABLE);
842
843 // init baud rate, 8 data bits, 1 stop bit, no parity, no RTS+CTS
844 USART_InitStructure.USART_BaudRate = STM32_UART_BAUD;
845 USART_InitStructure.USART_WordLength = USART_WordLength_8b;
846 USART_InitStructure.USART_StopBits = USART_StopBits_1;
847 USART_InitStructure.USART_Parity = USART_Parity_No;
848 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
849 USART_InitStructure.USART_Mode = USART_Mode_Tx;
850 USART_Init(STM32_UART_COM, &USART_InitStructure);
851
852 // UART enable
853 USART_Cmd(STM32_UART_COM, ENABLE);
854
855 #elif defined(ARM_STM32F10X)
856 GPIO_InitTypeDef GPIO_InitStructure;
857 USART_InitTypeDef USART_InitStructure;
858
859 // Clock enable vom TX Pin
860 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); // UART3 an PB10
861
862 // Clock enable der UART
863 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
864
865 // UART als Alternative-Funktion mit PushPull
866 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
867 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
868
869 // TX-Pin
870 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
871 GPIO_Init(GPIOB, &GPIO_InitStructure);
872
873 // Oversampling
874 USART_OverSampling8Cmd(STM32_UART_COM, ENABLE);
875
876 // init baud rate, 8 data bits, 1 stop bit, no parity, no RTS+CTS
877 USART_InitStructure.USART_BaudRate = 115200;
878 USART_InitStructure.USART_WordLength = USART_WordLength_8b;
879 USART_InitStructure.USART_StopBits = USART_StopBits_1;
880 USART_InitStructure.USART_Parity = USART_Parity_No;
881 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
882 USART_InitStructure.USART_Mode = USART_Mode_Tx;
883 USART_Init(STM32_UART_COM, &USART_InitStructure);
884
885 // UART enable
886 USART_Cmd(STM32_UART_COM, ENABLE);
887
888 #elif defined(LIBOPENCM3)
889 rcc_periph_clock_enable(STM32_UART_COM_RCC);
890 /* Setup GPIO pin for USART TX */
891 rcc_periph_clock_enable(STM32_UART_GPIO_RCC);
892 gpio_set_mode(STM32_UART_GPIO_PORT, GPIO_MODE_OUTPUT_2_MHZ,
893 GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, STM32_UART_GPIO_PIN);
894
895 /* Setup UART parameters. */
896 usart_set_baudrate(STM32_UART_COM, STM32_UART_BAUD);
897 usart_set_databits(STM32_UART_COM, 8);
898 usart_set_stopbits(STM32_UART_COM, USART_STOPBITS_1);
899 usart_set_parity(STM32_UART_COM, USART_PARITY_NONE);
900 usart_set_flow_control(STM32_UART_COM, USART_FLOWCONTROL_NONE);
901 usart_set_mode(STM32_UART_COM, USART_MODE_TX_RX);
902 /* Finally enable the USART. */
903 usart_enable(STM32_UART_COM);
904
905 #elif defined(ARDUINO)
906 // we use the Arduino Serial Imlementation
907 // you have to call Serial.begin(SER_BAUD); in Arduino setup() function
908
909 #elif defined (__AVR_XMEGA__)
910
911 PMIC.CTRL |= PMIC_HILVLEN_bm;
912
913 USARTC1.BAUDCTRLB = 0;
914 USARTC1.BAUDCTRLA = F_CPU / 153600 - 1;
915 USARTC1.CTRLA = USART_RXCINTLVL_HI_gc; // high INT level (receive)
916 USARTC1.CTRLB = USART_TXEN_bm | USART_RXEN_bm; // activated RX and TX
917 USARTC1.CTRLC = USART_CHSIZE_8BIT_gc; // 8 Bit
918 PORTC.DIR |= (1<<7); // TXD is output
919 PORTC.DIR &= ~(1<<6);
920
921 #else
922
923 #if (IRMP_EXT_LOGGING == 0) // use UART
924 UART0_UBRRH = UBRRH_VALUE; // set baud rate
925 UART0_UBRRL = UBRRL_VALUE;
926
927 #if USE_2X
928 UART0_UCSRA |= (1<<UART0_U2X);
929 #else
930 UART0_UCSRA &= ~(1<<UART0_U2X);
931 #endif
932
933 UART0_UCSRC = UART0_UCSZ1_BIT_VALUE | UART0_UCSZ0_BIT_VALUE | UART0_URSEL_BIT_VALUE;
934 UART0_UCSRB |= UART0_TXEN_BIT_VALUE; // enable UART TX
935 #else // other log method
936 initextlog();
937 #endif //IRMP_EXT_LOGGING
938 #endif //ARM_STM32F4XX
939 #endif // UNIX_OR_WINDOWS
940 }
941
942 /*---------------------------------------------------------------------------------------------------------------------------------------------------
943 * Send character
944 * @details Sends character
945 * @param ch character to be transmitted
946 *---------------------------------------------------------------------------------------------------------------------------------------------------
947 */
948 void
949 irmp_uart_putc (unsigned char ch)
950 {
951 #ifndef UNIX_OR_WINDOWS
952 #if defined(ARM_STM32F4XX) || defined(ARM_STM32F10X)
953 // warten bis altes Byte gesendet wurde
954 while (USART_GetFlagStatus(STM32_UART_COM, USART_FLAG_TXE) == RESET)
955 {
956 ;
957 }
958
959 USART_SendData(STM32_UART_COM, ch);
960
961 if (ch == '\n')
962 {
963 while (USART_GetFlagStatus(STM32_UART_COM, USART_FLAG_TXE) == RESET);
964 USART_SendData(STM32_UART_COM, '\r');
965 }
966
967 #elif defined(LIBOPENCM3)
968 if (ch == '\n') {
969 usart_send_blocking(STM32_UART_COM, '\r');
970 }
971 usart_send_blocking(STM32_UART_COM, ch);
972
973 #elif defined(ARDUINO)
974 // we use the Arduino Serial Imlementation
975 usb_serial_putchar(ch);
976
977 #else
978 #if (IRMP_EXT_LOGGING == 0)
979
980 # if defined (__AVR_XMEGA__)
981 while (!(USARTC1.STATUS & USART_DREIF_bm))
982 {
983 ;
984 }
985
986 USARTC1.DATA = ch;
987
988 # else // AVR_MEGA
989 while (!(UART0_UCSRA & UART0_UDRE_BIT_VALUE))
990 {
991 ;
992 }
993
994 UART0_UDR = ch;
995
996 # endif // __AVR_XMEGA__
997
998 #else
999
1000 sendextlog(ch); // use external log
1001
1002 #endif // IRMP_EXT_LOGGING
1003 #endif // ARM_STM32F4XX
1004 #else
1005 fputc (ch, stderr);
1006 #endif // UNIX_OR_WINDOWS
1007 }
1008
1009 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1010 * Log IR signal
1011 *---------------------------------------------------------------------------------------------------------------------------------------------------
1012 */
1013
1014 #define STARTCYCLES 2 // min count of zeros before start of logging
1015 #define ENDBITS 1000 // number of sequenced highbits to detect end
1016 #define DATALEN 700 // log buffer size
1017
1018 static void
1019 irmp_log (uint_fast8_t val)
1020 {
1021 static uint8_t buf[DATALEN]; // logging buffer
1022 static uint_fast16_t buf_idx; // index
1023 static uint_fast8_t startcycles; // current number of start-zeros
1024 static uint_fast16_t cnt; // counts sequenced highbits - to detect end
1025 static uint_fast8_t last_val = 1;
1026
1027 if (! val && (startcycles < STARTCYCLES) && !buf_idx) // prevent that single random zeros init logging
1028 {
1029 startcycles++;
1030 }
1031 else
1032 {
1033 startcycles = 0;
1034
1035 if (! val || buf_idx != 0) // start or continue logging on "0", "1" cannot init logging
1036 {
1037 if (last_val == val)
1038 {
1039 cnt++;
1040
1041 if (val && cnt > ENDBITS) // if high received then look at log-stop condition
1042 { // if stop condition is true, output on uart
1043 uint_fast8_t i8;
1044 uint_fast16_t i;
1045 uint_fast16_t j;
1046 uint_fast8_t v = '1';
1047 uint_fast16_t d;
1048
1049 for (i8 = 0; i8 < STARTCYCLES; i8++)
1050 {
1051 irmp_uart_putc ('0'); // the ignored starting zeros
1052 }
1053
1054 for (i = 0; i < buf_idx; i++)
1055 {
1056 d = buf[i];
1057
1058 if (d == 0xff)
1059 {
1060 i++;
1061 d = buf[i];
1062 i++;
1063 d |= ((uint_fast16_t) buf[i] << 8);
1064 }
1065
1066 for (j = 0; j < d; j++)
1067 {
1068 irmp_uart_putc (v);
1069 }
1070
1071 v = (v == '1') ? '0' : '1';
1072 }
1073
1074 for (i8 = 0; i8 < 20; i8++)
1075 {
1076 irmp_uart_putc ('1');
1077 }
1078
1079 irmp_uart_putc ('\n');
1080 buf_idx = 0;
1081 last_val = 1;
1082 cnt = 0;
1083 }
1084 }
1085 else if (buf_idx < DATALEN - 3)
1086 {
1087 if (cnt >= 0xff)
1088 {
1089 buf[buf_idx++] = 0xff;
1090 buf[buf_idx++] = (cnt & 0xff);
1091 buf[buf_idx] = (cnt >> 8);
1092 }
1093 else
1094 {
1095 buf[buf_idx] = cnt;
1096 }
1097
1098 buf_idx++;
1099 cnt = 1;
1100 last_val = val;
1101 }
1102 }
1103 }
1104 }
1105
1106 #else
1107 #define irmp_log(val)
1108 #endif //IRMP_LOGGING
1109
1110 typedef struct
1111 {
1112 uint_fast8_t protocol; // ir protocol
1113 uint_fast8_t pulse_1_len_min; // minimum length of pulse with bit value 1
1114 uint_fast8_t pulse_1_len_max; // maximum length of pulse with bit value 1
1115 uint_fast8_t pause_1_len_min; // minimum length of pause with bit value 1
1116 uint_fast8_t pause_1_len_max; // maximum length of pause with bit value 1
1117 uint_fast8_t pulse_0_len_min; // minimum length of pulse with bit value 0
1118 uint_fast8_t pulse_0_len_max; // maximum length of pulse with bit value 0
1119 uint_fast8_t pause_0_len_min; // minimum length of pause with bit value 0
1120 uint_fast8_t pause_0_len_max; // maximum length of pause with bit value 0
1121 uint_fast8_t address_offset; // address offset
1122 uint_fast8_t address_end; // end of address
1123 uint_fast8_t command_offset; // command offset
1124 uint_fast8_t command_end; // end of command
1125 uint_fast8_t complete_len; // complete length of frame
1126 uint_fast8_t stop_bit; // flag: frame has stop bit
1127 uint_fast8_t lsb_first; // flag: LSB first
1128 uint_fast8_t flags; // some flags
1129 } IRMP_PARAMETER;
1130
1131 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1132
1133 static const PROGMEM IRMP_PARAMETER sircs_param =
1134 {
1135 IRMP_SIRCS_PROTOCOL, // protocol: ir protocol
1136 SIRCS_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1137 SIRCS_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1138 SIRCS_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1139 SIRCS_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1140 SIRCS_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1141 SIRCS_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1142 SIRCS_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1143 SIRCS_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1144 SIRCS_ADDRESS_OFFSET, // address_offset: address offset
1145 SIRCS_ADDRESS_OFFSET + SIRCS_ADDRESS_LEN, // address_end: end of address
1146 SIRCS_COMMAND_OFFSET, // command_offset: command offset
1147 SIRCS_COMMAND_OFFSET + SIRCS_COMMAND_LEN, // command_end: end of command
1148 SIRCS_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1149 SIRCS_STOP_BIT, // stop_bit: flag: frame has stop bit
1150 SIRCS_LSB, // lsb_first: flag: LSB first
1151 SIRCS_FLAGS // flags: some flags
1152 };
1153
1154 #endif
1155
1156 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
1157
1158 static const PROGMEM IRMP_PARAMETER nec_param =
1159 {
1160 IRMP_NEC_PROTOCOL, // protocol: ir protocol
1161 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1162 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1163 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1164 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1165 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1166 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1167 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1168 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1169 NEC_ADDRESS_OFFSET, // address_offset: address offset
1170 NEC_ADDRESS_OFFSET + NEC_ADDRESS_LEN, // address_end: end of address
1171 NEC_COMMAND_OFFSET, // command_offset: command offset
1172 NEC_COMMAND_OFFSET + NEC_COMMAND_LEN, // command_end: end of command
1173 NEC_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1174 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit
1175 NEC_LSB, // lsb_first: flag: LSB first
1176 NEC_FLAGS // flags: some flags
1177 };
1178
1179 static const PROGMEM IRMP_PARAMETER nec_rep_param =
1180 {
1181 IRMP_NEC_PROTOCOL, // protocol: ir protocol
1182 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1183 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1184 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1185 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1186 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1187 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1188 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1189 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1190 0, // address_offset: address offset
1191 0, // address_end: end of address
1192 0, // command_offset: command offset
1193 0, // command_end: end of command
1194 0, // complete_len: complete length of frame
1195 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit
1196 NEC_LSB, // lsb_first: flag: LSB first
1197 NEC_FLAGS // flags: some flags
1198 };
1199
1200 #endif
1201
1202 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
1203
1204 static const PROGMEM IRMP_PARAMETER nec42_param =
1205 {
1206 IRMP_NEC42_PROTOCOL, // protocol: ir protocol
1207 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1208 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1209 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1210 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1211 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1212 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1213 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1214 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1215 NEC42_ADDRESS_OFFSET, // address_offset: address offset
1216 NEC42_ADDRESS_OFFSET + NEC42_ADDRESS_LEN, // address_end: end of address
1217 NEC42_COMMAND_OFFSET, // command_offset: command offset
1218 NEC42_COMMAND_OFFSET + NEC42_COMMAND_LEN, // command_end: end of command
1219 NEC42_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1220 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit
1221 NEC_LSB, // lsb_first: flag: LSB first
1222 NEC_FLAGS // flags: some flags
1223 };
1224
1225 #endif
1226
1227 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
1228
1229 static const PROGMEM IRMP_PARAMETER lgair_param =
1230 {
1231 IRMP_LGAIR_PROTOCOL, // protocol: ir protocol
1232 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1233 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1234 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1235 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1236 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1237 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1238 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1239 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1240 LGAIR_ADDRESS_OFFSET, // address_offset: address offset
1241 LGAIR_ADDRESS_OFFSET + LGAIR_ADDRESS_LEN, // address_end: end of address
1242 LGAIR_COMMAND_OFFSET, // command_offset: command offset
1243 LGAIR_COMMAND_OFFSET + LGAIR_COMMAND_LEN, // command_end: end of command
1244 LGAIR_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1245 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit
1246 NEC_LSB, // lsb_first: flag: LSB first
1247 NEC_FLAGS // flags: some flags
1248 };
1249
1250 #endif
1251
1252 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1253
1254 static const PROGMEM IRMP_PARAMETER samsung_param =
1255 {
1256 IRMP_SAMSUNG_PROTOCOL, // protocol: ir protocol
1257 SAMSUNG_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1258 SAMSUNG_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1259 SAMSUNG_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1260 SAMSUNG_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1261 SAMSUNG_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1262 SAMSUNG_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1263 SAMSUNG_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1264 SAMSUNG_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1265 SAMSUNG_ADDRESS_OFFSET, // address_offset: address offset
1266 SAMSUNG_ADDRESS_OFFSET + SAMSUNG_ADDRESS_LEN, // address_end: end of address
1267 SAMSUNG_COMMAND_OFFSET, // command_offset: command offset
1268 SAMSUNG_COMMAND_OFFSET + SAMSUNG_COMMAND_LEN, // command_end: end of command
1269 SAMSUNG_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1270 SAMSUNG_STOP_BIT, // stop_bit: flag: frame has stop bit
1271 SAMSUNG_LSB, // lsb_first: flag: LSB first
1272 SAMSUNG_FLAGS // flags: some flags
1273 };
1274
1275 #endif
1276
1277 #if IRMP_SUPPORT_SAMSUNGAH_PROTOCOL == 1
1278
1279 static const PROGMEM IRMP_PARAMETER samsungah_param =
1280 {
1281 IRMP_SAMSUNGAH_PROTOCOL, // protocol: ir protocol
1282 SAMSUNGAH_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1283 SAMSUNGAH_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1284 SAMSUNGAH_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1285 SAMSUNGAH_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1286 SAMSUNGAH_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1287 SAMSUNGAH_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1288 SAMSUNGAH_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1289 SAMSUNGAH_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1290 SAMSUNGAH_ADDRESS_OFFSET, // address_offset: address offset
1291 SAMSUNGAH_ADDRESS_OFFSET + SAMSUNGAH_ADDRESS_LEN, // address_end: end of address
1292 SAMSUNGAH_COMMAND_OFFSET, // command_offset: command offset
1293 SAMSUNGAH_COMMAND_OFFSET + SAMSUNGAH_COMMAND_LEN, // command_end: end of command
1294 SAMSUNGAH_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1295 SAMSUNGAH_STOP_BIT, // stop_bit: flag: frame has stop bit
1296 SAMSUNGAH_LSB, // lsb_first: flag: LSB first
1297 SAMSUNGAH_FLAGS // flags: some flags
1298 };
1299
1300 #endif
1301
1302 #if IRMP_SUPPORT_TELEFUNKEN_PROTOCOL == 1
1303
1304 static const PROGMEM IRMP_PARAMETER telefunken_param =
1305 {
1306 IRMP_TELEFUNKEN_PROTOCOL, // protocol: ir protocol
1307 TELEFUNKEN_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1308 TELEFUNKEN_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1309 TELEFUNKEN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1310 TELEFUNKEN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1311 TELEFUNKEN_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1312 TELEFUNKEN_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1313 TELEFUNKEN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1314 TELEFUNKEN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1315 TELEFUNKEN_ADDRESS_OFFSET, // address_offset: address offset
1316 TELEFUNKEN_ADDRESS_OFFSET + TELEFUNKEN_ADDRESS_LEN, // address_end: end of address
1317 TELEFUNKEN_COMMAND_OFFSET, // command_offset: command offset
1318 TELEFUNKEN_COMMAND_OFFSET + TELEFUNKEN_COMMAND_LEN, // command_end: end of command
1319 TELEFUNKEN_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1320 TELEFUNKEN_STOP_BIT, // stop_bit: flag: frame has stop bit
1321 TELEFUNKEN_LSB, // lsb_first: flag: LSB first
1322 TELEFUNKEN_FLAGS // flags: some flags
1323 };
1324
1325 #endif
1326
1327 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
1328
1329 static const PROGMEM IRMP_PARAMETER matsushita_param =
1330 {
1331 IRMP_MATSUSHITA_PROTOCOL, // protocol: ir protocol
1332 MATSUSHITA_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1333 MATSUSHITA_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1334 MATSUSHITA_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1335 MATSUSHITA_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1336 MATSUSHITA_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1337 MATSUSHITA_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1338 MATSUSHITA_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1339 MATSUSHITA_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1340 MATSUSHITA_ADDRESS_OFFSET, // address_offset: address offset
1341 MATSUSHITA_ADDRESS_OFFSET + MATSUSHITA_ADDRESS_LEN, // address_end: end of address
1342 MATSUSHITA_COMMAND_OFFSET, // command_offset: command offset
1343 MATSUSHITA_COMMAND_OFFSET + MATSUSHITA_COMMAND_LEN, // command_end: end of command
1344 MATSUSHITA_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1345 MATSUSHITA_STOP_BIT, // stop_bit: flag: frame has stop bit
1346 MATSUSHITA_LSB, // lsb_first: flag: LSB first
1347 MATSUSHITA_FLAGS // flags: some flags
1348 };
1349
1350 #endif
1351
1352 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1353
1354 static const PROGMEM IRMP_PARAMETER kaseikyo_param =
1355 {
1356 IRMP_KASEIKYO_PROTOCOL, // protocol: ir protocol
1357 KASEIKYO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1358 KASEIKYO_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1359 KASEIKYO_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1360 KASEIKYO_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1361 KASEIKYO_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1362 KASEIKYO_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1363 KASEIKYO_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1364 KASEIKYO_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1365 KASEIKYO_ADDRESS_OFFSET, // address_offset: address offset
1366 KASEIKYO_ADDRESS_OFFSET + KASEIKYO_ADDRESS_LEN, // address_end: end of address
1367 KASEIKYO_COMMAND_OFFSET, // command_offset: command offset
1368 KASEIKYO_COMMAND_OFFSET + KASEIKYO_COMMAND_LEN, // command_end: end of command
1369 KASEIKYO_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1370 KASEIKYO_STOP_BIT, // stop_bit: flag: frame has stop bit
1371 KASEIKYO_LSB, // lsb_first: flag: LSB first
1372 KASEIKYO_FLAGS // flags: some flags
1373 };
1374
1375 #endif
1376
1377 #if IRMP_SUPPORT_PANASONIC_PROTOCOL == 1
1378
1379 static const PROGMEM IRMP_PARAMETER panasonic_param =
1380 {
1381 IRMP_PANASONIC_PROTOCOL, // protocol: ir protocol
1382 PANASONIC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1383 PANASONIC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1384 PANASONIC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1385 PANASONIC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1386 PANASONIC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1387 PANASONIC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1388 PANASONIC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1389 PANASONIC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1390 PANASONIC_ADDRESS_OFFSET, // address_offset: address offset
1391 PANASONIC_ADDRESS_OFFSET + PANASONIC_ADDRESS_LEN, // address_end: end of address
1392 PANASONIC_COMMAND_OFFSET, // command_offset: command offset
1393 PANASONIC_COMMAND_OFFSET + PANASONIC_COMMAND_LEN, // command_end: end of command
1394 PANASONIC_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1395 PANASONIC_STOP_BIT, // stop_bit: flag: frame has stop bit
1396 PANASONIC_LSB, // lsb_first: flag: LSB first
1397 PANASONIC_FLAGS // flags: some flags
1398 };
1399
1400 #endif
1401
1402 #if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1
1403
1404 static const PROGMEM IRMP_PARAMETER mitsu_heavy_param =
1405 {
1406 IRMP_MITSU_HEAVY_PROTOCOL, // protocol: ir protocol
1407 MITSU_HEAVY_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1408 MITSU_HEAVY_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1409 MITSU_HEAVY_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1410 MITSU_HEAVY_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1411 MITSU_HEAVY_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1412 MITSU_HEAVY_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1413 MITSU_HEAVY_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1414 MITSU_HEAVY_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1415 MITSU_HEAVY_ADDRESS_OFFSET, // address_offset: address offset
1416 MITSU_HEAVY_ADDRESS_OFFSET + MITSU_HEAVY_ADDRESS_LEN, // address_end: end of address
1417 MITSU_HEAVY_COMMAND_OFFSET, // command_offset: command offset
1418 MITSU_HEAVY_COMMAND_OFFSET + MITSU_HEAVY_COMMAND_LEN, // command_end: end of command
1419 MITSU_HEAVY_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1420 MITSU_HEAVY_STOP_BIT, // stop_bit: flag: frame has stop bit
1421 MITSU_HEAVY_LSB, // lsb_first: flag: LSB first
1422 MITSU_HEAVY_FLAGS // flags: some flags
1423 };
1424
1425 #endif
1426
1427 #if IRMP_SUPPORT_VINCENT_PROTOCOL == 1
1428
1429 static const PROGMEM IRMP_PARAMETER vincent_param =
1430 {
1431 IRMP_VINCENT_PROTOCOL, // protocol: ir protocol
1432 VINCENT_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1433 VINCENT_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1434 VINCENT_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1435 VINCENT_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1436 VINCENT_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1437 VINCENT_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1438 VINCENT_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1439 VINCENT_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1440 VINCENT_ADDRESS_OFFSET, // address_offset: address offset
1441 VINCENT_ADDRESS_OFFSET + VINCENT_ADDRESS_LEN, // address_end: end of address
1442 VINCENT_COMMAND_OFFSET, // command_offset: command offset
1443 VINCENT_COMMAND_OFFSET + VINCENT_COMMAND_LEN, // command_end: end of command
1444 VINCENT_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1445 VINCENT_STOP_BIT, // stop_bit: flag: frame has stop bit
1446 VINCENT_LSB, // lsb_first: flag: LSB first
1447 VINCENT_FLAGS // flags: some flags
1448 };
1449
1450 #endif
1451
1452 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
1453
1454 static const PROGMEM IRMP_PARAMETER recs80_param =
1455 {
1456 IRMP_RECS80_PROTOCOL, // protocol: ir protocol
1457 RECS80_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1458 RECS80_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1459 RECS80_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1460 RECS80_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1461 RECS80_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1462 RECS80_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1463 RECS80_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1464 RECS80_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1465 RECS80_ADDRESS_OFFSET, // address_offset: address offset
1466 RECS80_ADDRESS_OFFSET + RECS80_ADDRESS_LEN, // address_end: end of address
1467 RECS80_COMMAND_OFFSET, // command_offset: command offset
1468 RECS80_COMMAND_OFFSET + RECS80_COMMAND_LEN, // command_end: end of command
1469 RECS80_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1470 RECS80_STOP_BIT, // stop_bit: flag: frame has stop bit
1471 RECS80_LSB, // lsb_first: flag: LSB first
1472 RECS80_FLAGS // flags: some flags
1473 };
1474
1475 #endif
1476
1477 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1478
1479 static const PROGMEM IRMP_PARAMETER rc5_param =
1480 {
1481 IRMP_RC5_PROTOCOL, // protocol: ir protocol
1482 RC5_BIT_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1483 RC5_BIT_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1484 RC5_BIT_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1485 RC5_BIT_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1486 0, // pulse_0_len_min: here: not used
1487 0, // pulse_0_len_max: here: not used
1488 0, // pause_0_len_min: here: not used
1489 0, // pause_0_len_max: here: not used
1490 RC5_ADDRESS_OFFSET, // address_offset: address offset
1491 RC5_ADDRESS_OFFSET + RC5_ADDRESS_LEN, // address_end: end of address
1492 RC5_COMMAND_OFFSET, // command_offset: command offset
1493 RC5_COMMAND_OFFSET + RC5_COMMAND_LEN, // command_end: end of command
1494 RC5_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1495 RC5_STOP_BIT, // stop_bit: flag: frame has stop bit
1496 RC5_LSB, // lsb_first: flag: LSB first
1497 RC5_FLAGS // flags: some flags
1498 };
1499
1500 #endif
1501
1502 #if IRMP_SUPPORT_S100_PROTOCOL == 1
1503
1504 static const PROGMEM IRMP_PARAMETER s100_param =
1505 {
1506 IRMP_S100_PROTOCOL, // protocol: ir protocol
1507 S100_BIT_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1508 S100_BIT_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1509 S100_BIT_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1510 S100_BIT_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1511 0, // pulse_0_len_min: here: not used
1512 0, // pulse_0_len_max: here: not used
1513 0, // pause_0_len_min: here: not used
1514 0, // pause_0_len_max: here: not used
1515 S100_ADDRESS_OFFSET, // address_offset: address offset
1516 S100_ADDRESS_OFFSET + S100_ADDRESS_LEN, // address_end: end of address
1517 S100_COMMAND_OFFSET, // command_offset: command offset
1518 S100_COMMAND_OFFSET + S100_COMMAND_LEN, // command_end: end of command
1519 S100_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1520 S100_STOP_BIT, // stop_bit: flag: frame has stop bit
1521 S100_LSB, // lsb_first: flag: LSB first
1522 S100_FLAGS // flags: some flags
1523 };
1524
1525 #endif
1526
1527 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1528
1529 static const PROGMEM IRMP_PARAMETER denon_param =
1530 {
1531 IRMP_DENON_PROTOCOL, // protocol: ir protocol
1532 DENON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1533 DENON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1534 DENON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1535 DENON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1536 DENON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1537 DENON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1538 DENON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1539 DENON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1540 DENON_ADDRESS_OFFSET, // address_offset: address offset
1541 DENON_ADDRESS_OFFSET + DENON_ADDRESS_LEN, // address_end: end of address
1542 DENON_COMMAND_OFFSET, // command_offset: command offset
1543 DENON_COMMAND_OFFSET + DENON_COMMAND_LEN, // command_end: end of command
1544 DENON_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1545 DENON_STOP_BIT, // stop_bit: flag: frame has stop bit
1546 DENON_LSB, // lsb_first: flag: LSB first
1547 DENON_FLAGS // flags: some flags
1548 };
1549
1550 #endif
1551
1552 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1553
1554 static const PROGMEM IRMP_PARAMETER rc6_param =
1555 {
1556 IRMP_RC6_PROTOCOL, // protocol: ir protocol
1557
1558 RC6_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1559 RC6_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1560 RC6_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1561 RC6_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1562 0, // pulse_0_len_min: here: not used
1563 0, // pulse_0_len_max: here: not used
1564 0, // pause_0_len_min: here: not used
1565 0, // pause_0_len_max: here: not used
1566 RC6_ADDRESS_OFFSET, // address_offset: address offset
1567 RC6_ADDRESS_OFFSET + RC6_ADDRESS_LEN, // address_end: end of address
1568 RC6_COMMAND_OFFSET, // command_offset: command offset
1569 RC6_COMMAND_OFFSET + RC6_COMMAND_LEN, // command_end: end of command
1570 RC6_COMPLETE_DATA_LEN_SHORT, // complete_len: complete length of frame
1571 RC6_STOP_BIT, // stop_bit: flag: frame has stop bit
1572 RC6_LSB, // lsb_first: flag: LSB first
1573 RC6_FLAGS // flags: some flags
1574 };
1575
1576 #endif
1577
1578 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
1579
1580 static const PROGMEM IRMP_PARAMETER recs80ext_param =
1581 {
1582 IRMP_RECS80EXT_PROTOCOL, // protocol: ir protocol
1583 RECS80EXT_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1584 RECS80EXT_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1585 RECS80EXT_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1586 RECS80EXT_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1587 RECS80EXT_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1588 RECS80EXT_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1589 RECS80EXT_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1590 RECS80EXT_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1591 RECS80EXT_ADDRESS_OFFSET, // address_offset: address offset
1592 RECS80EXT_ADDRESS_OFFSET + RECS80EXT_ADDRESS_LEN, // address_end: end of address
1593 RECS80EXT_COMMAND_OFFSET, // command_offset: command offset
1594 RECS80EXT_COMMAND_OFFSET + RECS80EXT_COMMAND_LEN, // command_end: end of command
1595 RECS80EXT_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1596 RECS80EXT_STOP_BIT, // stop_bit: flag: frame has stop bit
1597 RECS80EXT_LSB, // lsb_first: flag: LSB first
1598 RECS80EXT_FLAGS // flags: some flags
1599 };
1600
1601 #endif
1602
1603 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1604
1605 static const PROGMEM IRMP_PARAMETER nubert_param =
1606 {
1607 IRMP_NUBERT_PROTOCOL, // protocol: ir protocol
1608 NUBERT_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1609 NUBERT_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1610 NUBERT_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1611 NUBERT_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1612 NUBERT_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1613 NUBERT_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1614 NUBERT_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1615 NUBERT_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1616 NUBERT_ADDRESS_OFFSET, // address_offset: address offset
1617 NUBERT_ADDRESS_OFFSET + NUBERT_ADDRESS_LEN, // address_end: end of address
1618 NUBERT_COMMAND_OFFSET, // command_offset: command offset
1619 NUBERT_COMMAND_OFFSET + NUBERT_COMMAND_LEN, // command_end: end of command
1620 NUBERT_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1621 NUBERT_STOP_BIT, // stop_bit: flag: frame has stop bit
1622 NUBERT_LSB, // lsb_first: flag: LSB first
1623 NUBERT_FLAGS // flags: some flags
1624 };
1625
1626 #endif
1627
1628 #if IRMP_SUPPORT_FAN_PROTOCOL == 1
1629
1630 static const PROGMEM IRMP_PARAMETER fan_param =
1631 {
1632 IRMP_FAN_PROTOCOL, // protocol: ir protocol
1633 FAN_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1634 FAN_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1635 FAN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1636 FAN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1637 FAN_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1638 FAN_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1639 FAN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1640 FAN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1641 FAN_ADDRESS_OFFSET, // address_offset: address offset
1642 FAN_ADDRESS_OFFSET + FAN_ADDRESS_LEN, // address_end: end of address
1643 FAN_COMMAND_OFFSET, // command_offset: command offset
1644 FAN_COMMAND_OFFSET + FAN_COMMAND_LEN, // command_end: end of command
1645 FAN_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1646 FAN_STOP_BIT, // stop_bit: flag: frame has NO stop bit
1647 FAN_LSB, // lsb_first: flag: LSB first
1648 FAN_FLAGS // flags: some flags
1649 };
1650
1651 #endif
1652
1653 #if IRMP_SUPPORT_SPEAKER_PROTOCOL == 1
1654
1655 static const PROGMEM IRMP_PARAMETER speaker_param =
1656 {
1657 IRMP_SPEAKER_PROTOCOL, // protocol: ir protocol
1658 SPEAKER_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1659 SPEAKER_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1660 SPEAKER_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1661 SPEAKER_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1662 SPEAKER_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1663 SPEAKER_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1664 SPEAKER_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1665 SPEAKER_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1666 SPEAKER_ADDRESS_OFFSET, // address_offset: address offset
1667 SPEAKER_ADDRESS_OFFSET + SPEAKER_ADDRESS_LEN, // address_end: end of address
1668 SPEAKER_COMMAND_OFFSET, // command_offset: command offset
1669 SPEAKER_COMMAND_OFFSET + SPEAKER_COMMAND_LEN, // command_end: end of command
1670 SPEAKER_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1671 SPEAKER_STOP_BIT, // stop_bit: flag: frame has stop bit
1672 SPEAKER_LSB, // lsb_first: flag: LSB first
1673 SPEAKER_FLAGS // flags: some flags
1674 };
1675
1676 #endif
1677
1678 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1679
1680 static const PROGMEM IRMP_PARAMETER bang_olufsen_param =
1681 {
1682 IRMP_BANG_OLUFSEN_PROTOCOL, // protocol: ir protocol
1683 BANG_OLUFSEN_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1684 BANG_OLUFSEN_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1685 BANG_OLUFSEN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1686 BANG_OLUFSEN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1687 BANG_OLUFSEN_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1688 BANG_OLUFSEN_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1689 BANG_OLUFSEN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1690 BANG_OLUFSEN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1691 BANG_OLUFSEN_ADDRESS_OFFSET, // address_offset: address offset
1692 BANG_OLUFSEN_ADDRESS_OFFSET + BANG_OLUFSEN_ADDRESS_LEN, // address_end: end of address
1693 BANG_OLUFSEN_COMMAND_OFFSET, // command_offset: command offset
1694 BANG_OLUFSEN_COMMAND_OFFSET + BANG_OLUFSEN_COMMAND_LEN, // command_end: end of command
1695 BANG_OLUFSEN_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1696 BANG_OLUFSEN_STOP_BIT, // stop_bit: flag: frame has stop bit
1697 BANG_OLUFSEN_LSB, // lsb_first: flag: LSB first
1698 BANG_OLUFSEN_FLAGS // flags: some flags
1699 };
1700
1701 #endif
1702
1703 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
1704
1705 static uint_fast8_t first_bit;
1706
1707 static const PROGMEM IRMP_PARAMETER grundig_param =
1708 {
1709 IRMP_GRUNDIG_PROTOCOL, // protocol: ir protocol
1710
1711 GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1712 GRUNDIG_NOKIA_IR60_BIT_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1713 GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1714 GRUNDIG_NOKIA_IR60_BIT_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1715 0, // pulse_0_len_min: here: not used
1716 0, // pulse_0_len_max: here: not used
1717 0, // pause_0_len_min: here: not used
1718 0, // pause_0_len_max: here: not used
1719 GRUNDIG_ADDRESS_OFFSET, // address_offset: address offset
1720 GRUNDIG_ADDRESS_OFFSET + GRUNDIG_ADDRESS_LEN, // address_end: end of address
1721 GRUNDIG_COMMAND_OFFSET, // command_offset: command offset
1722 GRUNDIG_COMMAND_OFFSET + GRUNDIG_COMMAND_LEN + 1, // command_end: end of command (USE 1 bit MORE to STORE NOKIA DATA!)
1723 NOKIA_COMPLETE_DATA_LEN, // complete_len: complete length of frame, here: NOKIA instead of GRUNDIG!
1724 GRUNDIG_NOKIA_IR60_STOP_BIT, // stop_bit: flag: frame has stop bit
1725 GRUNDIG_NOKIA_IR60_LSB, // lsb_first: flag: LSB first
1726 GRUNDIG_NOKIA_IR60_FLAGS // flags: some flags
1727 };
1728
1729 #endif
1730
1731 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
1732
1733 static const PROGMEM IRMP_PARAMETER ruwido_param =
1734 {
1735 IRMP_RUWIDO_PROTOCOL, // protocol: ir protocol
1736 SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1737 SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1738 SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1739 SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1740 0, // pulse_0_len_min: here: not used
1741 0, // pulse_0_len_max: here: not used
1742 0, // pause_0_len_min: here: not used
1743 0, // pause_0_len_max: here: not used
1744 RUWIDO_ADDRESS_OFFSET, // address_offset: address offset
1745 RUWIDO_ADDRESS_OFFSET + RUWIDO_ADDRESS_LEN, // address_end: end of address
1746 RUWIDO_COMMAND_OFFSET, // command_offset: command offset
1747 RUWIDO_COMMAND_OFFSET + RUWIDO_COMMAND_LEN, // command_end: end of command
1748 SIEMENS_COMPLETE_DATA_LEN, // complete_len: complete length of frame, here: SIEMENS instead of RUWIDO!
1749 SIEMENS_OR_RUWIDO_STOP_BIT, // stop_bit: flag: frame has stop bit
1750 SIEMENS_OR_RUWIDO_LSB, // lsb_first: flag: LSB first
1751 SIEMENS_OR_RUWIDO_FLAGS // flags: some flags
1752 };
1753
1754 #endif
1755
1756 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
1757
1758 static const PROGMEM IRMP_PARAMETER fdc_param =
1759 {
1760 IRMP_FDC_PROTOCOL, // protocol: ir protocol
1761 FDC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1762 FDC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1763 FDC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1764 FDC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1765 FDC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1766 FDC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1767 FDC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1768 FDC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1769 FDC_ADDRESS_OFFSET, // address_offset: address offset
1770 FDC_ADDRESS_OFFSET + FDC_ADDRESS_LEN, // address_end: end of address
1771 FDC_COMMAND_OFFSET, // command_offset: command offset
1772 FDC_COMMAND_OFFSET + FDC_COMMAND_LEN, // command_end: end of command
1773 FDC_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1774 FDC_STOP_BIT, // stop_bit: flag: frame has stop bit
1775 FDC_LSB, // lsb_first: flag: LSB first
1776 FDC_FLAGS // flags: some flags
1777 };
1778
1779 #endif
1780
1781 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
1782
1783 static const PROGMEM IRMP_PARAMETER rccar_param =
1784 {
1785 IRMP_RCCAR_PROTOCOL, // protocol: ir protocol
1786 RCCAR_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1787 RCCAR_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1788 RCCAR_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1789 RCCAR_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1790 RCCAR_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1791 RCCAR_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1792 RCCAR_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1793 RCCAR_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1794 RCCAR_ADDRESS_OFFSET, // address_offset: address offset
1795 RCCAR_ADDRESS_OFFSET + RCCAR_ADDRESS_LEN, // address_end: end of address
1796 RCCAR_COMMAND_OFFSET, // command_offset: command offset
1797 RCCAR_COMMAND_OFFSET + RCCAR_COMMAND_LEN, // command_end: end of command
1798 RCCAR_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1799 RCCAR_STOP_BIT, // stop_bit: flag: frame has stop bit
1800 RCCAR_LSB, // lsb_first: flag: LSB first
1801 RCCAR_FLAGS // flags: some flags
1802 };
1803
1804 #endif
1805
1806 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1
1807
1808 static const PROGMEM IRMP_PARAMETER nikon_param =
1809 {
1810 IRMP_NIKON_PROTOCOL, // protocol: ir protocol
1811 NIKON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1812 NIKON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1813 NIKON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1814 NIKON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1815 NIKON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1816 NIKON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1817 NIKON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1818 NIKON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1819 NIKON_ADDRESS_OFFSET, // address_offset: address offset
1820 NIKON_ADDRESS_OFFSET + NIKON_ADDRESS_LEN, // address_end: end of address
1821 NIKON_COMMAND_OFFSET, // command_offset: command offset
1822 NIKON_COMMAND_OFFSET + NIKON_COMMAND_LEN, // command_end: end of command
1823 NIKON_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1824 NIKON_STOP_BIT, // stop_bit: flag: frame has stop bit
1825 NIKON_LSB, // lsb_first: flag: LSB first
1826 NIKON_FLAGS // flags: some flags
1827 };
1828
1829 #endif
1830
1831 #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
1832
1833 static const PROGMEM IRMP_PARAMETER kathrein_param =
1834 {
1835 IRMP_KATHREIN_PROTOCOL, // protocol: ir protocol
1836 KATHREIN_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1837 KATHREIN_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1838 KATHREIN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1839 KATHREIN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1840 KATHREIN_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1841 KATHREIN_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1842 KATHREIN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1843 KATHREIN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1844 KATHREIN_ADDRESS_OFFSET, // address_offset: address offset
1845 KATHREIN_ADDRESS_OFFSET + KATHREIN_ADDRESS_LEN, // address_end: end of address
1846 KATHREIN_COMMAND_OFFSET, // command_offset: command offset
1847 KATHREIN_COMMAND_OFFSET + KATHREIN_COMMAND_LEN, // command_end: end of command
1848 KATHREIN_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1849 KATHREIN_STOP_BIT, // stop_bit: flag: frame has stop bit
1850 KATHREIN_LSB, // lsb_first: flag: LSB first
1851 KATHREIN_FLAGS // flags: some flags
1852 };
1853
1854 #endif
1855
1856 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1
1857
1858 static const PROGMEM IRMP_PARAMETER netbox_param =
1859 {
1860 IRMP_NETBOX_PROTOCOL, // protocol: ir protocol
1861 NETBOX_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1, here: exact value
1862 NETBOX_PULSE_REST_LEN, // pulse_1_len_max: maximum length of pulse with bit value 1, here: rest value
1863 NETBOX_PAUSE_LEN, // pause_1_len_min: minimum length of pause with bit value 1, here: exact value
1864 NETBOX_PAUSE_REST_LEN, // pause_1_len_max: maximum length of pause with bit value 1, here: rest value
1865 NETBOX_PULSE_LEN, // pulse_0_len_min: minimum length of pulse with bit value 0, here: exact value
1866 NETBOX_PULSE_REST_LEN, // pulse_0_len_max: maximum length of pulse with bit value 0, here: rest value
1867 NETBOX_PAUSE_LEN, // pause_0_len_min: minimum length of pause with bit value 0, here: exact value
1868 NETBOX_PAUSE_REST_LEN, // pause_0_len_max: maximum length of pause with bit value 0, here: rest value
1869 NETBOX_ADDRESS_OFFSET, // address_offset: address offset
1870 NETBOX_ADDRESS_OFFSET + NETBOX_ADDRESS_LEN, // address_end: end of address
1871 NETBOX_COMMAND_OFFSET, // command_offset: command offset
1872 NETBOX_COMMAND_OFFSET + NETBOX_COMMAND_LEN, // command_end: end of command
1873 NETBOX_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1874 NETBOX_STOP_BIT, // stop_bit: flag: frame has stop bit
1875 NETBOX_LSB, // lsb_first: flag: LSB first
1876 NETBOX_FLAGS // flags: some flags
1877 };
1878
1879 #endif
1880
1881 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1
1882
1883 static const PROGMEM IRMP_PARAMETER lego_param =
1884 {
1885 IRMP_LEGO_PROTOCOL, // protocol: ir protocol
1886 LEGO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1887 LEGO_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1888 LEGO_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1889 LEGO_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1890 LEGO_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1891 LEGO_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1892 LEGO_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1893 LEGO_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1894 LEGO_ADDRESS_OFFSET, // address_offset: address offset
1895 LEGO_ADDRESS_OFFSET + LEGO_ADDRESS_LEN, // address_end: end of address
1896 LEGO_COMMAND_OFFSET, // command_offset: command offset
1897 LEGO_COMMAND_OFFSET + LEGO_COMMAND_LEN, // command_end: end of command
1898 LEGO_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1899 LEGO_STOP_BIT, // stop_bit: flag: frame has stop bit
1900 LEGO_LSB, // lsb_first: flag: LSB first
1901 LEGO_FLAGS // flags: some flags
1902 };
1903
1904 #endif
1905
1906 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1
1907
1908 static const PROGMEM IRMP_PARAMETER thomson_param =
1909 {
1910 IRMP_THOMSON_PROTOCOL, // protocol: ir protocol
1911 THOMSON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1912 THOMSON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1913 THOMSON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1914 THOMSON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1915 THOMSON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1916 THOMSON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1917 THOMSON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1918 THOMSON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1919 THOMSON_ADDRESS_OFFSET, // address_offset: address offset
1920 THOMSON_ADDRESS_OFFSET + THOMSON_ADDRESS_LEN, // address_end: end of address
1921 THOMSON_COMMAND_OFFSET, // command_offset: command offset
1922 THOMSON_COMMAND_OFFSET + THOMSON_COMMAND_LEN, // command_end: end of command
1923 THOMSON_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1924 THOMSON_STOP_BIT, // stop_bit: flag: frame has stop bit
1925 THOMSON_LSB, // lsb_first: flag: LSB first
1926 THOMSON_FLAGS // flags: some flags
1927 };
1928
1929 #endif
1930
1931 #if IRMP_SUPPORT_BOSE_PROTOCOL == 1
1932
1933 static const PROGMEM IRMP_PARAMETER bose_param =
1934 {
1935 IRMP_BOSE_PROTOCOL, // protocol: ir protocol
1936 BOSE_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1937 BOSE_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1938 BOSE_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1939 BOSE_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1940 BOSE_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1941 BOSE_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1942 BOSE_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1943 BOSE_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1944 BOSE_ADDRESS_OFFSET, // address_offset: address offset
1945 BOSE_ADDRESS_OFFSET + BOSE_ADDRESS_LEN, // address_end: end of address
1946 BOSE_COMMAND_OFFSET, // command_offset: command offset
1947 BOSE_COMMAND_OFFSET + BOSE_COMMAND_LEN, // command_end: end of command
1948 BOSE_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1949 BOSE_STOP_BIT, // stop_bit: flag: frame has stop bit
1950 BOSE_LSB, // lsb_first: flag: LSB first
1951 BOSE_FLAGS // flags: some flags
1952 };
1953
1954 #endif
1955
1956 #if IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1
1957
1958 static const PROGMEM IRMP_PARAMETER a1tvbox_param =
1959 {
1960 IRMP_A1TVBOX_PROTOCOL, // protocol: ir protocol
1961
1962 A1TVBOX_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1963 A1TVBOX_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1964 A1TVBOX_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1965 A1TVBOX_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1966 0, // pulse_0_len_min: here: not used
1967 0, // pulse_0_len_max: here: not used
1968 0, // pause_0_len_min: here: not used
1969 0, // pause_0_len_max: here: not used
1970 A1TVBOX_ADDRESS_OFFSET, // address_offset: address offset
1971 A1TVBOX_ADDRESS_OFFSET + A1TVBOX_ADDRESS_LEN, // address_end: end of address
1972 A1TVBOX_COMMAND_OFFSET, // command_offset: command offset
1973 A1TVBOX_COMMAND_OFFSET + A1TVBOX_COMMAND_LEN, // command_end: end of command
1974 A1TVBOX_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1975 A1TVBOX_STOP_BIT, // stop_bit: flag: frame has stop bit
1976 A1TVBOX_LSB, // lsb_first: flag: LSB first
1977 A1TVBOX_FLAGS // flags: some flags
1978 };
1979
1980 #endif
1981
1982 #if IRMP_SUPPORT_MERLIN_PROTOCOL == 1
1983
1984 static const PROGMEM IRMP_PARAMETER merlin_param =
1985 {
1986 IRMP_MERLIN_PROTOCOL, // protocol: ir protocol
1987
1988 MERLIN_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1989 MERLIN_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1990 MERLIN_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1991 MERLIN_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1992 0, // pulse_0_len_min: here: not used
1993 0, // pulse_0_len_max: here: not used
1994 0, // pause_0_len_min: here: not used
1995 0, // pause_0_len_max: here: not used
1996 MERLIN_ADDRESS_OFFSET, // address_offset: address offset
1997 MERLIN_ADDRESS_OFFSET + MERLIN_ADDRESS_LEN, // address_end: end of address
1998 MERLIN_COMMAND_OFFSET, // command_offset: command offset
1999 MERLIN_COMMAND_OFFSET + MERLIN_COMMAND_LEN, // command_end: end of command
2000 MERLIN_COMPLETE_DATA_LEN, // complete_len: complete length of frame
2001 MERLIN_STOP_BIT, // stop_bit: flag: frame has stop bit
2002 MERLIN_LSB, // lsb_first: flag: LSB first
2003 MERLIN_FLAGS // flags: some flags
2004 };
2005
2006 #endif
2007
2008 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
2009
2010 static const PROGMEM IRMP_PARAMETER ortek_param =
2011 {
2012 IRMP_ORTEK_PROTOCOL, // protocol: ir protocol
2013
2014 ORTEK_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
2015 ORTEK_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
2016 ORTEK_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
2017 ORTEK_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
2018 0, // pulse_0_len_min: here: not used
2019 0, // pulse_0_len_max: here: not used
2020 0, // pause_0_len_min: here: not used
2021 0, // pause_0_len_max: here: not used
2022 ORTEK_ADDRESS_OFFSET, // address_offset: address offset
2023 ORTEK_ADDRESS_OFFSET + ORTEK_ADDRESS_LEN, // address_end: end of address
2024 ORTEK_COMMAND_OFFSET, // command_offset: command offset
2025 ORTEK_COMMAND_OFFSET + ORTEK_COMMAND_LEN, // command_end: end of command
2026 ORTEK_COMPLETE_DATA_LEN, // complete_len: complete length of frame
2027 ORTEK_STOP_BIT, // stop_bit: flag: frame has stop bit
2028 ORTEK_LSB, // lsb_first: flag: LSB first
2029 ORTEK_FLAGS // flags: some flags
2030 };
2031
2032 #endif
2033
2034 #if IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
2035
2036 static const PROGMEM IRMP_PARAMETER roomba_param =
2037 {
2038 IRMP_ROOMBA_PROTOCOL, // protocol: ir protocol
2039 ROOMBA_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
2040 ROOMBA_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
2041 ROOMBA_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
2042 ROOMBA_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
2043 ROOMBA_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
2044 ROOMBA_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
2045 ROOMBA_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
2046 ROOMBA_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
2047 ROOMBA_ADDRESS_OFFSET, // address_offset: address offset
2048 ROOMBA_ADDRESS_OFFSET + ROOMBA_ADDRESS_LEN, // address_end: end of address
2049 ROOMBA_COMMAND_OFFSET, // command_offset: command offset
2050 ROOMBA_COMMAND_OFFSET + ROOMBA_COMMAND_LEN, // command_end: end of command
2051 ROOMBA_COMPLETE_DATA_LEN, // complete_len: complete length of frame
2052 ROOMBA_STOP_BIT, // stop_bit: flag: frame has stop bit
2053 ROOMBA_LSB, // lsb_first: flag: LSB first
2054 ROOMBA_FLAGS // flags: some flags
2055 };
2056
2057 #endif
2058
2059 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1
2060
2061 static const PROGMEM IRMP_PARAMETER rcmm_param =
2062 {
2063 IRMP_RCMM32_PROTOCOL, // protocol: ir protocol
2064
2065 RCMM32_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
2066 RCMM32_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
2067 0, // pause_1_len_min: here: minimum length of short pause
2068 0, // pause_1_len_max: here: maximum length of short pause
2069 RCMM32_BIT_PULSE_LEN_MIN, // pulse_0_len_min: here: not used
2070 RCMM32_BIT_PULSE_LEN_MAX, // pulse_0_len_max: here: not used
2071 0, // pause_0_len_min: here: not used
2072 0, // pause_0_len_max: here: not used
2073 RCMM32_ADDRESS_OFFSET, // address_offset: address offset
2074 RCMM32_ADDRESS_OFFSET + RCMM32_ADDRESS_LEN, // address_end: end of address
2075 RCMM32_COMMAND_OFFSET, // command_offset: command offset
2076 RCMM32_COMMAND_OFFSET + RCMM32_COMMAND_LEN, // command_end: end of command
2077 RCMM32_COMPLETE_DATA_LEN, // complete_len: complete length of frame
2078 RCMM32_STOP_BIT, // stop_bit: flag: frame has stop bit
2079 RCMM32_LSB, // lsb_first: flag: LSB first
2080 RCMM32_FLAGS // flags: some flags
2081 };
2082
2083 #endif
2084
2085 #if IRMP_SUPPORT_PENTAX_PROTOCOL == 1
2086
2087 static const PROGMEM IRMP_PARAMETER pentax_param =
2088 {
2089 IRMP_PENTAX_PROTOCOL, // protocol: ir protocol
2090 PENTAX_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
2091 PENTAX_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
2092 PENTAX_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
2093 PENTAX_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
2094 PENTAX_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
2095 PENTAX_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
2096 PENTAX_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
2097 PENTAX_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
2098 PENTAX_ADDRESS_OFFSET, // address_offset: address offset
2099 PENTAX_ADDRESS_OFFSET + PENTAX_ADDRESS_LEN, // address_end: end of address
2100 PENTAX_COMMAND_OFFSET, // command_offset: command offset
2101 PENTAX_COMMAND_OFFSET + PENTAX_COMMAND_LEN, // command_end: end of command
2102 PENTAX_COMPLETE_DATA_LEN, // complete_len: complete length of frame
2103 PENTAX_STOP_BIT, // stop_bit: flag: frame has stop bit
2104 PENTAX_LSB, // lsb_first: flag: LSB first
2105 PENTAX_FLAGS // flags: some flags
2106 };
2107
2108 #endif
2109
2110 #if IRMP_SUPPORT_ACP24_PROTOCOL == 1
2111
2112 static const PROGMEM IRMP_PARAMETER acp24_param =
2113 {
2114 IRMP_ACP24_PROTOCOL, // protocol: ir protocol
2115 ACP24_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
2116 ACP24_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
2117 ACP24_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
2118 ACP24_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
2119 ACP24_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
2120 ACP24_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
2121 ACP24_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
2122 ACP24_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
2123 ACP24_ADDRESS_OFFSET, // address_offset: address offset
2124 ACP24_ADDRESS_OFFSET + ACP24_ADDRESS_LEN, // address_end: end of address
2125 ACP24_COMMAND_OFFSET, // command_offset: command offset
2126 ACP24_COMMAND_OFFSET + ACP24_COMMAND_LEN, // command_end: end of command
2127 ACP24_COMPLETE_DATA_LEN, // complete_len: complete length of frame
2128 ACP24_STOP_BIT, // stop_bit: flag: frame has stop bit
2129 ACP24_LSB, // lsb_first: flag: LSB first
2130 ACP24_FLAGS // flags: some flags
2131 };
2132
2133 #endif
2134
2135 #if IRMP_SUPPORT_RADIO1_PROTOCOL == 1
2136
2137 static const PROGMEM IRMP_PARAMETER radio1_param =
2138 {
2139 IRMP_RADIO1_PROTOCOL, // protocol: ir protocol
2140
2141 RADIO1_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
2142 RADIO1_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
2143 RADIO1_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
2144 RADIO1_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
2145 RADIO1_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
2146 RADIO1_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
2147 RADIO1_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
2148 RADIO1_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
2149 RADIO1_ADDRESS_OFFSET, // address_offset: address offset
2150 RADIO1_ADDRESS_OFFSET + RADIO1_ADDRESS_LEN, // address_end: end of address
2151 RADIO1_COMMAND_OFFSET, // command_offset: command offset
2152 RADIO1_COMMAND_OFFSET + RADIO1_COMMAND_LEN, // command_end: end of command
2153 RADIO1_COMPLETE_DATA_LEN, // complete_len: complete length of frame
2154 RADIO1_STOP_BIT, // stop_bit: flag: frame has stop bit
2155 RADIO1_LSB, // lsb_first: flag: LSB first
2156 RADIO1_FLAGS // flags: some flags
2157 };
2158
2159 #endif
2160
2161 static uint_fast8_t irmp_bit; // current bit position
2162 static IRMP_PARAMETER irmp_param;
2163
2164 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2165 static IRMP_PARAMETER irmp_param2;
2166 #endif
2167
2168 static volatile uint_fast8_t irmp_ir_detected = FALSE;
2169 static volatile uint_fast8_t irmp_protocol;
2170 static volatile uint_fast16_t irmp_address;
2171 static volatile uint_fast16_t irmp_command;
2172 static volatile uint_fast16_t irmp_id; // only used for SAMSUNG protocol
2173 static volatile uint_fast8_t irmp_flags;
2174 // static volatile uint_fast8_t irmp_busy_flag;
2175
2176 #if defined(__MBED__)
2177 // DigitalIn inputPin(IRMP_PIN, PullUp); // this requires mbed.h and source to be compiled as cpp
2178 gpio_t gpioIRin; // use low level c function instead
2179 #endif
2180
2181
2182 #ifdef ANALYZE
2183 #define input(x) (x)
2184 static uint_fast8_t IRMP_PIN;
2185 static uint_fast8_t radio;
2186 #endif
2187
2188 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2189 * Initialize IRMP decoder
2190 * @details Configures IRMP input pin
2191 *---------------------------------------------------------------------------------------------------------------------------------------------------
2192 */
2193 #ifndef ANALYZE
2194 void
2195 irmp_init (void)
2196 {
2197 #if defined(PIC_CCS) || defined(PIC_C18) // PIC: do nothing
2198 #elif defined (ARM_STM32) // STM32
2199 GPIO_InitTypeDef GPIO_InitStructure;
2200
2201 /* GPIOx clock enable */
2202 # if defined (ARM_STM32L1XX)
2203 RCC_AHBPeriphClockCmd(IRMP_PORT_RCC, ENABLE);
2204 # elif defined (ARM_STM32F10X)
2205 RCC_APB2PeriphClockCmd(IRMP_PORT_RCC, ENABLE);
2206 # elif defined (ARM_STM32F4XX)
2207 RCC_AHB1PeriphClockCmd(IRMP_PORT_RCC, ENABLE);
2208 # endif
2209
2210 /* GPIO Configuration */
2211 GPIO_InitStructure.GPIO_Pin = IRMP_BIT;
2212 # if defined (ARM_STM32L1XX) || defined (ARM_STM32F4XX)
2213 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
2214 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
2215 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
2216 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
2217 # elif defined (ARM_STM32F10X)
2218 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
2219 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
2220 # endif
2221 GPIO_Init(IRMP_PORT, &GPIO_InitStructure);
2222
2223 #elif defined (LIBOPENCM3) // STM32 with libopencm3
2224
2225 /* GPIOx clock enable */
2226 rcc_periph_clock_enable(IRMP_PORT_RCC);
2227 /* GPIO Configuration */
2228 gpio_set_mode(IRMP_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, IRMP_BIT);
2229
2230 #elif defined(STELLARIS_ARM_CORTEX_M4)
2231 // Enable the GPIO port
2232 ROM_SysCtlPeripheralEnable(IRMP_PORT_PERIPH);
2233
2234 // Set as an input
2235 ROM_GPIODirModeSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_DIR_MODE_IN);
2236 ROM_GPIOPadConfigSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
2237
2238 #elif defined(__SDCC_stm8) // STM8
2239 IRMP_GPIO_STRUCT->DDR &= ~(1<<IRMP_BIT); // pin is input
2240 IRMP_GPIO_STRUCT->CR1 |= (1<<IRMP_BIT); // activate pullup
2241
2242 #elif defined (TEENSY_ARM_CORTEX_M4) // TEENSY
2243 pinMode(IRMP_PIN, INPUT);
2244
2245 #elif defined(__xtensa__) // ESP8266
2246 pinMode(IRMP_BIT_NUMBER, INPUT);
2247 // select pin function
2248 # if (IRMP_BIT_NUMBER == 12)
2249 PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
2250 // doesn't work for me:
2251 // # elif (IRMP_BIT_NUMBER == 13)
2252 // PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U , FUNC_GPIO13);
2253 # else
2254 # warning Please add PIN_FUNC_SELECT when necessary.
2255 # endif
2256 GPIO_DIS_OUTPUT(IRMP_BIT_NUMBER);
2257
2258 #elif defined(__MBED__)
2259 gpio_init_in_ex(&gpioIRin, IRMP_PIN, IRMP_PINMODE); // initialize input for IR diode
2260
2261 #else // AVR
2262 IRMP_PORT &= ~(1<<IRMP_BIT); // deactivate pullup
2263 IRMP_DDR &= ~(1<<IRMP_BIT); // set pin to input
2264 #endif
2265
2266 #if IRMP_LOGGING == 1
2267 irmp_uart_init ();
2268 #endif
2269 }
2270 #endif
2271 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2272 * Get IRMP data
2273 * @details gets decoded IRMP data
2274 * @param pointer in order to store IRMP data
2275 * @return TRUE: successful, FALSE: failed
2276 *---------------------------------------------------------------------------------------------------------------------------------------------------
2277 */
2278 uint_fast8_t
2279 irmp_get_data (IRMP_DATA * irmp_data_p)
2280 {
2281 uint_fast8_t rtc = FALSE;
2282
2283 if (irmp_ir_detected)
2284 {
2285 switch (irmp_protocol)
2286 {
2287 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2288 case IRMP_SAMSUNG_PROTOCOL:
2289 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))
2290 {
2291 irmp_command &= 0xff;
2292 irmp_command |= irmp_id << 8;
2293 rtc = TRUE;
2294 }
2295 break;
2296
2297 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1
2298 case IRMP_SAMSUNG48_PROTOCOL:
2299 irmp_command = (irmp_command & 0x00FF) | ((irmp_id & 0x00FF) << 8);
2300 rtc = TRUE;
2301 break;
2302 #endif
2303 #endif
2304
2305 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2306 case IRMP_NEC_PROTOCOL:
2307 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))
2308 {
2309 irmp_command &= 0xff;
2310 rtc = TRUE;
2311 }
2312 else if (irmp_address == 0x87EE)
2313 {
2314 #ifdef ANALYZE
2315 ANALYZE_PRINTF ("Switching to APPLE protocol\n");
2316 #endif // ANALYZE
2317 irmp_protocol = IRMP_APPLE_PROTOCOL;
2318 irmp_address = (irmp_command & 0xFF00) >> 8;
2319 irmp_command &= 0x00FF;
2320 rtc = TRUE;
2321 }
2322 break;
2323 #endif
2324
2325
2326 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2327 case IRMP_VINCENT_PROTOCOL:
2328 if ((irmp_command >> 8) == (irmp_command & 0x00FF))
2329 {
2330 irmp_command &= 0xff;
2331 rtc = TRUE;
2332 }
2333 break;
2334 #endif
2335
2336 #if IRMP_SUPPORT_BOSE_PROTOCOL == 1
2337 case IRMP_BOSE_PROTOCOL:
2338 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))
2339 {
2340 irmp_command &= 0xff;
2341 rtc = TRUE;
2342 }
2343 break;
2344 #endif
2345 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
2346 case IRMP_SIEMENS_PROTOCOL:
2347 case IRMP_RUWIDO_PROTOCOL:
2348 if (((irmp_command >> 1) & 0x0001) == (~irmp_command & 0x0001))
2349 {
2350 irmp_command >>= 1;
2351 rtc = TRUE;
2352 }
2353 break;
2354 #endif
2355 #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
2356 case IRMP_KATHREIN_PROTOCOL:
2357 if (irmp_command != 0x0000)
2358 {
2359 rtc = TRUE;
2360 }
2361 break;
2362 #endif
2363 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
2364 case IRMP_RC5_PROTOCOL:
2365 irmp_address &= ~0x20; // clear toggle bit
2366 rtc = TRUE;
2367 break;
2368 #endif
2369 #if IRMP_SUPPORT_S100_PROTOCOL == 1
2370 case IRMP_S100_PROTOCOL:
2371 irmp_address &= ~0x20; // clear toggle bit
2372 rtc = TRUE;
2373 break;
2374 #endif
2375 #if IRMP_SUPPORT_IR60_PROTOCOL == 1
2376 case IRMP_IR60_PROTOCOL:
2377 if (irmp_command != 0x007d) // 0x007d (== 62<<1 + 1) is start instruction frame
2378 {
2379 rtc = TRUE;
2380 }
2381 else
2382 {
2383 #ifdef ANALYZE
2384 ANALYZE_PRINTF("Info IR60: got start instruction frame\n");
2385 #endif // ANALYZE
2386 }
2387 break;
2388 #endif
2389 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
2390 case IRMP_RCCAR_PROTOCOL:
2391 // frame in irmp_data:
2392 // Bit 12 11 10 9 8 7 6 5 4 3 2 1 0
2393 // V D7 D6 D5 D4 D3 D2 D1 D0 A1 A0 C1 C0 // 10 9 8 7 6 5 4 3 2 1 0
2394 irmp_address = (irmp_command & 0x000C) >> 2; // addr: 0 0 0 0 0 0 0 0 0 A1 A0
2395 irmp_command = ((irmp_command & 0x1000) >> 2) | // V-Bit: V 0 0 0 0 0 0 0 0 0 0
2396 ((irmp_command & 0x0003) << 8) | // C-Bits: 0 C1 C0 0 0 0 0 0 0 0 0
2397 ((irmp_command & 0x0FF0) >> 4); // D-Bits: D7 D6 D5 D4 D3 D2 D1 D0
2398 rtc = TRUE; // Summe: V C1 C0 D7 D6 D5 D4 D3 D2 D1 D0
2399 break;
2400 #endif
2401
2402 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 // squeeze code to 8 bit, upper bit indicates release-key
2403 case IRMP_NETBOX_PROTOCOL:
2404 if (irmp_command & 0x1000) // last bit set?
2405 {
2406 if ((irmp_command & 0x1f) == 0x15) // key pressed: 101 01 (LSB)
2407 {
2408 irmp_command >>= 5;
2409 irmp_command &= 0x7F;
2410 rtc = TRUE;
2411 }
2412 else if ((irmp_command & 0x1f) == 0x10) // key released: 000 01 (LSB)
2413 {
2414 irmp_command >>= 5;
2415 irmp_command |= 0x80;
2416 rtc = TRUE;
2417 }
2418 else
2419 {
2420 #ifdef ANALYZE
2421 ANALYZE_PRINTF("error NETBOX: bit6/7 must be 0/1\n");
2422 #endif // ANALYZE
2423 }
2424 }
2425 else
2426 {
2427 #ifdef ANALYZE
2428 ANALYZE_PRINTF("error NETBOX: last bit not set\n");
2429 #endif // ANALYZE
2430 }
2431 break;
2432 #endif
2433 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1
2434 case IRMP_LEGO_PROTOCOL:
2435 {
2436 uint_fast8_t crc = 0x0F ^ ((irmp_command & 0xF000) >> 12) ^ ((irmp_command & 0x0F00) >> 8) ^ ((irmp_command & 0x00F0) >> 4);
2437
2438 if ((irmp_command & 0x000F) == crc)
2439 {
2440 irmp_command >>= 4;
2441 rtc = TRUE;
2442 }
2443 else
2444 {
2445 #ifdef ANALYZE
2446 ANALYZE_PRINTF ("CRC error in LEGO protocol\n");
2447 #endif // ANALYZE
2448 // rtc = TRUE; // don't accept codes with CRC errors
2449 }
2450 break;
2451 }
2452 #endif
2453
2454 default:
2455 {
2456 rtc = TRUE;
2457 break;
2458 }
2459 }
2460
2461 if (rtc)
2462 {
2463 irmp_data_p->protocol = irmp_protocol;
2464 irmp_data_p->address = irmp_address;
2465 irmp_data_p->command = irmp_command;
2466 irmp_data_p->flags = irmp_flags;
2467 irmp_command = 0;
2468 irmp_address = 0;
2469 irmp_flags = 0;
2470 }
2471
2472 irmp_ir_detected = FALSE;
2473 }
2474
2475 return rtc;
2476 }
2477
2478 #if IRMP_USE_CALLBACK == 1
2479 void
2480 irmp_set_callback_ptr (void (*cb)(uint_fast8_t))
2481 {
2482 irmp_callback_ptr = cb;
2483 }
2484 #endif // IRMP_USE_CALLBACK == 1
2485
2486 // these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR()
2487 static uint_fast16_t irmp_tmp_address; // ir address
2488 static uint_fast16_t irmp_tmp_command; // ir command
2489
2490 #if (IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)) || IRMP_SUPPORT_NEC42_PROTOCOL == 1
2491 static uint_fast16_t irmp_tmp_address2; // ir address
2492 static uint_fast16_t irmp_tmp_command2; // ir command
2493 #endif
2494
2495 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
2496 static uint_fast16_t irmp_lgair_address; // ir address
2497 static uint_fast16_t irmp_lgair_command; // ir command
2498 #endif
2499
2500 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2501 static uint_fast16_t irmp_tmp_id; // ir id (only SAMSUNG)
2502 #endif
2503 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2504 static uint8_t xor_check[6]; // check kaseikyo "parity" bits
2505 static uint_fast8_t genre2; // save genre2 bits here, later copied to MSB in flags
2506 #endif
2507
2508 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
2509 static uint_fast8_t parity; // number of '1' of the first 14 bits, check if even.
2510 #endif
2511
2512 #if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1
2513 static uint_fast8_t check; // number of '1' of the first 14 bits, check if even.
2514 static uint_fast8_t mitsu_parity; // number of '1' of the first 14 bits, check if even.
2515 #endif
2516
2517 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2518 * store bit
2519 * @details store bit in temp address or temp command
2520 * @param value to store: 0 or 1
2521 *---------------------------------------------------------------------------------------------------------------------------------------------------
2522 */
2523 // verhindert, dass irmp_store_bit() inline compiliert wird:
2524 // static void irmp_store_bit (uint_fast8_t) __attribute__ ((noinline));
2525
2526 static void
2527 irmp_store_bit (uint_fast8_t value)
2528 {
2529 #if IRMP_SUPPORT_ACP24_PROTOCOL == 1
2530 if (irmp_param.protocol == IRMP_ACP24_PROTOCOL) // squeeze 64 bits into 16 bits:
2531 {
2532 if (value)
2533 {
2534 // ACP24-Frame:
2535 // 1 2 3 4 5 6
2536 // 0123456789012345678901234567890123456789012345678901234567890123456789
2537 // N VVMMM ? ??? t vmA x y TTTT
2538 //
2539 // irmp_data_p->command:
2540 //
2541 // 5432109876543210
2542 // NAVVvMMMmtxyTTTT
2543
2544 switch (irmp_bit)
2545 {
2546 case 0: irmp_tmp_command |= (1<<15); break; // N
2547 case 2: irmp_tmp_command |= (1<<13); break; // V
2548 case 3: irmp_tmp_command |= (1<<12); break; // V
2549 case 4: irmp_tmp_command |= (1<<10); break; // M
2550 case 5: irmp_tmp_command |= (1<< 9); break; // M
2551 case 6: irmp_tmp_command |= (1<< 8); break; // M
2552 case 20: irmp_tmp_command |= (1<< 6); break; // t
2553 case 22: irmp_tmp_command |= (1<<11); break; // v
2554 case 23: irmp_tmp_command |= (1<< 7); break; // m
2555 case 24: irmp_tmp_command |= (1<<14); break; // A
2556 case 26: irmp_tmp_command |= (1<< 5); break; // x
2557 case 44: irmp_tmp_command |= (1<< 4); break; // y
2558 case 66: irmp_tmp_command |= (1<< 3); break; // T
2559 case 67: irmp_tmp_command |= (1<< 2); break; // T
2560 case 68: irmp_tmp_command |= (1<< 1); break; // T
2561 case 69: irmp_tmp_command |= (1<< 0); break; // T
2562 }
2563 }
2564 }
2565 else
2566 #endif // IRMP_SUPPORT_ACP24_PROTOCOL
2567
2568 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
2569 if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL)
2570 {
2571 if (irmp_bit < 14)
2572 {
2573 if (value)
2574 {
2575 parity++;
2576 }
2577 }
2578 else if (irmp_bit == 14)
2579 {
2580 if (value) // value == 1: even parity
2581 {
2582 if (parity & 0x01)
2583 {
2584 parity = PARITY_CHECK_FAILED;
2585 }
2586 else
2587 {
2588 parity = PARITY_CHECK_OK;
2589 }
2590 }
2591 else
2592 {
2593 if (parity & 0x01) // value == 0: odd parity
2594 {
2595 parity = PARITY_CHECK_OK;
2596 }
2597 else
2598 {
2599 parity = PARITY_CHECK_FAILED;
2600 }
2601 }
2602 }
2603 }
2604 else
2605 #endif
2606 {
2607 ;
2608 }
2609
2610 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
2611 if (irmp_bit == 0 && irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL)
2612 {
2613 first_bit = value;
2614 }
2615 else
2616 #endif
2617
2618 if (irmp_bit >= irmp_param.address_offset && irmp_bit < irmp_param.address_end)
2619 {
2620 if (irmp_param.lsb_first)
2621 {
2622 irmp_tmp_address |= (((uint_fast16_t) (value)) << (irmp_bit - irmp_param.address_offset)); // CV wants cast
2623 }
2624 else
2625 {
2626 irmp_tmp_address <<= 1;
2627 irmp_tmp_address |= value;
2628 }
2629 }
2630 else if (irmp_bit >= irmp_param.command_offset && irmp_bit < irmp_param.command_end)
2631 {
2632 if (irmp_param.lsb_first)
2633 {
2634 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1
2635 if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit >= 32)
2636 {
2637 irmp_tmp_id |= (((uint_fast16_t) (value)) << (irmp_bit - 32)); // CV wants cast
2638 }
2639 else
2640 #endif
2641 {
2642 irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast
2643 }
2644 }
2645 else
2646 {
2647 irmp_tmp_command <<= 1;
2648 irmp_tmp_command |= value;
2649 }
2650 }
2651
2652 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
2653 if (irmp_param.protocol == IRMP_NEC_PROTOCOL || irmp_param.protocol == IRMP_NEC42_PROTOCOL)
2654 {
2655 if (irmp_bit < 8)
2656 {
2657 irmp_lgair_address <<= 1; // LGAIR uses MSB
2658 irmp_lgair_address |= value;
2659 }
2660 else if (irmp_bit < 24)
2661 {
2662 irmp_lgair_command <<= 1; // LGAIR uses MSB
2663 irmp_lgair_command |= value;
2664 }
2665 }
2666 // NO else!
2667 #endif
2668
2669 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
2670 if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit >= 13 && irmp_bit < 26)
2671 {
2672 irmp_tmp_address2 |= (((uint_fast16_t) (value)) << (irmp_bit - 13)); // CV wants cast
2673 }
2674 else
2675 #endif
2676
2677 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2678 if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit >= SAMSUNG_ID_OFFSET && irmp_bit < SAMSUNG_ID_OFFSET + SAMSUNG_ID_LEN)
2679 {
2680 irmp_tmp_id |= (((uint_fast16_t) (value)) << (irmp_bit - SAMSUNG_ID_OFFSET)); // store with LSB first
2681 }
2682 else
2683 #endif
2684
2685 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2686 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)
2687 {
2688 if (irmp_bit >= 20 && irmp_bit < 24)
2689 {
2690 irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first
2691 }
2692 else if (irmp_bit >= 24 && irmp_bit < 28)
2693 {
2694 genre2 |= (((uint_fast8_t) (value)) << (irmp_bit - 20)); // store 4 system bits (genre 2) in upper nibble with LSB first
2695 }
2696
2697 if (irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)
2698 {
2699 if (value)
2700 {
2701 xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8);
2702 }
2703 else
2704 {
2705 xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8));
2706 }
2707 }
2708 }
2709 else
2710 #endif
2711
2712 #if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1
2713 if (irmp_param.protocol == IRMP_MITSU_HEAVY_PROTOCOL) // squeeze 64 bits into 16 bits:
2714 {
2715 if (irmp_bit == 72 )
2716 { // irmp_tmp_address, irmp_tmp_command received: check parity & compress
2717 mitsu_parity = PARITY_CHECK_OK;
2718
2719 check = irmp_tmp_address >> 8; // inverted upper byte == lower byte?
2720 check = ~ check;
2721
2722 if (check == (irmp_tmp_address & 0xFF))
2723 { // ok:
2724 irmp_tmp_address <<= 8; // throw away upper byte
2725 }
2726 else
2727 {
2728 mitsu_parity = PARITY_CHECK_FAILED;
2729 }
2730
2731 check = irmp_tmp_command >> 8; // inverted upper byte == lower byte?
2732 check = ~ check;
2733 if (check == (irmp_tmp_command & 0xFF))
2734 { // ok: pack together
2735 irmp_tmp_address |= irmp_tmp_command & 0xFF; // byte 1, byte2 in irmp_tmp_address, irmp_tmp_command can be used for byte 3
2736 }
2737 else
2738 {
2739 mitsu_parity = PARITY_CHECK_FAILED;
2740 }
2741 irmp_tmp_command = 0;
2742 }
2743
2744 if (irmp_bit >= 72 )
2745 { // receive 3. word in irmp_tmp_command
2746 irmp_tmp_command <<= 1;
2747 irmp_tmp_command |= value;
2748 }
2749 }
2750 else
2751 #endif // IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL
2752 {
2753 ;
2754 }
2755
2756 irmp_bit++;
2757 }
2758
2759 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2760 * store bit
2761 * @details store bit in temp address or temp command
2762 * @param value to store: 0 or 1
2763 *---------------------------------------------------------------------------------------------------------------------------------------------------
2764 */
2765 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2766 static void
2767 irmp_store_bit2 (uint_fast8_t value)
2768 {
2769 uint_fast8_t irmp_bit2;
2770
2771 if (irmp_param.protocol)
2772 {
2773 irmp_bit2 = irmp_bit - 2;
2774 }
2775 else
2776 {
2777 irmp_bit2 = irmp_bit - 1;
2778 }
2779
2780 if (irmp_bit2 >= irmp_param2.address_offset && irmp_bit2 < irmp_param2.address_end)
2781 {
2782 irmp_tmp_address2 |= (((uint_fast16_t) (value)) << (irmp_bit2 - irmp_param2.address_offset)); // CV wants cast
2783 }
2784 else if (irmp_bit2 >= irmp_param2.command_offset && irmp_bit2 < irmp_param2.command_end)
2785 {
2786 irmp_tmp_command2 |= (((uint_fast16_t) (value)) << (irmp_bit2 - irmp_param2.command_offset)); // CV wants cast
2787 }
2788 }
2789 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2790
2791 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2792 * ISR routine
2793 * @details ISR routine, called 10000 times per second
2794 *---------------------------------------------------------------------------------------------------------------------------------------------------
2795 */
2796 uint_fast8_t
2797 irmp_ISR (void)
2798 {
2799 static uint_fast8_t irmp_start_bit_detected; // flag: start bit detected
2800 static uint_fast8_t wait_for_space; // flag: wait for data bit space
2801 static uint_fast8_t wait_for_start_space; // flag: wait for start bit space
2802 static uint_fast8_t irmp_pulse_time; // count bit time for pulse
2803 static PAUSE_LEN irmp_pause_time; // count bit time for pause
2804 static uint_fast16_t last_irmp_address = 0xFFFF; // save last irmp address to recognize key repetition
2805 static uint_fast16_t last_irmp_command = 0xFFFF; // save last irmp command to recognize key repetition
2806 static uint_fast16_t key_repetition_len; // SIRCS repeats frame 2-5 times with 45 ms pause
2807 static uint_fast8_t repetition_frame_number;
2808 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
2809 static uint_fast16_t last_irmp_denon_command; // save last irmp command to recognize DENON frame repetition
2810 static uint_fast16_t denon_repetition_len = 0xFFFF; // denon repetition len of 2nd auto generated frame
2811 #endif
2812 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_S100_PROTOCOL == 1
2813 static uint_fast8_t rc5_cmd_bit6; // bit 6 of RC5 command is the inverted 2nd start bit
2814 #endif
2815 #if IRMP_SUPPORT_MANCHESTER == 1
2816 static PAUSE_LEN last_pause; // last pause value
2817 #endif
2818 #if IRMP_SUPPORT_MANCHESTER == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
2819 static uint_fast8_t last_value; // last bit value
2820 #endif
2821 uint_fast8_t irmp_input; // input value
2822
2823 #ifdef ANALYZE
2824 time_counter++;
2825 #endif // ANALYZE
2826
2827 #if defined(__SDCC_stm8)
2828 irmp_input = input(IRMP_GPIO_STRUCT->IDR)
2829 #elif defined(__MBED__)
2830 //irmp_input = inputPin;
2831 irmp_input = gpio_read (&gpioIRin);
2832 #else
2833 irmp_input = input(IRMP_PIN);
2834 #endif
2835
2836 #if IRMP_USE_CALLBACK == 1
2837 if (irmp_callback_ptr)
2838 {
2839 static uint_fast8_t last_inverted_input;
2840
2841 if (last_inverted_input != !irmp_input)
2842 {
2843 (*irmp_callback_ptr) (! irmp_input);
2844 last_inverted_input = !irmp_input;
2845 }
2846 }
2847 #endif // IRMP_USE_CALLBACK == 1
2848
2849 irmp_log(irmp_input); // log ir signal, if IRMP_LOGGING defined
2850
2851 if (! irmp_ir_detected) // ir code already detected?
2852 { // no...
2853 if (! irmp_start_bit_detected) // start bit detected?
2854 { // no...
2855 if (! irmp_input) // receiving burst?
2856 { // yes...
2857 // irmp_busy_flag = TRUE;
2858 #ifdef ANALYZE
2859 if (! irmp_pulse_time)
2860 {
2861 ANALYZE_PRINTF("%8.3fms [starting pulse]\n", (double) (time_counter * 1000) / F_INTERRUPTS);
2862 }
2863 #endif // ANALYZE
2864 irmp_pulse_time++; // increment counter
2865 }
2866 else
2867 { // no...
2868 if (irmp_pulse_time) // it's dark....
2869 { // set flags for counting the time of darkness...
2870 irmp_start_bit_detected = 1;
2871 wait_for_start_space = 1;
2872 wait_for_space = 0;
2873 irmp_tmp_command = 0;
2874 irmp_tmp_address = 0;
2875 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2876 genre2 = 0;
2877 #endif
2878 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2879 irmp_tmp_id = 0;
2880 #endif
2881
2882 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1
2883 irmp_tmp_command2 = 0;
2884 irmp_tmp_address2 = 0;
2885 #endif
2886 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
2887 irmp_lgair_command = 0;
2888 irmp_lgair_address = 0;
2889 #endif
2890 irmp_bit = 0xff;
2891 irmp_pause_time = 1; // 1st pause: set to 1, not to 0!
2892 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_S100_PROTOCOL == 1
2893 rc5_cmd_bit6 = 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame!
2894 #endif
2895 }
2896 else
2897 {
2898 if (key_repetition_len < 0xFFFF) // avoid overflow of counter
2899 {
2900 key_repetition_len++;
2901
2902 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
2903 if (denon_repetition_len < 0xFFFF) // avoid overflow of counter
2904 {
2905 denon_repetition_len++;
2906
2907 if (denon_repetition_len >= DENON_AUTO_REPETITION_PAUSE_LEN && last_irmp_denon_command != 0)
2908 {
2909 #ifdef ANALYZE
2910 ANALYZE_PRINTF ("%8.3fms warning: did not receive inverted command repetition\n",
2911 (double) (time_counter * 1000) / F_INTERRUPTS);
2912 #endif // ANALYZE
2913 last_irmp_denon_command = 0;
2914 denon_repetition_len = 0xFFFF;
2915 }
2916 }
2917 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
2918 }
2919 }
2920 }
2921 }
2922 else
2923 {
2924 if (wait_for_start_space) // we have received start bit...
2925 { // ...and are counting the time of darkness
2926 if (irmp_input) // still dark?
2927 { // yes
2928 irmp_pause_time++; // increment counter
2929
2930 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1
2931 if (((irmp_pulse_time < NIKON_START_BIT_PULSE_LEN_MIN || irmp_pulse_time > NIKON_START_BIT_PULSE_LEN_MAX) && irmp_pause_time > IRMP_TIMEOUT_LEN) ||
2932 irmp_pause_time > IRMP_TIMEOUT_NIKON_LEN)
2933 #else
2934 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?
2935 #endif
2936 { // yes...
2937 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2938 if (irmp_protocol == IRMP_JVC_PROTOCOL) // don't show eror if JVC protocol, irmp_pulse_time has been set below!
2939 {
2940 ;
2941 }
2942 else
2943 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2944 {
2945 #ifdef ANALYZE
2946 ANALYZE_PRINTF ("%8.3fms error 1: pause after start bit pulse %d too long: %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);
2947 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2948 #endif // ANALYZE
2949 }
2950
2951 irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit
2952 irmp_pulse_time = 0;
2953 irmp_pause_time = 0;
2954 }
2955 }
2956 else
2957 { // receiving first data pulse!
2958 IRMP_PARAMETER * irmp_param_p;
2959 irmp_param_p = (IRMP_PARAMETER *) 0;
2960
2961 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2962 irmp_param2.protocol = 0;
2963 #endif
2964
2965 #ifdef ANALYZE
2966 ANALYZE_PRINTF ("%8.3fms [start-bit: pulse = %2d, pause = %2d]\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);
2967 #endif // ANALYZE
2968
2969 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
2970 if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX &&
2971 irmp_pause_time >= SIRCS_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIRCS_START_BIT_PAUSE_LEN_MAX)
2972 { // it's SIRCS
2973 #ifdef ANALYZE
2974 ANALYZE_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2975 SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX,
2976 SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX);
2977 #endif // ANALYZE
2978 irmp_param_p = (IRMP_PARAMETER *) &sircs_param;
2979 }
2980 else
2981 #endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1
2982
2983 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2984 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame
2985 irmp_pulse_time >= JVC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= JVC_START_BIT_PULSE_LEN_MAX &&
2986 irmp_pause_time >= JVC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= JVC_REPEAT_START_BIT_PAUSE_LEN_MAX)
2987 {
2988 #ifdef ANALYZE
2989 ANALYZE_PRINTF ("protocol = NEC or JVC (type 1) repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2990 JVC_START_BIT_PULSE_LEN_MIN, JVC_START_BIT_PULSE_LEN_MAX,
2991 JVC_REPEAT_START_BIT_PAUSE_LEN_MIN, JVC_REPEAT_START_BIT_PAUSE_LEN_MAX);
2992 #endif // ANALYZE
2993 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
2994 }
2995 else
2996 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2997
2998 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2999 if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&
3000 irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)
3001 {
3002 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
3003 #ifdef ANALYZE
3004 ANALYZE_PRINTF ("protocol = NEC42, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3005 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
3006 NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);
3007 #endif // ANALYZE
3008 irmp_param_p = (IRMP_PARAMETER *) &nec42_param;
3009 #else
3010 #ifdef ANALYZE
3011 ANALYZE_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3012 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
3013 NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);
3014 #endif // ANALYZE
3015 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
3016 #endif
3017 }
3018 else if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&
3019 irmp_pause_time >= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX)
3020 { // it's NEC
3021 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
3022 if (irmp_protocol == IRMP_JVC_PROTOCOL) // last protocol was JVC, awaiting repeat frame
3023 { // some jvc remote controls use nec repetition frame for jvc repetition frame
3024 #ifdef ANALYZE
3025 ANALYZE_PRINTF ("protocol = JVC repeat frame type 2, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3026 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
3027 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);
3028 #endif // ANALYZE
3029 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
3030 }
3031 else
3032 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
3033 {
3034 #ifdef ANALYZE
3035 ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3036 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
3037 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);
3038 #endif // ANALYZE
3039
3040 irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param;
3041 }
3042 }
3043 else
3044
3045 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
3046 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame
3047 irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&
3048 irmp_pause_time >= NEC_0_PAUSE_LEN_MIN && irmp_pause_time <= NEC_0_PAUSE_LEN_MAX)
3049 { // it's JVC repetition type 3
3050 #ifdef ANALYZE
3051 ANALYZE_PRINTF ("protocol = JVC repeat frame type 3, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3052 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
3053 NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX);
3054 #endif // ANALYZE
3055 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
3056 }
3057 else
3058 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
3059
3060 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
3061
3062 #if IRMP_SUPPORT_TELEFUNKEN_PROTOCOL == 1
3063 if (irmp_pulse_time >= TELEFUNKEN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= TELEFUNKEN_START_BIT_PULSE_LEN_MAX &&
3064 irmp_pause_time >= TELEFUNKEN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= TELEFUNKEN_START_BIT_PAUSE_LEN_MAX)
3065 {
3066 #ifdef ANALYZE
3067 ANALYZE_PRINTF ("protocol = TELEFUNKEN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3068 TELEFUNKEN_START_BIT_PULSE_LEN_MIN, TELEFUNKEN_START_BIT_PULSE_LEN_MAX,
3069 TELEFUNKEN_START_BIT_PAUSE_LEN_MIN, TELEFUNKEN_START_BIT_PAUSE_LEN_MAX);
3070 #endif // ANALYZE
3071 irmp_param_p = (IRMP_PARAMETER *) &telefunken_param;
3072 }
3073 else
3074 #endif // IRMP_SUPPORT_TELEFUNKEN_PROTOCOL == 1
3075
3076 #if IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
3077 if (irmp_pulse_time >= ROOMBA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_START_BIT_PULSE_LEN_MAX &&
3078 irmp_pause_time >= ROOMBA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ROOMBA_START_BIT_PAUSE_LEN_MAX)
3079 {
3080 #ifdef ANALYZE
3081 ANALYZE_PRINTF ("protocol = ROOMBA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3082 ROOMBA_START_BIT_PULSE_LEN_MIN, ROOMBA_START_BIT_PULSE_LEN_MAX,
3083 ROOMBA_START_BIT_PAUSE_LEN_MIN, ROOMBA_START_BIT_PAUSE_LEN_MAX);
3084 #endif // ANALYZE
3085 irmp_param_p = (IRMP_PARAMETER *) &roomba_param;
3086 }
3087 else
3088 #endif // IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
3089
3090 #if IRMP_SUPPORT_ACP24_PROTOCOL == 1
3091 if (irmp_pulse_time >= ACP24_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ACP24_START_BIT_PULSE_LEN_MAX &&
3092 irmp_pause_time >= ACP24_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ACP24_START_BIT_PAUSE_LEN_MAX)
3093 {
3094 #ifdef ANALYZE
3095 ANALYZE_PRINTF ("protocol = ACP24, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3096 ACP24_START_BIT_PULSE_LEN_MIN, ACP24_START_BIT_PULSE_LEN_MAX,
3097 ACP24_START_BIT_PAUSE_LEN_MIN, ACP24_START_BIT_PAUSE_LEN_MAX);
3098 #endif // ANALYZE
3099 irmp_param_p = (IRMP_PARAMETER *) &acp24_param;
3100 }
3101 else
3102 #endif // IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
3103
3104 #if IRMP_SUPPORT_PENTAX_PROTOCOL == 1
3105 if (irmp_pulse_time >= PENTAX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= PENTAX_START_BIT_PULSE_LEN_MAX &&
3106 irmp_pause_time >= PENTAX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= PENTAX_START_BIT_PAUSE_LEN_MAX)
3107 {
3108 #ifdef ANALYZE
3109 ANALYZE_PRINTF ("protocol = PENTAX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3110 PENTAX_START_BIT_PULSE_LEN_MIN, PENTAX_START_BIT_PULSE_LEN_MAX,
3111 PENTAX_START_BIT_PAUSE_LEN_MIN, PENTAX_START_BIT_PAUSE_LEN_MAX);
3112 #endif // ANALYZE
3113 irmp_param_p = (IRMP_PARAMETER *) &pentax_param;
3114 }
3115 else
3116 #endif // IRMP_SUPPORT_PENTAX_PROTOCOL == 1
3117
3118 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1
3119 if (irmp_pulse_time >= NIKON_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NIKON_START_BIT_PULSE_LEN_MAX &&
3120 irmp_pause_time >= NIKON_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NIKON_START_BIT_PAUSE_LEN_MAX)
3121 {
3122 #ifdef ANALYZE
3123 ANALYZE_PRINTF ("protocol = NIKON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3124 NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX,
3125 NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX);
3126 #endif // ANALYZE
3127 irmp_param_p = (IRMP_PARAMETER *) &nikon_param;
3128 }
3129 else
3130 #endif // IRMP_SUPPORT_NIKON_PROTOCOL == 1
3131
3132 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
3133 if (irmp_pulse_time >= SAMSUNG_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_START_BIT_PULSE_LEN_MAX &&
3134 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)
3135 { // it's SAMSUNG
3136 #ifdef ANALYZE
3137 ANALYZE_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3138 SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX,
3139 SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX);
3140 #endif // ANALYZE
3141 irmp_param_p = (IRMP_PARAMETER *) &samsung_param;
3142 }
3143 else
3144 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
3145
3146 #if IRMP_SUPPORT_SAMSUNGAH_PROTOCOL == 1
3147 if (irmp_pulse_time >= SAMSUNGAH_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNGAH_START_BIT_PULSE_LEN_MAX &&
3148 irmp_pause_time >= SAMSUNGAH_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNGAH_START_BIT_PAUSE_LEN_MAX)
3149 { // it's SAMSUNGAH
3150 #ifdef ANALYZE
3151 ANALYZE_PRINTF ("protocol = SAMSUNGAH, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3152 SAMSUNGAH_START_BIT_PULSE_LEN_MIN, SAMSUNGAH_START_BIT_PULSE_LEN_MAX,
3153 SAMSUNGAH_START_BIT_PAUSE_LEN_MIN, SAMSUNGAH_START_BIT_PAUSE_LEN_MAX);
3154 #endif // ANALYZE
3155 irmp_param_p = (IRMP_PARAMETER *) &samsungah_param;
3156 }
3157 else
3158 #endif // IRMP_SUPPORT_SAMSUNGAH_PROTOCOL == 1
3159
3160 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
3161 if (irmp_pulse_time >= MATSUSHITA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MATSUSHITA_START_BIT_PULSE_LEN_MAX &&
3162 irmp_pause_time >= MATSUSHITA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MATSUSHITA_START_BIT_PAUSE_LEN_MAX)
3163 { // it's MATSUSHITA
3164 #ifdef ANALYZE
3165 ANALYZE_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3166 MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX,
3167 MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX);
3168 #endif // ANALYZE
3169 irmp_param_p = (IRMP_PARAMETER *) &matsushita_param;
3170 }
3171 else
3172 #endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
3173
3174 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
3175 if (irmp_pulse_time >= KASEIKYO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KASEIKYO_START_BIT_PULSE_LEN_MAX &&
3176 irmp_pause_time >= KASEIKYO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KASEIKYO_START_BIT_PAUSE_LEN_MAX)
3177 { // it's KASEIKYO
3178 #ifdef ANALYZE
3179 ANALYZE_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3180 KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX,
3181 KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX);
3182 #endif // ANALYZE
3183 irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param;
3184 }
3185 else
3186 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
3187
3188 #if IRMP_SUPPORT_PANASONIC_PROTOCOL == 1
3189 if (irmp_pulse_time >= PANASONIC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= PANASONIC_START_BIT_PULSE_LEN_MAX &&
3190 irmp_pause_time >= PANASONIC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= PANASONIC_START_BIT_PAUSE_LEN_MAX)
3191 { // it's PANASONIC
3192 #ifdef ANALYZE
3193 ANALYZE_PRINTF ("protocol = PANASONIC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3194 PANASONIC_START_BIT_PULSE_LEN_MIN, PANASONIC_START_BIT_PULSE_LEN_MAX,
3195 PANASONIC_START_BIT_PAUSE_LEN_MIN, PANASONIC_START_BIT_PAUSE_LEN_MAX);
3196 #endif // ANALYZE
3197 irmp_param_p = (IRMP_PARAMETER *) &panasonic_param;
3198 }
3199 else
3200 #endif // IRMP_SUPPORT_PANASONIC_PROTOCOL == 1
3201
3202 #if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1
3203 if (irmp_pulse_time >= MITSU_HEAVY_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MITSU_HEAVY_START_BIT_PULSE_LEN_MAX &&
3204 irmp_pause_time >= MITSU_HEAVY_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MITSU_HEAVY_START_BIT_PAUSE_LEN_MAX)
3205 { // it's MITSU_HEAVY
3206 #ifdef ANALYZE
3207 ANALYZE_PRINTF ("protocol = MITSU_HEAVY, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3208 MITSU_HEAVY_START_BIT_PULSE_LEN_MIN, MITSU_HEAVY_START_BIT_PULSE_LEN_MAX,
3209 MITSU_HEAVY_START_BIT_PAUSE_LEN_MIN, MITSU_HEAVY_START_BIT_PAUSE_LEN_MAX);
3210 #endif // ANALYZE
3211 irmp_param_p = (IRMP_PARAMETER *) &mitsu_heavy_param;
3212 }
3213 else
3214 #endif // IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1
3215
3216 #if IRMP_SUPPORT_VINCENT_PROTOCOL == 1
3217 if (irmp_pulse_time >= VINCENT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= VINCENT_START_BIT_PULSE_LEN_MAX &&
3218 irmp_pause_time >= VINCENT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= VINCENT_START_BIT_PAUSE_LEN_MAX)
3219 { // it's VINCENT
3220 #ifdef ANALYZE
3221 ANALYZE_PRINTF ("protocol = VINCENT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3222 VINCENT_START_BIT_PULSE_LEN_MIN, VINCENT_START_BIT_PULSE_LEN_MAX,
3223 VINCENT_START_BIT_PAUSE_LEN_MIN, VINCENT_START_BIT_PAUSE_LEN_MAX);
3224 #endif // ANALYZE
3225 irmp_param_p = (IRMP_PARAMETER *) &vincent_param;
3226 }
3227 else
3228 #endif // IRMP_SUPPORT_VINCENT_PROTOCOL == 1
3229
3230 #if IRMP_SUPPORT_RADIO1_PROTOCOL == 1
3231 if (irmp_pulse_time >= RADIO1_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RADIO1_START_BIT_PULSE_LEN_MAX &&
3232 irmp_pause_time >= RADIO1_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RADIO1_START_BIT_PAUSE_LEN_MAX)
3233 {
3234 #ifdef ANALYZE
3235 ANALYZE_PRINTF ("protocol = RADIO1, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3236 RADIO1_START_BIT_PULSE_LEN_MIN, RADIO1_START_BIT_PULSE_LEN_MAX,
3237 RADIO1_START_BIT_PAUSE_LEN_MIN, RADIO1_START_BIT_PAUSE_LEN_MAX);
3238 #endif // ANALYZE
3239 irmp_param_p = (IRMP_PARAMETER *) &radio1_param;
3240 }
3241 else
3242 #endif // IRMP_SUPPORT_RRADIO1_PROTOCOL == 1
3243
3244 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
3245 if (irmp_pulse_time >= RECS80_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80_START_BIT_PULSE_LEN_MAX &&
3246 irmp_pause_time >= RECS80_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80_START_BIT_PAUSE_LEN_MAX)
3247 { // it's RECS80
3248 #ifdef ANALYZE
3249 ANALYZE_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3250 RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX,
3251 RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX);
3252 #endif // ANALYZE
3253 irmp_param_p = (IRMP_PARAMETER *) &recs80_param;
3254 }
3255 else
3256 #endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1
3257
3258 #if IRMP_SUPPORT_S100_PROTOCOL == 1
3259 if (((irmp_pulse_time >= S100_START_BIT_LEN_MIN && irmp_pulse_time <= S100_START_BIT_LEN_MAX) ||
3260 (irmp_pulse_time >= 2 * S100_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * S100_START_BIT_LEN_MAX)) &&
3261 ((irmp_pause_time >= S100_START_BIT_LEN_MIN && irmp_pause_time <= S100_START_BIT_LEN_MAX) ||
3262 (irmp_pause_time >= 2 * S100_START_BIT_LEN_MIN && irmp_pause_time <= 2 * S100_START_BIT_LEN_MAX)))
3263 { // it's S100
3264 #ifdef ANALYZE
3265 ANALYZE_PRINTF ("protocol = S100, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n",
3266 S100_START_BIT_LEN_MIN, S100_START_BIT_LEN_MAX,
3267 2 * S100_START_BIT_LEN_MIN, 2 * S100_START_BIT_LEN_MAX,
3268 S100_START_BIT_LEN_MIN, S100_START_BIT_LEN_MAX,
3269 2 * S100_START_BIT_LEN_MIN, 2 * S100_START_BIT_LEN_MAX);
3270 #endif // ANALYZE
3271
3272 irmp_param_p = (IRMP_PARAMETER *) &s100_param;
3273 last_pause = irmp_pause_time;
3274
3275 if ((irmp_pulse_time > S100_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * S100_START_BIT_LEN_MAX) ||
3276 (irmp_pause_time > S100_START_BIT_LEN_MAX && irmp_pause_time <= 2 * S100_START_BIT_LEN_MAX))
3277 {
3278 last_value = 0;
3279 rc5_cmd_bit6 = 1<<6;
3280 }
3281 else
3282 {
3283 last_value = 1;
3284 }
3285 }
3286 else
3287 #endif // IRMP_SUPPORT_S100_PROTOCOL == 1
3288
3289 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
3290 if (((irmp_pulse_time >= RC5_START_BIT_LEN_MIN && irmp_pulse_time <= RC5_START_BIT_LEN_MAX) ||
3291 (irmp_pulse_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX)) &&
3292 ((irmp_pause_time >= RC5_START_BIT_LEN_MIN && irmp_pause_time <= RC5_START_BIT_LEN_MAX) ||
3293 (irmp_pause_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)))
3294 { // it's RC5
3295 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
3296 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&
3297 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)
3298 {
3299 #ifdef ANALYZE
3300 ANALYZE_PRINTF ("protocol = RC5 or FDC\n");
3301 ANALYZE_PRINTF ("FDC start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3302 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,
3303 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);
3304 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3305 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
3306 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);
3307 #endif // ANALYZE
3308 memcpy_P (&irmp_param2, &fdc_param, sizeof (IRMP_PARAMETER));
3309 }
3310 else
3311 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
3312
3313 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
3314 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&
3315 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)
3316 {
3317 #ifdef ANALYZE
3318 ANALYZE_PRINTF ("protocol = RC5 or RCCAR\n");
3319 ANALYZE_PRINTF ("RCCAR start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3320 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,
3321 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);
3322 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3323 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
3324 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);
3325 #endif // ANALYZE
3326 memcpy_P (&irmp_param2, &rccar_param, sizeof (IRMP_PARAMETER));
3327 }
3328 else
3329 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
3330 {
3331 #ifdef ANALYZE
3332 ANALYZE_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n",
3333 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
3334 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX,
3335 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
3336 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX);
3337 #endif // ANALYZE
3338 }
3339
3340 irmp_param_p = (IRMP_PARAMETER *) &rc5_param;
3341 last_pause = irmp_pause_time;
3342
3343 if ((irmp_pulse_time > RC5_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX) ||
3344 (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX))
3345 {
3346 last_value = 0;
3347 rc5_cmd_bit6 = 1<<6;
3348 }
3349 else
3350 {
3351 last_value = 1;
3352 }
3353 }
3354 else
3355 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1
3356
3357 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
3358 if ( (irmp_pulse_time >= DENON_PULSE_LEN_MIN && irmp_pulse_time <= DENON_PULSE_LEN_MAX) &&
3359 ((irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) ||
3360 (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)))
3361 { // it's DENON
3362 #ifdef ANALYZE
3363 ANALYZE_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
3364 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX,
3365 DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX,
3366 DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX);
3367 #endif // ANALYZE
3368 irmp_param_p = (IRMP_PARAMETER *) &denon_param;
3369 }
3370 else
3371 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
3372
3373 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1
3374 if ( (irmp_pulse_time >= THOMSON_PULSE_LEN_MIN && irmp_pulse_time <= THOMSON_PULSE_LEN_MAX) &&
3375 ((irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX) ||
3376 (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)))
3377 { // it's THOMSON
3378 #ifdef ANALYZE
3379 ANALYZE_PRINTF ("protocol = THOMSON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
3380 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX,
3381 THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX,
3382 THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX);
3383 #endif // ANALYZE
3384 irmp_param_p = (IRMP_PARAMETER *) &thomson_param;
3385 }
3386 else
3387 #endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1
3388
3389 #if IRMP_SUPPORT_BOSE_PROTOCOL == 1
3390 if (irmp_pulse_time >= BOSE_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= BOSE_START_BIT_PULSE_LEN_MAX &&
3391 irmp_pause_time >= BOSE_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BOSE_START_BIT_PAUSE_LEN_MAX)
3392 {
3393 #ifdef ANALYZE
3394 ANALYZE_PRINTF ("protocol = BOSE, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3395 BOSE_START_BIT_PULSE_LEN_MIN, BOSE_START_BIT_PULSE_LEN_MAX,
3396 BOSE_START_BIT_PAUSE_LEN_MIN, BOSE_START_BIT_PAUSE_LEN_MAX);
3397 #endif // ANALYZE
3398 irmp_param_p = (IRMP_PARAMETER *) &bose_param;
3399 }
3400 else
3401 #endif // IRMP_SUPPORT_BOSE_PROTOCOL == 1
3402
3403 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
3404 if (irmp_pulse_time >= RC6_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RC6_START_BIT_PULSE_LEN_MAX &&
3405 irmp_pause_time >= RC6_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RC6_START_BIT_PAUSE_LEN_MAX)
3406 { // it's RC6
3407 #ifdef ANALYZE
3408 ANALYZE_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3409 RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX,
3410 RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX);
3411 #endif // ANALYZE
3412 irmp_param_p = (IRMP_PARAMETER *) &rc6_param;
3413 last_pause = 0;
3414 last_value = 1;
3415 }
3416 else
3417 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
3418
3419 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
3420 if (irmp_pulse_time >= RECS80EXT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80EXT_START_BIT_PULSE_LEN_MAX &&
3421 irmp_pause_time >= RECS80EXT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80EXT_START_BIT_PAUSE_LEN_MAX)
3422 { // it's RECS80EXT
3423 #ifdef ANALYZE
3424 ANALYZE_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3425 RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX,
3426 RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX);
3427 #endif // ANALYZE
3428 irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param;
3429 }
3430 else
3431 #endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
3432
3433 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
3434 if (irmp_pulse_time >= NUBERT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NUBERT_START_BIT_PULSE_LEN_MAX &&
3435 irmp_pause_time >= NUBERT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NUBERT_START_BIT_PAUSE_LEN_MAX)
3436 { // it's NUBERT
3437 #ifdef ANALYZE
3438 ANALYZE_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3439 NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX,
3440 NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX);
3441 #endif // ANALYZE
3442 irmp_param_p = (IRMP_PARAMETER *) &nubert_param;
3443 }
3444 else
3445 #endif // IRMP_SUPPORT_NUBERT_PROTOCOL == 1
3446
3447 #if IRMP_SUPPORT_FAN_PROTOCOL == 1
3448 if (irmp_pulse_time >= FAN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FAN_START_BIT_PULSE_LEN_MAX &&
3449 irmp_pause_time >= FAN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FAN_START_BIT_PAUSE_LEN_MAX)
3450 { // it's FAN
3451 #ifdef ANALYZE
3452 ANALYZE_PRINTF ("protocol = FAN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3453 FAN_START_BIT_PULSE_LEN_MIN, FAN_START_BIT_PULSE_LEN_MAX,
3454 FAN_START_BIT_PAUSE_LEN_MIN, FAN_START_BIT_PAUSE_LEN_MAX);
3455 #endif // ANALYZE
3456 irmp_param_p = (IRMP_PARAMETER *) &fan_param;
3457 }
3458 else
3459 #endif // IRMP_SUPPORT_FAN_PROTOCOL == 1
3460
3461 #if IRMP_SUPPORT_SPEAKER_PROTOCOL == 1
3462 if (irmp_pulse_time >= SPEAKER_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SPEAKER_START_BIT_PULSE_LEN_MAX &&
3463 irmp_pause_time >= SPEAKER_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SPEAKER_START_BIT_PAUSE_LEN_MAX)
3464 { // it's SPEAKER
3465 #ifdef ANALYZE
3466 ANALYZE_PRINTF ("protocol = SPEAKER, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3467 SPEAKER_START_BIT_PULSE_LEN_MIN, SPEAKER_START_BIT_PULSE_LEN_MAX,
3468 SPEAKER_START_BIT_PAUSE_LEN_MIN, SPEAKER_START_BIT_PAUSE_LEN_MAX);
3469 #endif // ANALYZE
3470 irmp_param_p = (IRMP_PARAMETER *) &speaker_param;
3471 }
3472 else
3473 #endif // IRMP_SUPPORT_SPEAKER_PROTOCOL == 1
3474
3475 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
3476 if (irmp_pulse_time >= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX &&
3477 irmp_pause_time >= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX)
3478 { // it's BANG_OLUFSEN
3479 #ifdef ANALYZE
3480 ANALYZE_PRINTF ("protocol = BANG_OLUFSEN\n");
3481 ANALYZE_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3482 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,
3483 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);
3484 ANALYZE_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3485 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,
3486 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);
3487 ANALYZE_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3488 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,
3489 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);
3490 ANALYZE_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3491 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX,
3492 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX);
3493 #endif // ANALYZE
3494 irmp_param_p = (IRMP_PARAMETER *) &bang_olufsen_param;
3495 last_value = 0;
3496 }
3497 else
3498 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
3499
3500 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
3501 if (irmp_pulse_time >= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX &&
3502 irmp_pause_time >= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX)
3503 { // it's GRUNDIG
3504 #ifdef ANALYZE
3505 ANALYZE_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3506 GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX,
3507 GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX);
3508 #endif // ANALYZE
3509 irmp_param_p = (IRMP_PARAMETER *) &grundig_param;
3510 last_pause = irmp_pause_time;
3511 last_value = 1;
3512 }
3513 else
3514 #endif // IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
3515
3516 #if IRMP_SUPPORT_MERLIN_PROTOCOL == 1 // check MERLIN before RUWIDO!
3517 if (irmp_pulse_time >= MERLIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MERLIN_START_BIT_PULSE_LEN_MAX &&
3518 irmp_pause_time >= MERLIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MERLIN_START_BIT_PAUSE_LEN_MAX)
3519 { // it's MERLIN
3520 #ifdef ANALYZE
3521 ANALYZE_PRINTF ("protocol = MERLIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3522 MERLIN_START_BIT_PULSE_LEN_MIN, MERLIN_START_BIT_PULSE_LEN_MAX,
3523 MERLIN_START_BIT_PAUSE_LEN_MIN, MERLIN_START_BIT_PAUSE_LEN_MAX);
3524 #endif // ANALYZE
3525 irmp_param_p = (IRMP_PARAMETER *) &merlin_param;
3526 last_pause = 0;
3527 last_value = 1;
3528 }
3529 else
3530 #endif // IRMP_SUPPORT_MERLIN_PROTOCOL == 1
3531
3532 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
3533 if (((irmp_pulse_time >= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX) ||
3534 (irmp_pulse_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX)) &&
3535 ((irmp_pause_time >= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX) ||
3536 (irmp_pause_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX)))
3537 { // it's RUWIDO or SIEMENS
3538 #ifdef ANALYZE
3539 ANALYZE_PRINTF ("protocol = RUWIDO, start bit timings: pulse: %3d - %3d or %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
3540 SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,
3541 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,
3542 SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX,
3543 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX);
3544 #endif // ANALYZE
3545 irmp_param_p = (IRMP_PARAMETER *) &ruwido_param;
3546 last_pause = irmp_pause_time;
3547 last_value = 1;
3548 }
3549 else
3550 #endif // IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
3551
3552 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
3553 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&
3554 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)
3555 {
3556 #ifdef ANALYZE
3557 ANALYZE_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3558 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,
3559 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);
3560 #endif // ANALYZE
3561 irmp_param_p = (IRMP_PARAMETER *) &fdc_param;
3562 }
3563 else
3564 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
3565
3566 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
3567 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&
3568 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)
3569 {
3570 #ifdef ANALYZE
3571 ANALYZE_PRINTF ("protocol = RCCAR, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3572 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,
3573 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);
3574 #endif // ANALYZE
3575 irmp_param_p = (IRMP_PARAMETER *) &rccar_param;
3576 }
3577 else
3578 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
3579
3580 #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
3581 if (irmp_pulse_time >= KATHREIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_START_BIT_PULSE_LEN_MAX &&
3582 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)
3583 { // it's KATHREIN
3584 #ifdef ANALYZE
3585 ANALYZE_PRINTF ("protocol = KATHREIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3586 KATHREIN_START_BIT_PULSE_LEN_MIN, KATHREIN_START_BIT_PULSE_LEN_MAX,
3587 KATHREIN_START_BIT_PAUSE_LEN_MIN, KATHREIN_START_BIT_PAUSE_LEN_MAX);
3588 #endif // ANALYZE
3589 irmp_param_p = (IRMP_PARAMETER *) &kathrein_param;
3590 }
3591 else
3592 #endif // IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
3593
3594 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1
3595 if (irmp_pulse_time >= NETBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NETBOX_START_BIT_PULSE_LEN_MAX &&
3596 irmp_pause_time >= NETBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NETBOX_START_BIT_PAUSE_LEN_MAX)
3597 { // it's NETBOX
3598 #ifdef ANALYZE
3599 ANALYZE_PRINTF ("protocol = NETBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3600 NETBOX_START_BIT_PULSE_LEN_MIN, NETBOX_START_BIT_PULSE_LEN_MAX,
3601 NETBOX_START_BIT_PAUSE_LEN_MIN, NETBOX_START_BIT_PAUSE_LEN_MAX);
3602 #endif // ANALYZE
3603 irmp_param_p = (IRMP_PARAMETER *) &netbox_param;
3604 }
3605 else
3606 #endif // IRMP_SUPPORT_NETBOX_PROTOCOL == 1
3607
3608 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1
3609 if (irmp_pulse_time >= LEGO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= LEGO_START_BIT_PULSE_LEN_MAX &&
3610 irmp_pause_time >= LEGO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= LEGO_START_BIT_PAUSE_LEN_MAX)
3611 {
3612 #ifdef ANALYZE
3613 ANALYZE_PRINTF ("protocol = LEGO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3614 LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX,
3615 LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX);
3616 #endif // ANALYZE
3617 irmp_param_p = (IRMP_PARAMETER *) &lego_param;
3618 }
3619 else
3620 #endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1
3621
3622 #if IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1
3623 if (irmp_pulse_time >= A1TVBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= A1TVBOX_START_BIT_PULSE_LEN_MAX &&
3624 irmp_pause_time >= A1TVBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= A1TVBOX_START_BIT_PAUSE_LEN_MAX)
3625 { // it's A1TVBOX
3626 #ifdef ANALYZE
3627 ANALYZE_PRINTF ("protocol = A1TVBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3628 A1TVBOX_START_BIT_PULSE_LEN_MIN, A1TVBOX_START_BIT_PULSE_LEN_MAX,
3629 A1TVBOX_START_BIT_PAUSE_LEN_MIN, A1TVBOX_START_BIT_PAUSE_LEN_MAX);
3630 #endif // ANALYZE
3631 irmp_param_p = (IRMP_PARAMETER *) &a1tvbox_param;
3632 last_pause = 0;
3633 last_value = 1;
3634 }
3635 else
3636 #endif // IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1
3637
3638 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
3639 if (irmp_pulse_time >= ORTEK_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ORTEK_START_BIT_PULSE_LEN_MAX &&
3640 irmp_pause_time >= ORTEK_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ORTEK_START_BIT_PAUSE_LEN_MAX)
3641 { // it's ORTEK (Hama)
3642 #ifdef ANALYZE
3643 ANALYZE_PRINTF ("protocol = ORTEK, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3644 ORTEK_START_BIT_PULSE_LEN_MIN, ORTEK_START_BIT_PULSE_LEN_MAX,
3645 ORTEK_START_BIT_PAUSE_LEN_MIN, ORTEK_START_BIT_PAUSE_LEN_MAX);
3646 #endif // ANALYZE
3647 irmp_param_p = (IRMP_PARAMETER *) &ortek_param;
3648 last_pause = 0;
3649 last_value = 1;
3650 parity = 0;
3651 }
3652 else
3653 #endif // IRMP_SUPPORT_ORTEK_PROTOCOL == 1
3654
3655 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1
3656 if (irmp_pulse_time >= RCMM32_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCMM32_START_BIT_PULSE_LEN_MAX &&
3657 irmp_pause_time >= RCMM32_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_START_BIT_PAUSE_LEN_MAX)
3658 { // it's RCMM
3659 #ifdef ANALYZE
3660 ANALYZE_PRINTF ("protocol = RCMM, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3661 RCMM32_START_BIT_PULSE_LEN_MIN, RCMM32_START_BIT_PULSE_LEN_MAX,
3662 RCMM32_START_BIT_PAUSE_LEN_MIN, RCMM32_START_BIT_PAUSE_LEN_MAX);
3663 #endif // ANALYZE
3664 irmp_param_p = (IRMP_PARAMETER *) &rcmm_param;
3665 }
3666 else
3667 #endif // IRMP_SUPPORT_RCMM_PROTOCOL == 1
3668 {
3669 #ifdef ANALYZE
3670 ANALYZE_PRINTF ("protocol = UNKNOWN\n");
3671 #endif // ANALYZE
3672 irmp_start_bit_detected = 0; // wait for another start bit...
3673 }
3674
3675 if (irmp_start_bit_detected)
3676 {
3677 memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER));
3678
3679 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))
3680 {
3681 #ifdef ANALYZE
3682 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max);
3683 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max);
3684 #endif // ANALYZE
3685 }
3686 else
3687 {
3688 #ifdef ANALYZE
3689 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max,
3690 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max);
3691 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max,
3692 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max);
3693 #endif // ANALYZE
3694 }
3695
3696 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
3697 if (irmp_param2.protocol)
3698 {
3699 #ifdef ANALYZE
3700 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param2.pulse_0_len_min, irmp_param2.pulse_0_len_max);
3701 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param2.pause_0_len_min, irmp_param2.pause_0_len_max);
3702 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param2.pulse_1_len_min, irmp_param2.pulse_1_len_max);
3703 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param2.pause_1_len_min, irmp_param2.pause_1_len_max);
3704 #endif // ANALYZE
3705 }
3706 #endif
3707
3708
3709 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
3710 if (irmp_param.protocol == IRMP_RC6_PROTOCOL)
3711 {
3712 #ifdef ANALYZE
3713 ANALYZE_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX);
3714 #endif // ANALYZE
3715 }
3716 #endif
3717
3718 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))
3719 {
3720 #ifdef ANALYZE
3721 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);
3722 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max);
3723 #endif // ANALYZE
3724 }
3725 else
3726 {
3727 #ifdef ANALYZE
3728 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max,
3729 2 * irmp_param.pulse_0_len_min, 2 * irmp_param.pulse_0_len_max);
3730 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max,
3731 2 * irmp_param.pause_0_len_min, 2 * irmp_param.pause_0_len_max);
3732 #endif // ANALYZE
3733 }
3734
3735 #ifdef ANALYZE
3736 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
3737 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)
3738 {
3739 ANALYZE_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);
3740 ANALYZE_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX);
3741 }
3742 #endif
3743
3744 ANALYZE_PRINTF ("command_offset: %2d\n", irmp_param.command_offset);
3745 ANALYZE_PRINTF ("command_len: %3d\n", irmp_param.command_end - irmp_param.command_offset);
3746 ANALYZE_PRINTF ("complete_len: %3d\n", irmp_param.complete_len);
3747 ANALYZE_PRINTF ("stop_bit: %3d\n", irmp_param.stop_bit);
3748 #endif // ANALYZE
3749 }
3750
3751 irmp_bit = 0;
3752
3753 #if IRMP_SUPPORT_MANCHESTER == 1
3754 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&
3755 irmp_param.protocol != IRMP_RUWIDO_PROTOCOL && // Manchester, but not RUWIDO
3756 irmp_param.protocol != IRMP_RC6_PROTOCOL) // Manchester, but not RC6
3757 {
3758 if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max)
3759 {
3760 #ifdef ANALYZE
3761 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
3762 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');
3763 ANALYZE_NEWLINE ();
3764 #endif // ANALYZE
3765 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1);
3766 }
3767 else if (! last_value) // && irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)
3768 {
3769 #ifdef ANALYZE
3770 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
3771 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');
3772 ANALYZE_NEWLINE ();
3773 #endif // ANALYZE
3774 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0);
3775 }
3776 }
3777 else
3778 #endif // IRMP_SUPPORT_MANCHESTER == 1
3779
3780 #if IRMP_SUPPORT_SERIAL == 1
3781 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)
3782 {
3783 ; // do nothing
3784 }
3785 else
3786 #endif // IRMP_SUPPORT_SERIAL == 1
3787
3788
3789 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
3790 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)
3791 {
3792 #ifdef ANALYZE
3793 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
3794 #endif // ANALYZE
3795
3796 if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX)
3797 { // pause timings correct for "1"?
3798 #ifdef ANALYZE
3799 ANALYZE_PUTCHAR ('1'); // yes, store 1
3800 ANALYZE_NEWLINE ();
3801 #endif // ANALYZE
3802 irmp_store_bit (1);
3803 }
3804 else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)
3805 { // pause timings correct for "0"?
3806 #ifdef ANALYZE
3807 ANALYZE_PUTCHAR ('0'); // yes, store 0
3808 ANALYZE_NEWLINE ();
3809 #endif // ANALYZE
3810 irmp_store_bit (0);
3811 }
3812 }
3813 else
3814 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
3815 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1
3816 if (irmp_param.protocol == IRMP_THOMSON_PROTOCOL)
3817 {
3818 #ifdef ANALYZE
3819 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
3820 #endif // ANALYZE
3821
3822 if (irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX)
3823 { // pause timings correct for "1"?
3824 #ifdef ANALYZE
3825 ANALYZE_PUTCHAR ('1'); // yes, store 1
3826 ANALYZE_NEWLINE ();
3827 #endif // ANALYZE
3828 irmp_store_bit (1);
3829 }
3830 else // if (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)
3831 { // pause timings correct for "0"?
3832 #ifdef ANALYZE
3833 ANALYZE_PUTCHAR ('0'); // yes, store 0
3834 ANALYZE_NEWLINE ();
3835 #endif // ANALYZE
3836 irmp_store_bit (0);
3837 }
3838 }
3839 else
3840 #endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1
3841 {
3842 ; // else do nothing
3843 }
3844
3845 irmp_pulse_time = 1; // set counter to 1, not 0
3846 irmp_pause_time = 0;
3847 wait_for_start_space = 0;
3848 }
3849 }
3850 else if (wait_for_space) // the data section....
3851 { // counting the time of darkness....
3852 uint_fast8_t got_light = FALSE;
3853
3854 if (irmp_input) // still dark?
3855 { // yes...
3856 if (irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 1)
3857 {
3858 if (
3859 #if IRMP_SUPPORT_MANCHESTER == 1
3860 (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) ||
3861 #endif
3862 #if IRMP_SUPPORT_SERIAL == 1
3863 (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) ||
3864 #endif
3865 (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max))
3866 {
3867 #ifdef ANALYZE
3868 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))
3869 {
3870 ANALYZE_PRINTF ("stop bit detected\n");
3871 }
3872 #endif // ANALYZE
3873 irmp_param.stop_bit = 0;
3874 }
3875 else
3876 {
3877 #ifdef ANALYZE
3878 ANALYZE_PRINTF ("error: stop bit timing wrong, irmp_bit = %d, irmp_pulse_time = %d, pulse_0_len_min = %d, pulse_0_len_max = %d\n",
3879 irmp_bit, irmp_pulse_time, irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);
3880 #endif // ANALYZE
3881 irmp_start_bit_detected = 0; // wait for another start bit...
3882 irmp_pulse_time = 0;
3883 irmp_pause_time = 0;
3884 }
3885 }
3886 else
3887 {
3888 irmp_pause_time++; // increment counter
3889
3890 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
3891 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && // Sony has a variable number of bits:
3892 irmp_pause_time > SIRCS_PAUSE_LEN_MAX && // minimum is 12
3893 irmp_bit >= 12 - 1) // pause too long?
3894 { // yes, break and close this frame
3895 irmp_param.complete_len = irmp_bit + 1; // set new complete length
3896 got_light = TRUE; // this is a lie, but helps (generates stop bit)
3897 irmp_tmp_address |= (irmp_bit - SIRCS_MINIMUM_DATA_LEN + 1) << 8; // new: store number of additional bits in upper byte of address!
3898 irmp_param.command_end = irmp_param.command_offset + irmp_bit + 1; // correct command length
3899 irmp_pause_time = SIRCS_PAUSE_LEN_MAX - 1; // correct pause length
3900 }
3901 else
3902 #endif
3903 #if IRMP_SUPPORT_FAN_PROTOCOL == 1
3904 if (irmp_param.protocol == IRMP_FAN_PROTOCOL && // FAN has no stop bit.
3905 irmp_bit >= FAN_COMPLETE_DATA_LEN - 1) // last bit in frame
3906 { // yes, break and close this frame
3907 if (irmp_pulse_time <= FAN_0_PULSE_LEN_MAX && irmp_pause_time >= FAN_0_PAUSE_LEN_MIN)
3908 {
3909 #ifdef ANALYZE
3910 ANALYZE_PRINTF ("Generating virtual stop bit\n");
3911 #endif // ANALYZE
3912 got_light = TRUE; // this is a lie, but helps (generates stop bit)
3913 }
3914 else if (irmp_pulse_time >= FAN_1_PULSE_LEN_MIN && irmp_pause_time >= FAN_1_PAUSE_LEN_MIN)
3915 {
3916 #ifdef ANALYZE
3917 ANALYZE_PRINTF ("Generating virtual stop bit\n");
3918 #endif // ANALYZE
3919 got_light = TRUE; // this is a lie, but helps (generates stop bit)
3920 }
3921 }
3922 else
3923 #endif
3924 #if IRMP_SUPPORT_SERIAL == 1
3925 // NETBOX generates no stop bit, here is the timeout condition:
3926 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) && irmp_param.protocol == IRMP_NETBOX_PROTOCOL &&
3927 irmp_pause_time >= NETBOX_PULSE_LEN * (NETBOX_COMPLETE_DATA_LEN - irmp_bit))
3928 {
3929 got_light = TRUE; // this is a lie, but helps (generates stop bit)
3930 }
3931 else
3932 #endif
3933 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
3934 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit)
3935 {
3936 if (irmp_pause_time > IR60_TIMEOUT_LEN && (irmp_bit == 5 || irmp_bit == 6))
3937 {
3938 #ifdef ANALYZE
3939 ANALYZE_PRINTF ("Switching to IR60 protocol\n");
3940 #endif // ANALYZE
3941 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
3942 irmp_param.stop_bit = TRUE; // set flag
3943
3944 irmp_param.protocol = IRMP_IR60_PROTOCOL; // change protocol
3945 irmp_param.complete_len = IR60_COMPLETE_DATA_LEN; // correct complete len
3946 irmp_param.address_offset = IR60_ADDRESS_OFFSET;
3947 irmp_param.address_end = IR60_ADDRESS_OFFSET + IR60_ADDRESS_LEN;
3948 irmp_param.command_offset = IR60_COMMAND_OFFSET;
3949 irmp_param.command_end = IR60_COMMAND_OFFSET + IR60_COMMAND_LEN;
3950
3951 irmp_tmp_command <<= 1;
3952 irmp_tmp_command |= first_bit;
3953 }
3954 else if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2)
3955 { // special manchester decoder
3956 irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len
3957 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
3958 irmp_param.stop_bit = TRUE; // set flag
3959 }
3960 else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN)
3961 {
3962 #ifdef ANALYZE
3963 ANALYZE_PRINTF ("Switching to NOKIA protocol, irmp_bit = %d\n", irmp_bit);
3964 #endif // ANALYZE
3965 irmp_param.protocol = IRMP_NOKIA_PROTOCOL; // change protocol
3966 irmp_param.address_offset = NOKIA_ADDRESS_OFFSET;
3967 irmp_param.address_end = NOKIA_ADDRESS_OFFSET + NOKIA_ADDRESS_LEN;
3968 irmp_param.command_offset = NOKIA_COMMAND_OFFSET;
3969 irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN;
3970
3971 if (irmp_tmp_command & 0x300)
3972 {
3973 irmp_tmp_address = (irmp_tmp_command >> 8);
3974 irmp_tmp_command &= 0xFF;
3975 }
3976 }
3977 }
3978 else
3979 #endif
3980 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
3981 if (irmp_param.protocol == IRMP_RUWIDO_PROTOCOL && !irmp_param.stop_bit)
3982 {
3983 if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= RUWIDO_COMPLETE_DATA_LEN - 2)
3984 { // special manchester decoder
3985 irmp_param.complete_len = RUWIDO_COMPLETE_DATA_LEN; // correct complete len
3986 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
3987 irmp_param.stop_bit = TRUE; // set flag
3988 }
3989 else if (irmp_bit >= RUWIDO_COMPLETE_DATA_LEN)
3990 {
3991 #ifdef ANALYZE
3992 ANALYZE_PRINTF ("Switching to SIEMENS protocol\n");
3993 #endif // ANALYZE
3994 irmp_param.protocol = IRMP_SIEMENS_PROTOCOL; // change protocol
3995 irmp_param.address_offset = SIEMENS_ADDRESS_OFFSET;
3996 irmp_param.address_end = SIEMENS_ADDRESS_OFFSET + SIEMENS_ADDRESS_LEN;
3997 irmp_param.command_offset = SIEMENS_COMMAND_OFFSET;
3998 irmp_param.command_end = SIEMENS_COMMAND_OFFSET + SIEMENS_COMMAND_LEN;
3999
4000 // 76543210
4001 // RUWIDO: AAAAAAAAACCCCCCCp
4002 // SIEMENS: AAAAAAAAAAACCCCCCCCCCp
4003 irmp_tmp_address <<= 2;
4004 irmp_tmp_address |= (irmp_tmp_command >> 6);
4005 irmp_tmp_command &= 0x003F;
4006 // irmp_tmp_command <<= 4;
4007 irmp_tmp_command |= last_value;
4008 }
4009 }
4010 else
4011 #endif
4012 #if IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
4013 if (irmp_param.protocol == IRMP_ROOMBA_PROTOCOL && // Roomba has no stop bit
4014 irmp_bit >= ROOMBA_COMPLETE_DATA_LEN - 1) // it's the last data bit...
4015 { // break and close this frame
4016 if (irmp_pulse_time >= ROOMBA_1_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_1_PULSE_LEN_MAX)
4017 {
4018 irmp_pause_time = ROOMBA_1_PAUSE_LEN_EXACT;
4019 }
4020 else if (irmp_pulse_time >= ROOMBA_0_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_0_PULSE_LEN_MAX)
4021 {
4022 irmp_pause_time = ROOMBA_0_PAUSE_LEN;
4023 }
4024
4025 got_light = TRUE; // this is a lie, but helps (generates stop bit)
4026 }
4027 else
4028 #endif
4029 #if IRMP_SUPPORT_MANCHESTER == 1
4030 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&
4031 irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit)
4032 { // special manchester decoder
4033 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
4034 irmp_param.stop_bit = TRUE; // set flag
4035 }
4036 else
4037 #endif // IRMP_SUPPORT_MANCHESTER == 1
4038 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?
4039 { // yes...
4040 if (irmp_bit == irmp_param.complete_len - 1 && irmp_param.stop_bit == 0)
4041 {
4042 irmp_bit++;
4043 }
4044 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
4045 else if ((irmp_param.protocol == IRMP_NEC_PROTOCOL || irmp_param.protocol == IRMP_NEC42_PROTOCOL) && irmp_bit == 0)
4046 { // it was a non-standard repetition frame
4047 #ifdef ANALYZE // with 4500µs pause instead of 2250µs
4048 ANALYZE_PRINTF ("Detected non-standard repetition frame, switching to NEC repetition\n");
4049 #endif // ANALYZE
4050 if (key_repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX)
4051 {
4052 irmp_param.stop_bit = TRUE; // set flag
4053 irmp_param.protocol = IRMP_NEC_PROTOCOL; // switch protocol
4054 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
4055 irmp_tmp_address = last_irmp_address; // address is last address
4056 irmp_tmp_command = last_irmp_command; // command is last command
4057 irmp_flags |= IRMP_FLAG_REPETITION;
4058 key_repetition_len = 0;
4059 }
4060 else
4061 {
4062 #ifdef ANALYZE
4063 ANALYZE_PRINTF ("ignoring NEC repetition frame: timeout occured, key_repetition_len = %d > %d\n",
4064 key_repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX);
4065 #endif // ANALYZE
4066 irmp_ir_detected = FALSE;
4067 }
4068 }
4069 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
4070 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
4071 else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit
4072 {
4073 #ifdef ANALYZE
4074 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);
4075 #endif // ANALYZE
4076 irmp_param.stop_bit = TRUE; // set flag
4077 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol
4078 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
4079 irmp_tmp_command = (irmp_tmp_address >> 4); // set command: upper 12 bits are command bits
4080 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits
4081 irmp_start_bit_detected = 1; // tricky: don't wait for another start bit...
4082 }
4083 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
4084 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
4085 else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 28 || irmp_bit == 29)) // it was a LGAIR stop bit
4086 {
4087 #ifdef ANALYZE
4088 ANALYZE_PRINTF ("Switching to LGAIR protocol, irmp_bit = %d\n", irmp_bit);
4089 #endif // ANALYZE
4090 irmp_param.stop_bit = TRUE; // set flag
4091 irmp_param.protocol = IRMP_LGAIR_PROTOCOL; // switch protocol
4092 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
4093 irmp_tmp_command = irmp_lgair_command; // set command: upper 8 bits are command bits
4094 irmp_tmp_address = irmp_lgair_address; // lower 4 bits are address bits
4095 irmp_start_bit_detected = 1; // tricky: don't wait for another start bit...
4096 }
4097 #endif // IRMP_SUPPORT_LGAIR_PROTOCOL == 1
4098
4099 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
4100 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
4101 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 32) // it was a NEC stop bit
4102 {
4103 #ifdef ANALYZE
4104 ANALYZE_PRINTF ("Switching to NEC protocol\n");
4105 #endif // ANALYZE
4106 irmp_param.stop_bit = TRUE; // set flag
4107 irmp_param.protocol = IRMP_NEC_PROTOCOL; // switch protocol
4108 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
4109
4110 // 0123456789ABC0123456789ABC0123456701234567
4111 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc
4112 // NEC: AAAAAAAAaaaaaaaaCCCCCCCCcccccccc
4113 irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 13; // fm 2012-02-13: 12 -> 13
4114 irmp_tmp_command = (irmp_tmp_address2 >> 3) | (irmp_tmp_command << 10);
4115 }
4116 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
4117 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
4118 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 28) // it was a NEC stop bit
4119 {
4120 #ifdef ANALYZE
4121 ANALYZE_PRINTF ("Switching to LGAIR protocol\n");
4122 #endif // ANALYZE
4123 irmp_param.stop_bit = TRUE; // set flag
4124 irmp_param.protocol = IRMP_LGAIR_PROTOCOL; // switch protocol
4125 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
4126 irmp_tmp_address = irmp_lgair_address;
4127 irmp_tmp_command = irmp_lgair_command;
4128 }
4129 #endif // IRMP_SUPPORT_LGAIR_PROTOCOL == 1
4130 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
4131 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit
4132 {
4133 #ifdef ANALYZE
4134 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);
4135 #endif // ANALYZE
4136 irmp_param.stop_bit = TRUE; // set flag
4137 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol
4138 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
4139
4140 // 0123456789ABC0123456789ABC0123456701234567
4141 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc
4142 // JVC: AAAACCCCCCCCCCCC
4143 irmp_tmp_command = (irmp_tmp_address >> 4) | (irmp_tmp_address2 << 9); // set command: upper 12 bits are command bits
4144 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits
4145 }
4146 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
4147 #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1
4148
4149 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1
4150 else if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit == 32) // it was a SAMSUNG32 stop bit
4151 {
4152 #ifdef ANALYZE
4153 ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n");
4154 #endif // ANALYZE
4155 irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL;
4156 irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET;
4157 irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN;
4158 irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN;
4159 }
4160 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
4161
4162 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1
4163 else if (irmp_param.protocol == IRMP_RCMM32_PROTOCOL && (irmp_bit == 12 || irmp_bit == 24)) // it was a RCMM stop bit
4164 {
4165 if (irmp_bit == 12)
4166 {
4167 irmp_tmp_command = (irmp_tmp_address & 0xFF); // set command: lower 8 bits are command bits
4168 irmp_tmp_address >>= 8; // upper 4 bits are address bits
4169
4170 #ifdef ANALYZE
4171 ANALYZE_PRINTF ("Switching to RCMM12 protocol, irmp_bit = %d\n", irmp_bit);
4172 #endif // ANALYZE
4173 irmp_param.protocol = IRMP_RCMM12_PROTOCOL; // switch protocol
4174 }
4175 else // if ((irmp_bit == 24)
4176 {
4177 #ifdef ANALYZE
4178 ANALYZE_PRINTF ("Switching to RCMM24 protocol, irmp_bit = %d\n", irmp_bit);
4179 #endif // ANALYZE
4180 irmp_param.protocol = IRMP_RCMM24_PROTOCOL; // switch protocol
4181 }
4182 irmp_param.stop_bit = TRUE; // set flag
4183 irmp_param.complete_len = irmp_bit; // patch length
4184 }
4185 #endif // IRMP_SUPPORT_RCMM_PROTOCOL == 1
4186
4187 #if IRMP_SUPPORT_TECHNICS_PROTOCOL == 1
4188 else if (irmp_param.protocol == IRMP_MATSUSHITA_PROTOCOL && irmp_bit == 22) // it was a TECHNICS stop bit
4189 {
4190 #ifdef ANALYZE
4191 ANALYZE_PRINTF ("Switching to TECHNICS protocol, irmp_bit = %d\n", irmp_bit);
4192 #endif // ANALYZE
4193 // Situation:
4194 // The first 12 bits have been stored in irmp_tmp_command (LSB first)
4195 // The following 10 bits have been stored in irmp_tmp_address (LSB first)
4196 // The code of TECHNICS is:
4197 // cccccccccccCCCCCCCCCCC (11 times c and 11 times C)
4198 // ccccccccccccaaaaaaaaaa
4199 // where C is inverted value of c
4200
4201 irmp_tmp_address <<= 1;
4202 if (irmp_tmp_command & (1<<11))
4203 {
4204 irmp_tmp_address |= 1;
4205 irmp_tmp_command &= ~(1<<11);
4206 }
4207
4208 if (irmp_tmp_command == ((~irmp_tmp_address) & 0x07FF))
4209 {
4210 irmp_tmp_address = 0;
4211
4212 irmp_param.protocol = IRMP_TECHNICS_PROTOCOL; // switch protocol
4213 irmp_param.complete_len = irmp_bit; // patch length
4214 }
4215 else
4216 {
4217 #ifdef ANALYZE
4218 ANALYZE_PRINTF ("error 8: TECHNICS frame error\n");
4219 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4220 #endif // ANALYZE
4221 irmp_start_bit_detected = 0; // wait for another start bit...
4222 irmp_pulse_time = 0;
4223 irmp_pause_time = 0;
4224 }
4225 }
4226 #endif // IRMP_SUPPORT_TECHNICS_PROTOCOL == 1
4227 else
4228 {
4229 #ifdef ANALYZE
4230 ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit);
4231 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4232 #endif // ANALYZE
4233 irmp_start_bit_detected = 0; // wait for another start bit...
4234 irmp_pulse_time = 0;
4235 irmp_pause_time = 0;
4236 }
4237 }
4238 }
4239 }
4240 else
4241 { // got light now!
4242 got_light = TRUE;
4243 }
4244
4245 if (got_light)
4246 {
4247 #ifdef ANALYZE
4248 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
4249 #endif // ANALYZE
4250
4251 #if IRMP_SUPPORT_MANCHESTER == 1
4252 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester
4253 {
4254 #if 1
4255 if (irmp_pulse_time > irmp_param.pulse_1_len_max /* && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max */)
4256 #else // better, but some IR-RCs use asymmetric timings :-/
4257 if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max &&
4258 irmp_pause_time <= 2 * irmp_param.pause_1_len_max)
4259 #endif
4260 {
4261 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
4262 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit
4263 {
4264 #ifdef ANALYZE
4265 ANALYZE_PUTCHAR ('T');
4266 #endif // ANALYZE
4267 if (irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode 6A
4268 {
4269 irmp_store_bit (1);
4270 last_value = 1;
4271 }
4272 else // RC6 mode 0
4273 {
4274 irmp_store_bit (0);
4275 last_value = 0;
4276 }
4277 #ifdef ANALYZE
4278 ANALYZE_NEWLINE ();
4279 #endif // ANALYZE
4280 }
4281 else
4282 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
4283 {
4284 #ifdef ANALYZE
4285 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');
4286 #endif // ANALYZE
4287 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 );
4288
4289 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
4290 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit
4291 {
4292 #ifdef ANALYZE
4293 ANALYZE_PUTCHAR ('T');
4294 #endif // ANALYZE
4295 irmp_store_bit (1);
4296
4297 if (irmp_pause_time > 2 * irmp_param.pause_1_len_max)
4298 {
4299 last_value = 0;
4300 }
4301 else
4302 {
4303 last_value = 1;
4304 }
4305 #ifdef ANALYZE
4306 ANALYZE_NEWLINE ();
4307 #endif // ANALYZE
4308 }
4309 else
4310 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
4311 {
4312 #ifdef ANALYZE
4313 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');
4314 #endif // ANALYZE
4315 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 );
4316 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
4317 if (! irmp_param2.protocol)
4318 #endif
4319 {
4320 #ifdef ANALYZE
4321 ANALYZE_NEWLINE ();
4322 #endif // ANALYZE
4323 }
4324 last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0;
4325 }
4326 }
4327 }
4328 else if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max
4329 /* && irmp_pause_time <= 2 * irmp_param.pause_1_len_max */)
4330 {
4331 uint_fast8_t manchester_value;
4332
4333 if (last_pause > irmp_param.pause_1_len_max && last_pause <= 2 * irmp_param.pause_1_len_max)
4334 {
4335 manchester_value = last_value ? 0 : 1;
4336 last_value = manchester_value;
4337 }
4338 else
4339 {
4340 manchester_value = last_value;
4341 }
4342
4343 #ifdef ANALYZE
4344 ANALYZE_PUTCHAR (manchester_value + '0');
4345 #endif // ANALYZE
4346
4347 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
4348 if (! irmp_param2.protocol)
4349 #endif
4350 {
4351 #ifdef ANALYZE
4352 ANALYZE_NEWLINE ();
4353 #endif // ANALYZE
4354 }
4355
4356 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
4357 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 1) // RC6 mode != 0 ???
4358 {
4359 #ifdef ANALYZE
4360 ANALYZE_PRINTF ("Switching to RC6A protocol\n");
4361 #endif // ANALYZE
4362 irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG;
4363 irmp_param.address_offset = 5;
4364 irmp_param.address_end = irmp_param.address_offset + 15;
4365 irmp_param.command_offset = irmp_param.address_end + 1; // skip 1 system bit, changes like a toggle bit
4366 irmp_param.command_end = irmp_param.command_offset + 16 - 1;
4367 irmp_tmp_address = 0;
4368 }
4369 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
4370
4371 irmp_store_bit (manchester_value);
4372 }
4373 else
4374 {
4375 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1
4376 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL &&
4377 irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX &&
4378 ((irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) ||
4379 (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)))
4380 {
4381 #ifdef ANALYZE
4382 ANALYZE_PUTCHAR ('?');
4383 #endif // ANALYZE
4384 irmp_param.protocol = 0; // switch to FDC, see below
4385 }
4386 else
4387 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
4388 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1
4389 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL &&
4390 irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX &&
4391 ((irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) ||
4392 (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)))
4393 {
4394 #ifdef ANALYZE
4395 ANALYZE_PUTCHAR ('?');
4396 #endif // ANALYZE
4397 irmp_param.protocol = 0; // switch to RCCAR, see below
4398 }
4399 else
4400 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
4401 {
4402 #ifdef ANALYZE
4403 ANALYZE_PUTCHAR ('?');
4404 ANALYZE_NEWLINE ();
4405 ANALYZE_PRINTF ("error 3 manchester: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4406 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4407 #endif // ANALYZE
4408 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4409 irmp_pause_time = 0;
4410 }
4411 }
4412
4413 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1
4414 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL && irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX)
4415 {
4416 if (irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX)
4417 {
4418 #ifdef ANALYZE
4419 ANALYZE_PRINTF (" 1 (FDC)\n");
4420 #endif // ANALYZE
4421 irmp_store_bit2 (1);
4422 }
4423 else if (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)
4424 {
4425 #ifdef ANALYZE
4426 ANALYZE_PRINTF (" 0 (FDC)\n");
4427 #endif // ANALYZE
4428 irmp_store_bit2 (0);
4429 }
4430
4431 if (! irmp_param.protocol)
4432 {
4433 #ifdef ANALYZE
4434 ANALYZE_PRINTF ("Switching to FDC protocol\n");
4435 #endif // ANALYZE
4436 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));
4437 irmp_param2.protocol = 0;
4438 irmp_tmp_address = irmp_tmp_address2;
4439 irmp_tmp_command = irmp_tmp_command2;
4440 }
4441 }
4442 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
4443 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1
4444 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL && irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX)
4445 {
4446 if (irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX)
4447 {
4448 #ifdef ANALYZE
4449 ANALYZE_PRINTF (" 1 (RCCAR)\n");
4450 #endif // ANALYZE
4451 irmp_store_bit2 (1);
4452 }
4453 else if (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)
4454 {
4455 #ifdef ANALYZE
4456 ANALYZE_PRINTF (" 0 (RCCAR)\n");
4457 #endif // ANALYZE
4458 irmp_store_bit2 (0);
4459 }
4460
4461 if (! irmp_param.protocol)
4462 {
4463 #ifdef ANALYZE
4464 ANALYZE_PRINTF ("Switching to RCCAR protocol\n");
4465 #endif // ANALYZE
4466 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));
4467 irmp_param2.protocol = 0;
4468 irmp_tmp_address = irmp_tmp_address2;
4469 irmp_tmp_command = irmp_tmp_command2;
4470 }
4471 }
4472 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
4473
4474 last_pause = irmp_pause_time;
4475 wait_for_space = 0;
4476 }
4477 else
4478 #endif // IRMP_SUPPORT_MANCHESTER == 1
4479
4480 #if IRMP_SUPPORT_SERIAL == 1
4481 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)
4482 {
4483 while (irmp_bit < irmp_param.complete_len && irmp_pulse_time > irmp_param.pulse_1_len_max)
4484 {
4485 #ifdef ANALYZE
4486 ANALYZE_PUTCHAR ('1');
4487 #endif // ANALYZE
4488 irmp_store_bit (1);
4489
4490 if (irmp_pulse_time >= irmp_param.pulse_1_len_min)
4491 {
4492 irmp_pulse_time -= irmp_param.pulse_1_len_min;
4493 }
4494 else
4495 {
4496 irmp_pulse_time = 0;
4497 }
4498 }
4499
4500 while (irmp_bit < irmp_param.complete_len && irmp_pause_time > irmp_param.pause_1_len_max)
4501 {
4502 #ifdef ANALYZE
4503 ANALYZE_PUTCHAR ('0');
4504 #endif // ANALYZE
4505 irmp_store_bit (0);
4506
4507 if (irmp_pause_time >= irmp_param.pause_1_len_min)
4508 {
4509 irmp_pause_time -= irmp_param.pause_1_len_min;
4510 }
4511 else
4512 {
4513 irmp_pause_time = 0;
4514 }
4515 }
4516 #ifdef ANALYZE
4517 ANALYZE_NEWLINE ();
4518 #endif // ANALYZE
4519 wait_for_space = 0;
4520 }
4521 else
4522 #endif // IRMP_SUPPORT_SERIAL == 1
4523
4524 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
4525 if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit == 16) // Samsung: 16th bit
4526 {
4527 if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX &&
4528 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)
4529 {
4530 #ifdef ANALYZE
4531 ANALYZE_PRINTF ("SYNC\n");
4532 #endif // ANALYZE
4533 wait_for_space = 0;
4534 irmp_bit++;
4535 }
4536 else if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX)
4537 {
4538 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1
4539 #ifdef ANALYZE
4540 ANALYZE_PRINTF ("Switching to SAMSUNG48 protocol ");
4541 #endif // ANALYZE
4542 irmp_param.protocol = IRMP_SAMSUNG48_PROTOCOL;
4543 irmp_param.command_offset = SAMSUNG48_COMMAND_OFFSET;
4544 irmp_param.command_end = SAMSUNG48_COMMAND_OFFSET + SAMSUNG48_COMMAND_LEN;
4545 irmp_param.complete_len = SAMSUNG48_COMPLETE_DATA_LEN;
4546 #else
4547 #ifdef ANALYZE
4548 ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol ");
4549 #endif // ANALYZE
4550 irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL;
4551 irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET;
4552 irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN;
4553 irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN;
4554 #endif
4555 if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX)
4556 {
4557 #ifdef ANALYZE
4558 ANALYZE_PUTCHAR ('1');
4559 ANALYZE_NEWLINE ();
4560 #endif // ANALYZE
4561 irmp_store_bit (1);
4562 wait_for_space = 0;
4563 }
4564 else
4565 {
4566 #ifdef ANALYZE
4567 ANALYZE_PUTCHAR ('0');
4568 ANALYZE_NEWLINE ();
4569 #endif // ANALYZE
4570 irmp_store_bit (0);
4571 wait_for_space = 0;
4572 }
4573 }
4574 else
4575 { // timing incorrect!
4576 #ifdef ANALYZE
4577 ANALYZE_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4578 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4579 #endif // ANALYZE
4580 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4581 irmp_pause_time = 0;
4582 }
4583 }
4584 else
4585 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL
4586
4587 #if IRMP_SUPPORT_NEC16_PROTOCOL
4588 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
4589 if (irmp_param.protocol == IRMP_NEC42_PROTOCOL &&
4590 #else // IRMP_SUPPORT_NEC_PROTOCOL instead
4591 if (irmp_param.protocol == IRMP_NEC_PROTOCOL &&
4592 #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1
4593 irmp_bit == 8 && irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)
4594 {
4595 #ifdef ANALYZE
4596 ANALYZE_PRINTF ("Switching to NEC16 protocol\n");
4597 #endif // ANALYZE
4598 irmp_param.protocol = IRMP_NEC16_PROTOCOL;
4599 irmp_param.address_offset = NEC16_ADDRESS_OFFSET;
4600 irmp_param.address_end = NEC16_ADDRESS_OFFSET + NEC16_ADDRESS_LEN;
4601 irmp_param.command_offset = NEC16_COMMAND_OFFSET;
4602 irmp_param.command_end = NEC16_COMMAND_OFFSET + NEC16_COMMAND_LEN;
4603 irmp_param.complete_len = NEC16_COMPLETE_DATA_LEN;
4604 wait_for_space = 0;
4605 }
4606 else
4607 #endif // IRMP_SUPPORT_NEC16_PROTOCOL
4608
4609 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
4610 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)
4611 {
4612 if (irmp_pulse_time >= BANG_OLUFSEN_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_PULSE_LEN_MAX)
4613 {
4614 if (irmp_bit == 1) // Bang & Olufsen: 3rd bit
4615 {
4616 if (irmp_pause_time >= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX)
4617 {
4618 #ifdef ANALYZE
4619 ANALYZE_PRINTF ("3rd start bit\n");
4620 #endif // ANALYZE
4621 wait_for_space = 0;
4622 irmp_bit++;
4623 }
4624 else
4625 { // timing incorrect!
4626 #ifdef ANALYZE
4627 ANALYZE_PRINTF ("error 3a B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4628 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4629 #endif // ANALYZE
4630 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4631 irmp_pause_time = 0;
4632 }
4633 }
4634 else if (irmp_bit == 19) // Bang & Olufsen: trailer bit
4635 {
4636 if (irmp_pause_time >= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX)
4637 {
4638 #ifdef ANALYZE
4639 ANALYZE_PRINTF ("trailer bit\n");
4640 #endif // ANALYZE
4641 wait_for_space = 0;
4642 irmp_bit++;
4643 }
4644 else
4645 { // timing incorrect!
4646 #ifdef ANALYZE
4647 ANALYZE_PRINTF ("error 3b B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4648 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4649 #endif // ANALYZE
4650 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4651 irmp_pause_time = 0;
4652 }
4653 }
4654 else
4655 {
4656 if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX)
4657 { // pulse & pause timings correct for "1"?
4658 #ifdef ANALYZE
4659 ANALYZE_PUTCHAR ('1');
4660 ANALYZE_NEWLINE ();
4661 #endif // ANALYZE
4662 irmp_store_bit (1);
4663 last_value = 1;
4664 wait_for_space = 0;
4665 }
4666 else if (irmp_pause_time >= BANG_OLUFSEN_0_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_0_PAUSE_LEN_MAX)
4667 { // pulse & pause timings correct for "0"?
4668 #ifdef ANALYZE
4669 ANALYZE_PUTCHAR ('0');
4670 ANALYZE_NEWLINE ();
4671 #endif // ANALYZE
4672 irmp_store_bit (0);
4673 last_value = 0;
4674 wait_for_space = 0;
4675 }
4676 else if (irmp_pause_time >= BANG_OLUFSEN_R_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_R_PAUSE_LEN_MAX)
4677 {
4678 #ifdef ANALYZE
4679 ANALYZE_PUTCHAR (last_value + '0');
4680 ANALYZE_NEWLINE ();
4681 #endif // ANALYZE
4682 irmp_store_bit (last_value);
4683 wait_for_space = 0;
4684 }
4685 else
4686 { // timing incorrect!
4687 #ifdef ANALYZE
4688 ANALYZE_PRINTF ("error 3c B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4689 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4690 #endif // ANALYZE
4691 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4692 irmp_pause_time = 0;
4693 }
4694 }
4695 }
4696 else
4697 { // timing incorrect!
4698 #ifdef ANALYZE
4699 ANALYZE_PRINTF ("error 3d B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4700 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4701 #endif // ANALYZE
4702 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4703 irmp_pause_time = 0;
4704 }
4705 }
4706 else
4707 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL
4708
4709 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1
4710 if (irmp_param.protocol == IRMP_RCMM32_PROTOCOL)
4711 {
4712 if (irmp_pause_time >= RCMM32_BIT_00_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_00_PAUSE_LEN_MAX)
4713 {
4714 #ifdef ANALYZE
4715 ANALYZE_PUTCHAR ('0');
4716 ANALYZE_PUTCHAR ('0');
4717 #endif // ANALYZE
4718 irmp_store_bit (0);
4719 irmp_store_bit (0);
4720 }
4721 else if (irmp_pause_time >= RCMM32_BIT_01_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_01_PAUSE_LEN_MAX)
4722 {
4723 #ifdef ANALYZE
4724 ANALYZE_PUTCHAR ('0');
4725 ANALYZE_PUTCHAR ('1');
4726 #endif // ANALYZE
4727 irmp_store_bit (0);
4728 irmp_store_bit (1);
4729 }
4730 else if (irmp_pause_time >= RCMM32_BIT_10_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_10_PAUSE_LEN_MAX)
4731 {
4732 #ifdef ANALYZE
4733 ANALYZE_PUTCHAR ('1');
4734 ANALYZE_PUTCHAR ('0');
4735 #endif // ANALYZE
4736 irmp_store_bit (1);
4737 irmp_store_bit (0);
4738 }
4739 else if (irmp_pause_time >= RCMM32_BIT_11_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_11_PAUSE_LEN_MAX)
4740 {
4741 #ifdef ANALYZE
4742 ANALYZE_PUTCHAR ('1');
4743 ANALYZE_PUTCHAR ('1');
4744 #endif // ANALYZE
4745 irmp_store_bit (1);
4746 irmp_store_bit (1);
4747 }
4748 #ifdef ANALYZE
4749 ANALYZE_PRINTF ("\n");
4750 #endif // ANALYZE
4751 wait_for_space = 0;
4752 }
4753 else
4754 #endif
4755
4756 if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max &&
4757 irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)
4758 { // pulse & pause timings correct for "1"?
4759 #ifdef ANALYZE
4760 ANALYZE_PUTCHAR ('1');
4761 ANALYZE_NEWLINE ();
4762 #endif // ANALYZE
4763 irmp_store_bit (1);
4764 wait_for_space = 0;
4765 }
4766 else if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max &&
4767 irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max)
4768 { // pulse & pause timings correct for "0"?
4769 #ifdef ANALYZE
4770 ANALYZE_PUTCHAR ('0');
4771 ANALYZE_NEWLINE ();
4772 #endif // ANALYZE
4773 irmp_store_bit (0);
4774 wait_for_space = 0;
4775 }
4776 else
4777 #if IRMP_SUPPORT_KATHREIN_PROTOCOL
4778
4779 if (irmp_param.protocol == IRMP_KATHREIN_PROTOCOL &&
4780 irmp_pulse_time >= KATHREIN_1_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_1_PULSE_LEN_MAX &&
4781 (((irmp_bit == 8 || irmp_bit == 6) &&
4782 irmp_pause_time >= KATHREIN_SYNC_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_SYNC_BIT_PAUSE_LEN_MAX) ||
4783 (irmp_bit == 12 &&
4784 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)))
4785
4786 {
4787 if (irmp_bit == 8)
4788 {
4789 irmp_bit++;
4790 #ifdef ANALYZE
4791 ANALYZE_PUTCHAR ('S');
4792 ANALYZE_NEWLINE ();
4793 #endif // ANALYZE
4794 irmp_tmp_command <<= 1;
4795 }
4796 else
4797 {
4798 #ifdef ANALYZE
4799 ANALYZE_PUTCHAR ('S');
4800 ANALYZE_NEWLINE ();
4801 #endif // ANALYZE
4802 irmp_store_bit (1);
4803 }
4804 wait_for_space = 0;
4805 }
4806 else
4807 #endif // IRMP_SUPPORT_KATHREIN_PROTOCOL
4808 { // timing incorrect!
4809 #ifdef ANALYZE
4810 ANALYZE_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4811 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4812 #endif // ANALYZE
4813 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4814 irmp_pause_time = 0;
4815 }
4816
4817 irmp_pulse_time = 1; // set counter to 1, not 0
4818 }
4819 }
4820 else
4821 { // counting the pulse length ...
4822 if (! irmp_input) // still light?
4823 { // yes...
4824 irmp_pulse_time++; // increment counter
4825 }
4826 else
4827 { // now it's dark!
4828 wait_for_space = 1; // let's count the time (see above)
4829 irmp_pause_time = 1; // set pause counter to 1, not 0
4830 }
4831 }
4832
4833 if (irmp_start_bit_detected && irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0) // enough bits received?
4834 {
4835 if (last_irmp_command == irmp_tmp_command && key_repetition_len < AUTO_FRAME_REPETITION_LEN)
4836 {
4837 repetition_frame_number++;
4838 }
4839 else
4840 {
4841 repetition_frame_number = 0;
4842 }
4843
4844 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
4845 // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame
4846 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2))
4847 {
4848 #ifdef ANALYZE
4849 ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4850 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4851 #endif // ANALYZE
4852 key_repetition_len = 0;
4853 }
4854 else
4855 #endif
4856
4857 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
4858 // if ORTEK protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame
4859 if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL && repetition_frame_number == 1)
4860 {
4861 #ifdef ANALYZE
4862 ANALYZE_PRINTF ("code skipped: ORTEK auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4863 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4864 #endif // ANALYZE
4865 key_repetition_len = 0;
4866 }
4867 else
4868 #endif
4869
4870 #if 0 && IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 // fm 2015-12-02: don't ignore every 2nd frame
4871 // if KASEIKYO protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame
4872 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && repetition_frame_number == 1)
4873 {
4874 #ifdef ANALYZE
4875 ANALYZE_PRINTF ("code skipped: KASEIKYO auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4876 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4877 #endif // ANALYZE
4878 key_repetition_len = 0;
4879 }
4880 else
4881 #endif
4882
4883 #if 0 && IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 // fm 2015-12-02: don't ignore every 2nd frame
4884 // if SAMSUNG32 or SAMSUNG48 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
4885 if ((irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL || irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL) && (repetition_frame_number & 0x01))
4886 {
4887 #ifdef ANALYZE
4888 ANALYZE_PRINTF ("code skipped: SAMSUNG32/SAMSUNG48 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4889 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4890 #endif // ANALYZE
4891 key_repetition_len = 0;
4892 }
4893 else
4894 #endif
4895
4896 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
4897 // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
4898 if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01))
4899 {
4900 #ifdef ANALYZE
4901 ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4902 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4903 #endif // ANALYZE
4904 key_repetition_len = 0;
4905 }
4906 else
4907 #endif
4908
4909 #if IRMP_SUPPORT_SPEAKER_PROTOCOL == 1
4910 // if SPEAKER protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
4911 if (irmp_param.protocol == IRMP_SPEAKER_PROTOCOL && (repetition_frame_number & 0x01))
4912 {
4913 #ifdef ANALYZE
4914 ANALYZE_PRINTF ("code skipped: SPEAKER auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4915 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4916 #endif // ANALYZE
4917 key_repetition_len = 0;
4918 }
4919 else
4920 #endif
4921
4922 {
4923 #ifdef ANALYZE
4924 ANALYZE_PRINTF ("%8.3fms code detected, length = %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit);
4925 #endif // ANALYZE
4926 irmp_ir_detected = TRUE;
4927
4928 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
4929 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)
4930 { // check for repetition frame
4931 if ((~irmp_tmp_command & 0x3FF) == last_irmp_denon_command) // command bits must be inverted
4932 {
4933 irmp_tmp_command = last_irmp_denon_command; // use command received before!
4934 last_irmp_denon_command = 0;
4935
4936 irmp_protocol = irmp_param.protocol; // store protocol
4937 irmp_address = irmp_tmp_address; // store address
4938 irmp_command = irmp_tmp_command; // store command
4939 }
4940 else
4941 {
4942 if ((irmp_tmp_command & 0x01) == 0x00)
4943 {
4944 #ifdef ANALYZE
4945 ANALYZE_PRINTF ("%8.3fms info Denon: waiting for inverted command repetition\n", (double) (time_counter * 1000) / F_INTERRUPTS);
4946 #endif // ANALYZE
4947 last_irmp_denon_command = irmp_tmp_command;
4948 denon_repetition_len = 0;
4949 irmp_ir_detected = FALSE;
4950 }
4951 else
4952 {
4953 #ifdef ANALYZE
4954 ANALYZE_PRINTF ("%8.3fms warning Denon: got unexpected inverted command, ignoring it\n", (double) (time_counter * 1000) / F_INTERRUPTS);
4955 #endif // ANALYZE
4956 last_irmp_denon_command = 0;
4957 irmp_ir_detected = FALSE;
4958 }
4959 }
4960 }
4961 else
4962 #endif // IRMP_SUPPORT_DENON_PROTOCOL
4963
4964 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
4965 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && irmp_tmp_command == 0x01ff)
4966 { // Grundig start frame?
4967 #ifdef ANALYZE
4968 ANALYZE_PRINTF ("Detected GRUNDIG start frame, ignoring it\n");
4969 #endif // ANALYZE
4970 irmp_ir_detected = FALSE;
4971 }
4972 else
4973 #endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL
4974
4975 #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1
4976 if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL && irmp_tmp_address == 0x00ff && irmp_tmp_command == 0x00fe)
4977 { // Nokia start frame?
4978 #ifdef ANALYZE
4979 ANALYZE_PRINTF ("Detected NOKIA start frame, ignoring it\n");
4980 #endif // ANALYZE
4981 irmp_ir_detected = FALSE;
4982 }
4983 else
4984 #endif // IRMP_SUPPORT_NOKIA_PROTOCOL
4985 {
4986 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
4987 if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame
4988 {
4989 if (key_repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX)
4990 {
4991 #ifdef ANALYZE
4992 ANALYZE_PRINTF ("Detected NEC repetition frame, key_repetition_len = %d\n", key_repetition_len);
4993 ANALYZE_ONLY_NORMAL_PRINTF("REPETETION FRAME ");
4994 #endif // ANALYZE
4995 irmp_tmp_address = last_irmp_address; // address is last address
4996 irmp_tmp_command = last_irmp_command; // command is last command
4997 irmp_flags |= IRMP_FLAG_REPETITION;
4998 key_repetition_len = 0;
4999 }
5000 else
5001 {
5002 #ifdef ANALYZE
5003 ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, key_repetition_len = %d > %d\n",
5004 key_repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX);
5005 #endif // ANALYZE
5006 irmp_ir_detected = FALSE;
5007 }
5008 }
5009 #endif // IRMP_SUPPORT_NEC_PROTOCOL
5010
5011 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
5012 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)
5013 {
5014 uint_fast8_t xor_value;
5015
5016 xor_value = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4);
5017
5018 if (xor_value != (xor_check[2] & 0x0F))
5019 {
5020 #ifdef ANALYZE
5021 ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor_value, xor_check[2] & 0x0F);
5022 #endif // ANALYZE
5023 irmp_ir_detected = FALSE;
5024 }
5025
5026 xor_value = xor_check[2] ^ xor_check[3] ^ xor_check[4];
5027
5028 if (xor_value != xor_check[5])
5029 {
5030 #ifdef ANALYZE
5031 ANALYZE_PRINTF ("error 5: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor_value, xor_check[5]);
5032 #endif // ANALYZE
5033 irmp_ir_detected = FALSE;
5034 }
5035
5036 irmp_flags |= genre2; // write the genre2 bits into MSB of the flag byte
5037 }
5038 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
5039
5040 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
5041 if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL)
5042 {
5043 if (parity == PARITY_CHECK_FAILED)
5044 {
5045 #ifdef ANALYZE
5046 ANALYZE_PRINTF ("error 6: parity check failed\n");
5047 #endif // ANALYZE
5048 irmp_ir_detected = FALSE;
5049 }
5050
5051 if ((irmp_tmp_address & 0x03) == 0x02)
5052 {
5053 #ifdef ANALYZE
5054 ANALYZE_PRINTF ("code skipped: ORTEK end of transmission frame (key release)\n");
5055 #endif // ANALYZE
5056 irmp_ir_detected = FALSE;
5057 }
5058 irmp_tmp_address >>= 2;
5059 }
5060 #endif // IRMP_SUPPORT_ORTEK_PROTOCOL == 1
5061
5062 #if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1
5063 if (irmp_param.protocol == IRMP_MITSU_HEAVY_PROTOCOL)
5064 {
5065 check = irmp_tmp_command >> 8; // inverted upper byte == lower byte?
5066 check = ~ check;
5067 if (check == (irmp_tmp_command & 0xFF)) { //ok:
5068 irmp_tmp_command &= 0xFF;
5069 }
5070 else mitsu_parity = PARITY_CHECK_FAILED;
5071 if (mitsu_parity == PARITY_CHECK_FAILED)
5072 {
5073 #ifdef ANALYZE
5074 ANALYZE_PRINTF ("error 7: parity check failed\n");
5075 #endif // ANALYZE
5076 irmp_ir_detected = FALSE;
5077 }
5078 }
5079 #endif // IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL
5080
5081 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
5082 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode = 6?
5083 {
5084 irmp_protocol = IRMP_RC6A_PROTOCOL;
5085 }
5086 else
5087 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
5088 {
5089 irmp_protocol = irmp_param.protocol;
5090 }
5091
5092 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
5093 if (irmp_param.protocol == IRMP_FDC_PROTOCOL)
5094 {
5095 if (irmp_tmp_command & 0x000F) // released key?
5096 {
5097 irmp_tmp_command = (irmp_tmp_command >> 4) | 0x80; // yes, set bit 7
5098 }
5099 else
5100 {
5101 irmp_tmp_command >>= 4; // no, it's a pressed key
5102 }
5103 irmp_tmp_command |= (irmp_tmp_address << 2) & 0x0F00; // 000000CCCCAAAAAA -> 0000CCCC00000000
5104 irmp_tmp_address &= 0x003F;
5105 }
5106 #endif
5107
5108 irmp_address = irmp_tmp_address; // store address
5109 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
5110 if (irmp_param.protocol == IRMP_NEC_PROTOCOL)
5111 {
5112 last_irmp_address = irmp_tmp_address; // store as last address, too
5113 }
5114 #endif
5115
5116 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
5117 if (irmp_param.protocol == IRMP_RC5_PROTOCOL)
5118 {
5119 irmp_tmp_command |= rc5_cmd_bit6; // store bit 6
5120 }
5121 #endif
5122 #if IRMP_SUPPORT_S100_PROTOCOL == 1
5123 if (irmp_param.protocol == IRMP_S100_PROTOCOL)
5124 {
5125 irmp_tmp_command |= rc5_cmd_bit6; // store bit 6
5126 }
5127 #endif
5128 irmp_command = irmp_tmp_command; // store command
5129
5130 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
5131 irmp_id = irmp_tmp_id;
5132 #endif
5133 }
5134 }
5135
5136 if (irmp_ir_detected)
5137 {
5138 if (last_irmp_command == irmp_tmp_command &&
5139 last_irmp_address == irmp_tmp_address &&
5140 key_repetition_len < IRMP_KEY_REPETITION_LEN)
5141 {
5142 irmp_flags |= IRMP_FLAG_REPETITION;
5143 }
5144
5145 last_irmp_address = irmp_tmp_address; // store as last address, too
5146 last_irmp_command = irmp_tmp_command; // store as last command, too
5147
5148 key_repetition_len = 0;
5149 }
5150 else
5151 {
5152 #ifdef ANALYZE
5153 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
5154 #endif // ANALYZE
5155 }
5156
5157 irmp_start_bit_detected = 0; // and wait for next start bit
5158 irmp_tmp_command = 0;
5159 irmp_pulse_time = 0;
5160 irmp_pause_time = 0;
5161
5162 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
5163 if (irmp_protocol == IRMP_JVC_PROTOCOL) // the stop bit of JVC frame is also start bit of next frame
5164 { // set pulse time here!
5165 irmp_pulse_time = ((uint_fast8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME));
5166 }
5167 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
5168 }
5169 }
5170 }
5171
5172 #if defined(STELLARIS_ARM_CORTEX_M4)
5173 // Clear the timer interrupt
5174 TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
5175 #endif
5176
5177 return (irmp_ir_detected);
5178 }
5179
5180 #ifdef ANALYZE
5181
5182 /*---------------------------------------------------------------------------------------------------------------------------------------------------
5183 * main functions - for Unix/Linux + Windows only!
5184 *
5185 * AVR: see main.c!
5186 *
5187 * Compile it under linux with:
5188 * cc irmp.c -o irmp
5189 *
5190 * usage: ./irmp [-v|-s|-a|-l] < file
5191 *
5192 * options:
5193 * -v verbose
5194 * -s silent
5195 * -a analyze
5196 * -l list pulse/pauses
5197 *---------------------------------------------------------------------------------------------------------------------------------------------------
5198 */
5199
5200 void
5201 print_spectrum (char * text, int * buf, int is_pulse)
5202 {
5203 int i;
5204 int j;
5205 int min;
5206 int max;
5207 int max_value = 0;
5208 int value;
5209 int sum = 0;
5210 int counter = 0;
5211 double average = 0;
5212 double tolerance;
5213
5214 puts ("-----------------------------------------------------------------------------");
5215 printf ("%s:\n", text);
5216
5217 for (i = 0; i < 256; i++)
5218 {
5219 if (buf[i] > max_value)
5220 {
5221 max_value = buf[i];
5222 }
5223 }
5224
5225 for (i = 1; i < 200; i++)
5226 {
5227 if (buf[i] > 0)
5228 {
5229 printf ("%3d ", i);
5230 value = (buf[i] * 60) / max_value;
5231
5232 for (j = 0; j < value; j++)
5233 {
5234 putchar ('o');
5235 }
5236 printf (" %d\n", buf[i]);
5237
5238 sum += i * buf[i];
5239 counter += buf[i];
5240 }
5241 else
5242 {
5243 max = i - 1;
5244
5245 if (counter > 0)
5246 {
5247 average = (float) sum / (float) counter;
5248
5249 if (is_pulse)
5250 {
5251 printf ("pulse ");
5252 }
5253 else
5254 {
5255 printf ("pause ");
5256 }
5257
5258 printf ("avg: %4.1f=%6.1f us, ", average, (1000000. * average) / (float) F_INTERRUPTS);
5259 printf ("min: %2d=%6.1f us, ", min, (1000000. * min) / (float) F_INTERRUPTS);
5260 printf ("max: %2d=%6.1f us, ", max, (1000000. * max) / (float) F_INTERRUPTS);
5261
5262 tolerance = (max - average);
5263
5264 if (average - min > tolerance)
5265 {
5266 tolerance = average - min;
5267 }
5268
5269 tolerance = tolerance * 100 / average;
5270 printf ("tol: %4.1f%%\n", tolerance);
5271 }
5272
5273 counter = 0;
5274 sum = 0;
5275 min = i + 1;
5276 }
5277 }
5278 }
5279
5280 #define STATE_LEFT_SHIFT 0x01
5281 #define STATE_RIGHT_SHIFT 0x02
5282 #define STATE_LEFT_CTRL 0x04
5283 #define STATE_LEFT_ALT 0x08
5284 #define STATE_RIGHT_ALT 0x10
5285
5286 #define KEY_ESCAPE 0x1B // keycode = 0x006e
5287 #define KEY_MENUE 0x80 // keycode = 0x0070
5288 #define KEY_BACK 0x81 // keycode = 0x0071
5289 #define KEY_FORWARD 0x82 // keycode = 0x0072
5290 #define KEY_ADDRESS 0x83 // keycode = 0x0073
5291 #define KEY_WINDOW 0x84 // keycode = 0x0074
5292 #define KEY_1ST_PAGE 0x85 // keycode = 0x0075
5293 #define KEY_STOP 0x86 // keycode = 0x0076
5294 #define KEY_MAIL 0x87 // keycode = 0x0077
5295 #define KEY_FAVORITES 0x88 // keycode = 0x0078
5296 #define KEY_NEW_PAGE 0x89 // keycode = 0x0079
5297 #define KEY_SETUP 0x8A // keycode = 0x007a
5298 #define KEY_FONT 0x8B // keycode = 0x007b
5299 #define KEY_PRINT 0x8C // keycode = 0x007c
5300 #define KEY_ON_OFF 0x8E // keycode = 0x007c
5301
5302 #define KEY_INSERT 0x90 // keycode = 0x004b
5303 #define KEY_DELETE 0x91 // keycode = 0x004c
5304 #define KEY_LEFT 0x92 // keycode = 0x004f
5305 #define KEY_HOME 0x93 // keycode = 0x0050
5306 #define KEY_END 0x94 // keycode = 0x0051
5307 #define KEY_UP 0x95 // keycode = 0x0053
5308 #define KEY_DOWN 0x96 // keycode = 0x0054
5309 #define KEY_PAGE_UP 0x97 // keycode = 0x0055
5310 #define KEY_PAGE_DOWN 0x98 // keycode = 0x0056
5311 #define KEY_RIGHT 0x99 // keycode = 0x0059
5312 #define KEY_MOUSE_1 0x9E // keycode = 0x0400
5313 #define KEY_MOUSE_2 0x9F // keycode = 0x0800
5314
5315 static uint_fast8_t
5316 get_fdc_key (uint_fast16_t cmd)
5317 {
5318 static uint8_t key_table[128] =
5319 {
5320 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
5321 0, '^', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0xDF, '´', 0, '\b',
5322 '\t', 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 0xFC, '+', 0, 0, 'a',
5323 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 0xF6, 0xE4, '#', '\r', 0, '<', 'y', 'x',
5324 'c', 'v', 'b', 'n', 'm', ',', '.', '-', 0, 0, 0, 0, 0, ' ', 0, 0,
5325
5326 0, '°', '!', '"', '§', '$', '%', '&', '/', '(', ')', '=', '?', '`', 0, '\b',
5327 '\t', 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 0xDC, '*', 0, 0, 'A',
5328 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 0xD6, 0xC4, '\'', '\r', 0, '>', 'Y', 'X',
5329 'C', 'V', 'B', 'N', 'M', ';', ':', '_', 0, 0, 0, 0, 0, ' ', 0, 0
5330 };
5331 static uint_fast8_t state;
5332
5333 uint_fast8_t key = 0;
5334
5335 switch (cmd)
5336 {
5337 case 0x002C: state |= STATE_LEFT_SHIFT; break; // pressed left shift
5338 case 0x00AC: state &= ~STATE_LEFT_SHIFT; break; // released left shift
5339 case 0x0039: state |= STATE_RIGHT_SHIFT; break; // pressed right shift
5340 case 0x00B9: state &= ~STATE_RIGHT_SHIFT; break; // released right shift
5341 case 0x003A: state |= STATE_LEFT_CTRL; break; // pressed left ctrl
5342 case 0x00BA: state &= ~STATE_LEFT_CTRL; break; // released left ctrl
5343 case 0x003C: state |= STATE_LEFT_ALT; break; // pressed left alt
5344 case 0x00BC: state &= ~STATE_LEFT_ALT; break; // released left alt
5345 case 0x003E: state |= STATE_RIGHT_ALT; break; // pressed left alt
5346 case 0x00BE: state &= ~STATE_RIGHT_ALT; break; // released left alt
5347
5348 case 0x006e: key = KEY_ESCAPE; break;
5349 case 0x004b: key = KEY_INSERT; break;
5350 case 0x004c: key = KEY_DELETE; break;
5351 case 0x004f: key = KEY_LEFT; break;
5352 case 0x0050: key = KEY_HOME; break;
5353 case 0x0051: key = KEY_END; break;
5354 case 0x0053: key = KEY_UP; break;
5355 case 0x0054: key = KEY_DOWN; break;
5356 case 0x0055: key = KEY_PAGE_UP; break;
5357 case 0x0056: key = KEY_PAGE_DOWN; break;
5358 case 0x0059: key = KEY_RIGHT; break;
5359 case 0x0400: key = KEY_MOUSE_1; break;
5360 case 0x0800: key = KEY_MOUSE_2; break;
5361
5362 default:
5363 {
5364 if (!(cmd & 0x80)) // pressed key
5365 {
5366 if (cmd >= 0x70 && cmd <= 0x7F) // function keys
5367 {
5368 key = cmd + 0x10; // 7x -> 8x
5369 }
5370 else if (cmd < 64) // key listed in key_table
5371 {
5372 if (state & (STATE_LEFT_ALT | STATE_RIGHT_ALT))
5373 {
5374 switch (cmd)
5375 {
5376 case 0x0003: key = 0xB2; break; // upper 2
5377 case 0x0008: key = '{'; break;
5378 case 0x0009: key = '['; break;
5379 case 0x000A: key = ']'; break;
5380 case 0x000B: key = '}'; break;
5381 case 0x000C: key = '\\'; break;
5382 case 0x001C: key = '~'; break;
5383 case 0x002D: key = '|'; break;
5384 case 0x0034: key = 0xB5; break; // Mu
5385 }
5386 }
5387 else if (state & (STATE_LEFT_CTRL))
5388 {
5389 if (key_table[cmd] >= 'a' && key_table[cmd] <= 'z')
5390 {
5391 key = key_table[cmd] - 'a' + 1;
5392 }
5393 else
5394 {
5395 key = key_table[cmd];
5396 }
5397 }
5398 else
5399 {
5400 int idx = cmd + ((state & (STATE_LEFT_SHIFT | STATE_RIGHT_SHIFT)) ? 64 : 0);
5401
5402 if (key_table[idx])
5403 {
5404 key = key_table[idx];
5405 }
5406 }
5407 }
5408 }
5409 break;
5410 }
5411 }
5412
5413 return (key);
5414 }
5415
5416 static int analyze = FALSE;
5417 static int list = FALSE;
5418 static IRMP_DATA irmp_data;
5419 static int expected_protocol;
5420 static int expected_address;
5421 static int expected_command;
5422 static int do_check_expected_values;
5423
5424 static void
5425 next_tick (void)
5426 {
5427 if (! analyze && ! list)
5428 {
5429 (void) irmp_ISR ();
5430
5431 if (irmp_get_data (&irmp_data))
5432 {
5433 uint_fast8_t key;
5434
5435 ANALYZE_ONLY_NORMAL_PUTCHAR (' ');
5436
5437 if (verbose)
5438 {
5439 printf ("%8.3fms ", (double) (time_counter * 1000) / F_INTERRUPTS);
5440 }
5441
5442 if (irmp_data.protocol == IRMP_ACP24_PROTOCOL)
5443 {
5444 uint16_t temp = (irmp_data.command & 0x000F) + 15;
5445
5446 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, temp=%d",
5447 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, temp);
5448 }
5449 else if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0)
5450 {
5451 if ((key >= 0x20 && key < 0x7F) || key >= 0xA0)
5452 {
5453 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key='%c'",
5454 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, key);
5455 }
5456 else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F)) // function keys
5457 {
5458 char * p = (char *) NULL;
5459
5460 switch (key)
5461 {
5462 case '\t' : p = "TAB"; break;
5463 case '\r' : p = "CR"; break;
5464 case KEY_ESCAPE : p = "ESCAPE"; break;
5465 case KEY_MENUE : p = "MENUE"; break;
5466 case KEY_BACK : p = "BACK"; break;
5467 case KEY_FORWARD : p = "FORWARD"; break;
5468 case KEY_ADDRESS : p = "ADDRESS"; break;
5469 case KEY_WINDOW : p = "WINDOW"; break;
5470 case KEY_1ST_PAGE : p = "1ST_PAGE"; break;
5471 case KEY_STOP : p = "STOP"; break;
5472 case KEY_MAIL : p = "MAIL"; break;
5473 case KEY_FAVORITES : p = "FAVORITES"; break;
5474 case KEY_NEW_PAGE : p = "NEW_PAGE"; break;
5475 case KEY_SETUP : p = "SETUP"; break;
5476 case KEY_FONT : p = "FONT"; break;
5477 case KEY_PRINT : p = "PRINT"; break;
5478 case KEY_ON_OFF : p = "ON_OFF"; break;
5479
5480 case KEY_INSERT : p = "INSERT"; break;
5481 case KEY_DELETE : p = "DELETE"; break;
5482 case KEY_LEFT : p = "LEFT"; break;
5483 case KEY_HOME : p = "HOME"; break;
5484 case KEY_END : p = "END"; break;
5485 case KEY_UP : p = "UP"; break;
5486 case KEY_DOWN : p = "DOWN"; break;
5487 case KEY_PAGE_UP : p = "PAGE_UP"; break;
5488 case KEY_PAGE_DOWN : p = "PAGE_DOWN"; break;
5489 case KEY_RIGHT : p = "RIGHT"; break;
5490 case KEY_MOUSE_1 : p = "KEY_MOUSE_1"; break;
5491 case KEY_MOUSE_2 : p = "KEY_MOUSE_2"; break;
5492 default : p = "<UNKNWON>"; break;
5493 }
5494
5495 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key=%s",
5496 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, p);
5497 }
5498 else
5499 {
5500 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x",
5501 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key);
5502 }
5503 }
5504 else
5505 {
5506 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x",
5507 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags);
5508 }
5509
5510 if (do_check_expected_values)
5511 {
5512 if (irmp_data.protocol != expected_protocol ||
5513 irmp_data.address != expected_address ||
5514 irmp_data.command != expected_command)
5515 {
5516 printf ("\nerror 7: expected values differ: p=%2d (%s), a=0x%04x, c=0x%04x\n",
5517 expected_protocol, irmp_protocol_names[expected_protocol], expected_address, expected_command);
5518 }
5519 else
5520 {
5521 printf (" checked!\n");
5522 }
5523 do_check_expected_values = FALSE; // only check 1st frame in a line!
5524 }
5525 else
5526 {
5527 putchar ('\n');
5528 }
5529 }
5530 }
5531 }
5532
5533 int
5534 main (int argc, char ** argv)
5535 {
5536 int i;
5537 int ch;
5538 int last_ch = 0;
5539 int pulse = 0;
5540 int pause = 0;
5541
5542 int start_pulses[256];
5543 int start_pauses[256];
5544 int pulses[256];
5545 int pauses[256];
5546
5547 int first_pulse = TRUE;
5548 int first_pause = TRUE;
5549
5550 if (argc == 2)
5551 {
5552 if (! strcmp (argv[1], "-v"))
5553 {
5554 verbose = TRUE;
5555 }
5556 else if (! strcmp (argv[1], "-l"))
5557 {
5558 list = TRUE;
5559 }
5560 else if (! strcmp (argv[1], "-a"))
5561 {
5562 analyze = TRUE;
5563 }
5564 else if (! strcmp (argv[1], "-s"))
5565 {
5566 silent = TRUE;
5567 }
5568 else if (! strcmp (argv[1], "-r"))
5569 {
5570 radio = TRUE;
5571 }
5572 }
5573
5574 for (i = 0; i < 256; i++)
5575 {
5576 start_pulses[i] = 0;
5577 start_pauses[i] = 0;
5578 pulses[i] = 0;
5579 pauses[i] = 0;
5580 }
5581
5582 IRMP_PIN = 0xFF;
5583
5584 while ((ch = getchar ()) != EOF)
5585 {
5586 if (ch == '_' || ch == '0')
5587 {
5588 if (last_ch != ch)
5589 {
5590 if (pause > 0)
5591 {
5592 if (list)
5593 {
5594 printf ("pause: %d\n", pause);
5595 }
5596
5597 if (analyze)
5598 {
5599 if (first_pause)
5600 {
5601 if (pause < 256)
5602 {
5603 start_pauses[pause]++;
5604 }
5605 first_pause = FALSE;
5606 }
5607 else
5608 {
5609 if (pause < 256)
5610 {
5611 pauses[pause]++;
5612 }
5613 }
5614 }
5615 }
5616 pause = 0;
5617 }
5618 pulse++;
5619 IRMP_PIN = 0x00;
5620 }
5621 else if (ch == 0xaf || ch == '-' || ch == '1')
5622 {
5623 if (last_ch != ch)
5624 {
5625 if (list)
5626 {
5627 printf ("pulse: %d ", pulse);
5628 }
5629
5630 if (analyze)
5631 {
5632 if (first_pulse)
5633 {
5634 if (pulse < 256)
5635 {
5636 start_pulses[pulse]++;
5637 }
5638 first_pulse = FALSE;
5639 }
5640 else
5641 {
5642 if (pulse < 256)
5643 {
5644 pulses[pulse]++;
5645 }
5646 }
5647 }
5648 pulse = 0;
5649 }
5650
5651 pause++;
5652 IRMP_PIN = 0xff;
5653 }
5654 else if (ch == '\n')
5655 {
5656 IRMP_PIN = 0xff;
5657 time_counter = 0;
5658
5659 if (list && pause > 0)
5660 {
5661 printf ("pause: %d\n", pause);
5662 }
5663 pause = 0;
5664
5665 if (! analyze)
5666 {
5667 for (i = 0; i < (int) ((10000.0 * F_INTERRUPTS) / 10000); i++) // newline: long pause of 10000 msec
5668 {
5669 next_tick ();
5670 }
5671 }
5672 first_pulse = TRUE;
5673 first_pause = TRUE;
5674 }
5675 else if (ch == '#')
5676 {
5677 time_counter = 0;
5678
5679 if (analyze)
5680 {
5681 while ((ch = getchar()) != '\n' && ch != EOF)
5682 {
5683 ;
5684 }
5685 }
5686 else
5687 {
5688 char buf[1024];
5689 char * p;
5690 int idx = -1;
5691
5692 puts ("----------------------------------------------------------------------");
5693 putchar (ch);
5694
5695
5696 while ((ch = getchar()) != '\n' && ch != EOF)
5697 {
5698 if (ch != '\r') // ignore CR in DOS/Windows files
5699 {
5700 if (ch == '[' && idx == -1)
5701 {
5702 idx = 0;
5703 }
5704 else if (idx >= 0)
5705 {
5706 if (ch == ']')
5707 {
5708 do_check_expected_values = FALSE;
5709 buf[idx] = '\0';
5710 idx = -1;
5711
5712 expected_protocol = atoi (buf);
5713
5714 if (expected_protocol > 0)
5715 {
5716 p = buf;
5717 while (*p)
5718 {
5719 if (*p == 'x')
5720 {
5721 p++;
5722
5723 if (sscanf (p, "%x", &expected_address) == 1)
5724 {
5725 do_check_expected_values = TRUE;
5726 }
5727 break;
5728 }
5729 p++;
5730 }
5731
5732 if (do_check_expected_values)
5733 {
5734 do_check_expected_values = FALSE;
5735
5736 while (*p)
5737 {
5738 if (*p == 'x')
5739 {
5740 p++;
5741
5742 if (sscanf (p, "%x", &expected_command) == 1)
5743 {
5744 do_check_expected_values = TRUE;
5745 }
5746 break;
5747 }
5748 p++;
5749 }
5750
5751 if (do_check_expected_values)
5752 {
5753 // printf ("!%2d %04x %04x!\n", expected_protocol, expected_address, expected_command);
5754 }
5755 }
5756 }
5757 }
5758 else if (idx < 1024 - 2)
5759 {
5760 buf[idx++] = ch;
5761 }
5762 }
5763 putchar (ch);
5764 }
5765 }
5766 putchar ('\n');
5767 }
5768
5769 }
5770
5771 last_ch = ch;
5772
5773 next_tick ();
5774 }
5775
5776 if (analyze)
5777 {
5778 print_spectrum ("START PULSES", start_pulses, TRUE);
5779 print_spectrum ("START PAUSES", start_pauses, FALSE);
5780 print_spectrum ("PULSES", pulses, TRUE);
5781 print_spectrum ("PAUSES", pauses, FALSE);
5782 puts ("-----------------------------------------------------------------------------");
5783 }
5784 return 0;
5785 }
5786
5787 #endif // ANALYZE