]> cloudbase.mooo.com Git - irmp.git/blob - irmp.c
Version 2.1.1: added GRUNDIG2 protocol
[irmp.git] / irmp.c
1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irmp.c - infrared multi-protocol decoder, supports several remote control protocols
3 *
4 * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de
5 *
6 * $Id: irmp.c,v 1.115 2012/02/21 08:41:46 fm Exp $
7 *
8 * ATMEGA88 @ 8 MHz
9 *
10 * Supported mikrocontrollers:
11 *
12 * ATtiny45, ATtiny85
13 * ATtiny84
14 * ATmega8, ATmega16, ATmega32
15 * ATmega162
16 * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284
17 * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P
18 *
19 * Typical manufacturers of remote controls:
20 *
21 * SIRCS - Sony
22 * NEC - NEC, Yamaha, Canon, Tevion, Harman/Kardon, Hitachi, JVC, Pioneer, Toshiba, Xoro, Orion, and many other Japanese manufacturers
23 * SAMSUNG - Samsung
24 * SAMSUNG32 - Samsung
25 * MATSUSHITA - Matsushita
26 * KASEIKYO - Panasonic, Denon & other Japanese manufacturers (members of "Japan's Association for Electric Home Application")
27 * RECS80 - Philips, Nokia, Thomson, Nordmende, Telefunken, Saba
28 * RC5 - Philips and other European manufacturers
29 * DENON - Denon, Sharp
30 * RC6 - Philips and other European manufacturers
31 * APPLE - Apple
32 * NUBERT - Nubert Subwoofer System
33 * B&O - Bang & Olufsen
34 * PANASONIC - Panasonic (older, yet not implemented)
35 * GRUNDIG - Grundig
36 * NOKIA - Nokia
37 * SIEMENS - Siemens, e.g. Gigaset M740AV
38 * FDC - FDC IR keyboard
39 * RCCAR - IR remote control for RC cars
40 * JVC - JVC
41 * THOMSON - Thomson
42 * NIKON - Nikon cameras
43 * RUWIDO - T-Home
44 * KATHREIN - Kathrein
45 * LEGO - Lego Power Functions RC
46 *
47 *---------------------------------------------------------------------------------------------------------------------------------------------------
48 *
49 * SIRCS
50 * -----
51 *
52 * frame: 1 start bit + 12-20 data bits + no stop bit
53 * data: 7 command bits + 5 address bits + 0 to 8 additional bits
54 *
55 * start bit: data "0": data "1": stop bit:
56 * -----------------_________ ------_____ ------------______
57 * 2400us 600us 600us 600us 1200us 600 us no stop bit
58 *
59 *---------------------------------------------------------------------------------------------------------------------------------------------------
60 *
61 * NEC + extended NEC
62 * -------------------------
63 *
64 * frame: 1 start bit + 32 data bits + 1 stop bit
65 * data NEC: 8 address bits + 8 inverted address bits + 8 command bits + 8 inverted command bits
66 * data extended NEC: 16 address bits + 8 command bits + 8 inverted command bits
67 *
68 * start bit: data "0": data "1": stop bit:
69 * -----------------_________ ------______ ------________________ ------______....
70 * 9000us 4500us 560us 560us 560us 1690 us 560us
71 *
72 *
73 * Repetition frame:
74 *
75 * -----------------_________------______ .... ~100ms Pause, then repeat
76 * 9000us 2250us 560us
77 *
78 *---------------------------------------------------------------------------------------------------------------------------------------------------
79 *
80 * SAMSUNG
81 * -------
82 *
83 * frame: 1 start bit + 16 data(1) bits + 1 sync bit + additional 20 data(2) bits + 1 stop bit
84 * data(1): 16 address bits
85 * data(2): 4 ID bits + 8 command bits + 8 inverted command bits
86 *
87 * start bit: data "0": data "1": sync bit: stop bit:
88 * ----------______________ ------______ ------________________ ------______________ ------______....
89 * 4500us 4500us 550us 450us 550us 1450us 550us 4500us 550us
90 *
91 *---------------------------------------------------------------------------------------------------------------------------------------------------
92 *
93 * SAMSUNG32
94 * ----------
95 *
96 * frame: 1 start bit + 32 data bits + 1 stop bit
97 * data: 16 address bits + 16 command bits
98 *
99 * start bit: data "0": data "1": stop bit:
100 * ----------______________ ------______ ------________________ ------______....
101 * 4500us 4500us 550us 450us 550us 1450us 550us
102 *
103 *---------------------------------------------------------------------------------------------------------------------------------------------------
104 *
105 * MATSUSHITA
106 * ----------
107 *
108 * frame: 1 start bit + 24 data bits + 1 stop bit
109 * data: 6 custom bits + 6 command bits + 12 address bits
110 *
111 * start bit: data "0": data "1": stop bit:
112 * ----------_________ ------______ ------________________ ------______....
113 * 3488us 3488us 872us 872us 872us 2616us 872us
114 *
115 *---------------------------------------------------------------------------------------------------------------------------------------------------
116 *
117 * KASEIKYO
118 * --------
119 *
120 * frame: 1 start bit + 48 data bits + 1 stop bit
121 * data: 16 manufacturer bits + 4 parity bits + 4 genre1 bits + 4 genre2 bits + 10 command bits + 2 id bits + 8 parity bits
122 *
123 * start bit: data "0": data "1": stop bit:
124 * ----------______ ------______ ------________________ ------______....
125 * 3380us 1690us 423us 423us 423us 1269us 423us
126 *
127 *---------------------------------------------------------------------------------------------------------------------------------------------------
128 *
129 * RECS80
130 * ------
131 *
132 * frame: 2 start bits + 10 data bits + 1 stop bit
133 * data: 1 toggle bit + 3 address bits + 6 command bits
134 *
135 * start bit: data "0": data "1": stop bit:
136 * -----_____________________ -----____________ -----______________ ------_______....
137 * 158us 7432us 158us 4902us 158us 7432us 158us
138 *
139 *---------------------------------------------------------------------------------------------------------------------------------------------------
140 *
141 * RECS80EXT
142 * ---------
143 *
144 * frame: 2 start bits + 11 data bits + 1 stop bit
145 * data: 1 toggle bit + 4 address bits + 6 command bits
146 *
147 * start bit: data "0": data "1": stop bit:
148 * -----_____________________ -----____________ -----______________ ------_______....
149 * 158us 3637us 158us 4902us 158us 7432us 158us
150 *
151 *---------------------------------------------------------------------------------------------------------------------------------------------------
152 *
153 * RC5 + RC5X
154 * ----------
155 *
156 * RC5 frame: 2 start bits + 12 data bits + no stop bit
157 * RC5 data: 1 toggle bit + 5 address bits + 6 command bits
158 * RC5X frame: 1 start bit + 13 data bits + no stop bit
159 * RC5X data: 1 inverted command bit + 1 toggle bit + 5 address bits + 6 command bits
160 *
161 * start bit: data "0": data "1":
162 * ______----- ------______ ______------
163 * 889us 889us 889us 889us 889us 889us
164 *
165 *---------------------------------------------------------------------------------------------------------------------------------------------------
166 *
167 * DENON
168 * -----
169 *
170 * frame: 0 start bits + 16 data bits + stop bit + 65ms pause + 16 inverted data bits + stop bit
171 * data: 5 address bits + 10 command bits
172 *
173 * Theory:
174 *
175 * data "0": data "1":
176 * ------________________ ------______________
177 * 275us 775us 275us 1900us
178 *
179 * Practice:
180 *
181 * data "0": data "1":
182 * ------________________ ------______________
183 * 310us 745us 310us 1780us
184 *
185 *---------------------------------------------------------------------------------------------------------------------------------------------------
186 *
187 * RC6
188 * ---
189 *
190 * RC6 frame: 1 start bit + 1 bit "1" + 3 mode bits + 1 toggle bit + 16 data bits + 2666 us pause
191 * RC6 data: 8 address bits + 8 command bits
192 *
193 * start bit toggle bit "0": toggle bit "1": data/mode "0": data/mode "1":
194 * ____________------- _______------- -------_______ _______------- -------_______
195 * 2666us 889us 889us 889us 889us 889us 444us 444us 444us 444us
196 *
197 *---------------------------------------------------------------------------------------------------------------------------------------------------
198 *
199 * APPLE
200 * -----
201 *
202 * frame: 1 start bit + 32 data bits + 1 stop bit
203 * data: 16 address bits + 11100000 + 8 command bits
204 *
205 * start bit: data "0": data "1": stop bit:
206 * -----------------_________ ------______ ------________________ ------______....
207 * 9000us 4500us 560us 560us 560us 1690 us 560us
208 *
209 *---------------------------------------------------------------------------------------------------------------------------------------------------
210 *
211 * NUBERT (subwoofer system)
212 * -------------------------
213 *
214 * frame: 1 start bit + 10 data bits + 1 stop bit
215 * data: 0 address bits + 10 command bits ?
216 *
217 * start bit: data "0": data "1": stop bit:
218 * ----------_____ ------______ ------________________ ------______....
219 * 1340us 340us 500us 1300us 1340us 340us 500us
220 *
221 *---------------------------------------------------------------------------------------------------------------------------------------------------
222 *
223 * BANG_OLUFSEN
224 * ------------
225 *
226 * frame: 4 start bits + 16 data bits + 1 trailer bit + 1 stop bit
227 * data: 0 address bits + 16 command bits
228 *
229 * 1st start bit: 2nd start bit: 3rd start bit: 4th start bit:
230 * -----________ -----________ -----_____________ -----________
231 * 210us 3000us 210us 3000us 210us 15000us 210us 3000us
232 *
233 * data "0": data "1": data "repeat bit": trailer bit: stop bit:
234 * -----________ -----_____________ -----___________ -----_____________ -----____...
235 * 210us 3000us 210us 9000us 210us 6000us 210us 12000us 210us
236 *
237 *---------------------------------------------------------------------------------------------------------------------------------------------------
238 *
239 * GRUNDIG
240 * -------
241 *
242 * packet: 1 start frame + 19,968ms pause + N info frames + 117,76ms pause + 1 stop frame
243 * frame: 1 pre bit + 1 start bit + 9 data bits + no stop bit
244 * pause between info frames: 117,76ms
245 *
246 * data of start frame: 9 x 1
247 * data of info frame: 9 command bits
248 * data of stop frame: 9 x 1
249 *
250 * pre bit: start bit data "0": data "1":
251 * ------____________ ------______ ______------ ------______
252 * 528us 2639us 528us 528us 528us 528us 528us 528us
253 *
254 *---------------------------------------------------------------------------------------------------------------------------------------------------
255 *
256 * NOKIA:
257 * ------
258 *
259 * Timing similar to Grundig, but 16 data bits:
260 * frame: 1 pre bit + 1 start bit + 8 command bits + 8 address bits + no stop bit
261 *
262 *---------------------------------------------------------------------------------------------------------------------------------------------------
263 *
264 * SIEMENS or RUWIDO:
265 * ------------------
266 *
267 * SIEMENS frame: 1 start bit + 22 data bits + no stop bit
268 * SIEMENS data: 13 address bits + 1 repeat bit + 7 data bits + 1 unknown bit
269 *
270 * start bit data "0": data "1":
271 * -------_______ _______------- -------_______
272 * 250us 250us 250us 250us 250us 250us
273 *
274 *---------------------------------------------------------------------------------------------------------------------------------------------------
275 *
276 * PANASONIC (older protocol, yet not implemented, see also MATSUSHITA, timing very similar)
277 * -----------------------------------------------------------------------------------------
278 *
279 * frame: 1 start bit + 22 data bits + 1 stop bit
280 * 22 data bits = 5 custom bits + 6 data bits + 5 inverted custom bits + 6 inverted data bits
281 *
282 * European version: T = 456us
283 * USA & Canada version: T = 422us
284 *
285 * start bit: data "0": data "1": stop bit:
286 * 8T 8T 2T 2T 2T 6T 2T
287 * -------------____________ ------_____ ------_____________ ------_______....
288 * 3648us 3648us 912us 912us 912us 2736us 912us (Europe)
289 * 3376us 3376us 844us 844us 844us 2532us 844us (US)
290 *
291 *---------------------------------------------------------------------------------------------------------------------------------------------------
292 *
293 * This program is free software; you can redistribute it and/or modify
294 * it under the terms of the GNU General Public License as published by
295 * the Free Software Foundation; either version 2 of the License, or
296 * (at your option) any later version.
297 *---------------------------------------------------------------------------------------------------------------------------------------------------
298 */
299
300 #if defined(__18CXX)
301 #define PIC_C18 // Microchip C18 Compiler
302 #endif
303
304 #if defined(__PCM__) || defined(__PCB__) || defined(__PCH__) // CCS PIC Compiler instead of AVR
305 #define PIC_CCS_COMPILER
306 #endif
307
308 #ifdef unix // test on linux/unix
309 #include <stdio.h>
310 #include <unistd.h>
311 #include <stdlib.h>
312 #include <string.h>
313 #include <inttypes.h>
314
315 #define ANALYZE
316 #define PROGMEM
317 #define memcpy_P memcpy
318
319 #else // not unix:
320
321 #ifdef WIN32
322 #include <stdio.h>
323 #include <string.h>
324 typedef unsigned char uint8_t;
325 typedef unsigned short uint16_t;
326 #define ANALYZE
327 #define PROGMEM
328 #define memcpy_P memcpy
329
330 #else
331
332 #if defined (PIC_CCS_COMPILER) || defined(PIC_C18)
333
334 #include <string.h>
335 #define PROGMEM
336 #define memcpy_P memcpy
337
338 #if defined (PIC_CCS_COMPILER)
339 typedef unsigned int8 uint8_t;
340 typedef unsigned int16 uint16_t;
341 #endif
342
343 #else // AVR:
344
345 #include <inttypes.h>
346 #include <stdio.h>
347 #include <string.h>
348 #include <avr/io.h>
349 #include <util/delay.h>
350 #include <avr/pgmspace.h>
351
352 #endif // PIC_CCS_COMPILER or PIC_C18
353
354 #endif // windows
355 #endif // unix
356
357 #ifndef IRMP_USE_AS_LIB
358 #include "irmpconfig.h"
359 #endif
360 #include "irmp.h"
361
362 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRMP_SUPPORT_NOKIA_PROTOCOL == 1 || IRMP_SUPPORT_IR60_PROTOCOL == 1
363 #define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 1
364 #else
365 #define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 0
366 #endif
367
368 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 || IRMP_SUPPORT_RUWIDO_PROTOCOL == 1
369 #define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 1
370 #else
371 #define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 0
372 #endif
373
374 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || \
375 IRMP_SUPPORT_RC6_PROTOCOL == 1 || \
376 IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 || \
377 IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 || \
378 IRMP_SUPPORT_GRUNDIG2_PROTOCOL == 1 || \
379 IRMP_SUPPORT_IR60_PROTOCOL
380 #define IRMP_SUPPORT_MANCHESTER 1
381 #else
382 #define IRMP_SUPPORT_MANCHESTER 0
383 #endif
384
385 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1
386 #define IRMP_SUPPORT_SERIAL 1
387 #else
388 #define IRMP_SUPPORT_SERIAL 0
389 #endif
390
391 #define IRMP_KEY_REPETITION_LEN (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec
392
393 #define MIN_TOLERANCE_00 1.0 // -0%
394 #define MAX_TOLERANCE_00 1.0 // +0%
395
396 #define MIN_TOLERANCE_05 0.95 // -5%
397 #define MAX_TOLERANCE_05 1.05 // +5%
398
399 #define MIN_TOLERANCE_10 0.9 // -10%
400 #define MAX_TOLERANCE_10 1.1 // +10%
401
402 #define MIN_TOLERANCE_15 0.85 // -15%
403 #define MAX_TOLERANCE_15 1.15 // +15%
404
405 #define MIN_TOLERANCE_20 0.8 // -20%
406 #define MAX_TOLERANCE_20 1.2 // +20%
407
408 #define MIN_TOLERANCE_30 0.7 // -30%
409 #define MAX_TOLERANCE_30 1.3 // +30%
410
411 #define MIN_TOLERANCE_40 0.6 // -40%
412 #define MAX_TOLERANCE_40 1.4 // +40%
413
414 #define MIN_TOLERANCE_50 0.5 // -50%
415 #define MAX_TOLERANCE_50 1.5 // +50%
416
417 #define MIN_TOLERANCE_60 0.4 // -60%
418 #define MAX_TOLERANCE_60 1.6 // +60%
419
420 #define MIN_TOLERANCE_70 0.3 // -70%
421 #define MAX_TOLERANCE_70 1.7 // +70%
422
423 #define SIRCS_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
424 #define SIRCS_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
425 #define SIRCS_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
426 #if IRMP_SUPPORT_NETBOX_PROTOCOL // only 5% to avoid conflict with NETBOX:
427 #define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5))
428 #else // only 5% + 1 to avoid conflict with RC6:
429 #define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
430 #endif
431 #define SIRCS_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
432 #define SIRCS_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
433 #define SIRCS_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
434 #define SIRCS_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
435 #define SIRCS_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
436 #define SIRCS_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
437
438 #define NEC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
439 #define NEC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
440 #define NEC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
441 #define NEC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
442 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
443 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
444 #define NEC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
445 #define NEC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
446 #define NEC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
447 #define NEC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
448 #define NEC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
449 #define NEC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
450 // autodetect nec repetition frame within 50 msec:
451 // NEC seems to send the first repetition frame after 40ms, further repetition frames after 100 ms
452 #if 0
453 #define NEC_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * NEC_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)
454 #else
455 #define NEC_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * 100.0e-3 * MAX_TOLERANCE_20 + 0.5)
456 #endif
457
458 #define SAMSUNG_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
459 #define SAMSUNG_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
460 #define SAMSUNG_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
461 #define SAMSUNG_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
462 #define SAMSUNG_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
463 #define SAMSUNG_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
464 #define SAMSUNG_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
465 #define SAMSUNG_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
466 #define SAMSUNG_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
467 #define SAMSUNG_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
468
469 #define MATSUSHITA_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
470 #define MATSUSHITA_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
471 #define MATSUSHITA_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
472 #define MATSUSHITA_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
473 #define MATSUSHITA_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
474 #define MATSUSHITA_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
475 #define MATSUSHITA_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
476 #define MATSUSHITA_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
477 #define MATSUSHITA_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
478 #define MATSUSHITA_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
479
480 #define KASEIKYO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
481 #define KASEIKYO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
482 #define KASEIKYO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
483 #define KASEIKYO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
484 #define KASEIKYO_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
485 #define KASEIKYO_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
486 #define KASEIKYO_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
487 #define KASEIKYO_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
488 #define KASEIKYO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
489 #define KASEIKYO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
490
491 #define RECS80_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)
492 #define RECS80_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
493 #define RECS80_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
494 #define RECS80_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
495 #define RECS80_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
496 #define RECS80_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
497 #define RECS80_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
498 #define RECS80_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
499 #define RECS80_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
500 #define RECS80_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
501
502 #define RC5_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
503 #define RC5_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
504
505 #define RC5_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
506 #define RC5_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
507
508 #define DENON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
509 #define DENON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
510 #define DENON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
511 #define DENON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
512 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
513 #define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5)) // no -1, avoid conflict with RUWIDO
514 #else
515 #define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) // be more tolerant
516 #endif
517 #define DENON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
518
519 #define THOMSON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
520 #define THOMSON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
521 #define THOMSON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
522 #define THOMSON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
523 #define THOMSON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
524 #define THOMSON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
525
526 #define RC6_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
527 #define RC6_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
528 #define RC6_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
529 #define RC6_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
530 #define RC6_TOGGLE_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
531 #define RC6_TOGGLE_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
532 #define RC6_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
533 #define RC6_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_60 + 0.5) + 1) // pulses: 300 - 800
534 #define RC6_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
535 #define RC6_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1) // pauses: 300 - 600
536
537 #define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)
538 #define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_00 + 0.5) + 1)
539 #define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
540 #define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
541 #define RECS80EXT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
542 #define RECS80EXT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
543 #define RECS80EXT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
544 #define RECS80EXT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
545 #define RECS80EXT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
546 #define RECS80EXT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
547
548 #define NUBERT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
549 #define NUBERT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
550 #define NUBERT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
551 #define NUBERT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
552 #define NUBERT_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
553 #define NUBERT_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
554 #define NUBERT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
555 #define NUBERT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
556 #define NUBERT_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
557 #define NUBERT_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
558 #define NUBERT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
559 #define NUBERT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
560
561 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
562 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
563 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
564 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
565 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
566 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
567 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
568 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
569 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
570 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
571 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
572 #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
573 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
574 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
575 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
576 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
577 #define BANG_OLUFSEN_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
578 #define BANG_OLUFSEN_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
579 #define BANG_OLUFSEN_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
580 #define BANG_OLUFSEN_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
581 #define BANG_OLUFSEN_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
582 #define BANG_OLUFSEN_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
583 #define BANG_OLUFSEN_R_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
584 #define BANG_OLUFSEN_R_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
585 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
586 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
587
588 #define IR60_TIMEOUT_LEN ((uint8_t)(F_INTERRUPTS * IR60_TIMEOUT_TIME * 0.5))
589 #define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
590 #define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
591 #define GRUNDIG_NOKIA_IR60_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
592 #define GRUNDIG_NOKIA_IR60_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
593 #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) + 1)
594 #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
595
596 #define SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
597 #define SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
598 #define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
599 #define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
600 #define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
601 #define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
602 #define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
603 #define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
604
605 #define GRUNDIG2_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG2_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
606 #define GRUNDIG2_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG2_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
607 #define GRUNDIG2_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG2_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
608 #define GRUNDIG2_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG2_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
609 #define GRUNDIG2_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG2_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
610 #define GRUNDIG2_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG2_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
611 #define GRUNDIG2_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG2_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
612 #define GRUNDIG2_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG2_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
613
614 #define FDC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) // 5%: avoid conflict with NETBOX
615 #define FDC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MAX_TOLERANCE_05 + 0.5))
616 #define FDC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
617 #define FDC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5))
618 #define FDC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
619 #define FDC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
620 #define FDC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
621 #define FDC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
622 #if 0
623 #define FDC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) // could be negative: 255
624 #else
625 #define FDC_0_PAUSE_LEN_MIN (1) // simply use 1
626 #endif
627 #define FDC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
628
629 #define RCCAR_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
630 #define RCCAR_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
631 #define RCCAR_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
632 #define RCCAR_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
633 #define RCCAR_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
634 #define RCCAR_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
635 #define RCCAR_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
636 #define RCCAR_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
637 #define RCCAR_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
638 #define RCCAR_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
639
640 #define JVC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
641 #define JVC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
642 #define JVC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * (JVC_FRAME_REPEAT_PAUSE_TIME - IRMP_TIMEOUT_TIME) * MIN_TOLERANCE_40 + 0.5) - 1) // HACK!
643 #define JVC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * (JVC_FRAME_REPEAT_PAUSE_TIME - IRMP_TIMEOUT_TIME) * MAX_TOLERANCE_70 + 0.5) - 1) // HACK!
644 #define JVC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
645 #define JVC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * JVC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
646 #define JVC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
647 #define JVC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * JVC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
648 #define JVC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
649 #define JVC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * JVC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
650 // autodetect JVC repetition frame within 50 msec:
651 #define JVC_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * JVC_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)
652
653 #define NIKON_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
654 #define NIKON_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
655 #define NIKON_START_BIT_PAUSE_LEN_MIN ((uint16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
656 #define NIKON_START_BIT_PAUSE_LEN_MAX ((uint16_t)(F_INTERRUPTS * NIKON_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
657 #define NIKON_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
658 #define NIKON_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
659 #define NIKON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
660 #define NIKON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
661 #define NIKON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
662 #define NIKON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
663 #define NIKON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
664 #define NIKON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NIKON_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
665 #define NIKON_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * NIKON_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5)
666
667 #define KATHREIN_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
668 #define KATHREIN_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
669 #define KATHREIN_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
670 #define KATHREIN_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
671 #define KATHREIN_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
672 #define KATHREIN_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
673 #define KATHREIN_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
674 #define KATHREIN_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
675 #define KATHREIN_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
676 #define KATHREIN_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
677 #define KATHREIN_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
678 #define KATHREIN_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
679 #define KATHREIN_SYNC_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KATHREIN_SYNC_BIT_PAUSE_LEN_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
680 #define KATHREIN_SYNC_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KATHREIN_SYNC_BIT_PAUSE_LEN_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
681
682 #define NETBOX_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NETBOX_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
683 #define NETBOX_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NETBOX_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
684 #define NETBOX_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NETBOX_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
685 #define NETBOX_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NETBOX_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
686 #define NETBOX_PULSE_LEN ((uint8_t)(F_INTERRUPTS * NETBOX_PULSE_TIME))
687 #define NETBOX_PAUSE_LEN ((uint8_t)(F_INTERRUPTS * NETBOX_PAUSE_TIME))
688 #define NETBOX_PULSE_REST_LEN ((uint8_t)(F_INTERRUPTS * NETBOX_PULSE_TIME / 4))
689 #define NETBOX_PAUSE_REST_LEN ((uint8_t)(F_INTERRUPTS * NETBOX_PAUSE_TIME / 4))
690
691 #define LEGO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
692 #define LEGO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
693 #define LEGO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
694 #define LEGO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
695 #define LEGO_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
696 #define LEGO_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
697 #define LEGO_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
698 #define LEGO_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
699 #define LEGO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
700 #define LEGO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
701
702 #define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t!
703
704 #ifdef ANALYZE
705 #define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } }
706 #define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } }
707 #define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } }
708 #define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } }
709 static int silent;
710 static int time_counter;
711 static int verbose;
712 #else
713 #define ANALYZE_PUTCHAR(a)
714 #define ANALYZE_ONLY_NORMAL_PUTCHAR(a)
715 #define ANALYZE_PRINTF(...)
716 #define ANALYZE_NEWLINE()
717 #endif
718
719 #if IRMP_USE_CALLBACK == 1
720 static void (*irmp_callback_ptr) (uint8_t);
721 #endif // IRMP_USE_CALLBACK == 1
722
723 /*---------------------------------------------------------------------------------------------------------------------------------------------------
724 * Protocol names
725 *---------------------------------------------------------------------------------------------------------------------------------------------------
726 */
727 #if IRMP_PROTOCOL_NAMES == 1
728 char *
729 irmp_protocol_names[IRMP_N_PROTOCOLS + 1] =
730 {
731 "UNKNOWN",
732 "SIRCS",
733 "NEC",
734 "SAMSUNG",
735 "MATSUSH",
736 "KASEIKYO",
737 "RECS80",
738 "RC5",
739 "DENON",
740 "RC6",
741 "SAMSG32",
742 "APPLE",
743 "RECS80EX",
744 "NUBERT",
745 "BANG OLU",
746 "GRUNDIG",
747 "NOKIA",
748 "SIEMENS",
749 "FDC",
750 "RCCAR",
751 "JVC",
752 "RC6A",
753 "NIKON",
754 "RUWIDO",
755 "IR60",
756 "KATHREIN",
757 "NETBOX",
758 "NEC16",
759 "NEC42",
760 "LEGO",
761 "THOMSON"
762 };
763 #endif
764
765 /*---------------------------------------------------------------------------------------------------------------------------------------------------
766 * Logging
767 *---------------------------------------------------------------------------------------------------------------------------------------------------
768 */
769 #if IRMP_LOGGING == 1 // logging via UART
770
771 #if IRMP_EXT_LOGGING == 1 // use external logging
772 #include "irmpextlog.h"
773 #else // normal UART log (IRMP_EXT_LOGGING == 0)
774 #define BAUD 9600L
775 #include <util/setbaud.h>
776
777 #ifdef UBRR0H
778
779 #define UART0_UBRRH UBRR0H
780 #define UART0_UBRRL UBRR0L
781 #define UART0_UCSRA UCSR0A
782 #define UART0_UCSRB UCSR0B
783 #define UART0_UCSRC UCSR0C
784 #define UART0_UDRE_BIT_VALUE (1<<UDRE0)
785 #define UART0_UCSZ1_BIT_VALUE (1<<UCSZ01)
786 #define UART0_UCSZ0_BIT_VALUE (1<<UCSZ00)
787 #ifdef URSEL0
788 #define UART0_URSEL_BIT_VALUE (1<<URSEL0)
789 #else
790 #define UART0_URSEL_BIT_VALUE (0)
791 #endif
792 #define UART0_TXEN_BIT_VALUE (1<<TXEN0)
793 #define UART0_UDR UDR0
794 #define UART0_U2X U2X0
795
796 #else
797
798 #define UART0_UBRRH UBRRH
799 #define UART0_UBRRL UBRRL
800 #define UART0_UCSRA UCSRA
801 #define UART0_UCSRB UCSRB
802 #define UART0_UCSRC UCSRC
803 #define UART0_UDRE_BIT_VALUE (1<<UDRE)
804 #define UART0_UCSZ1_BIT_VALUE (1<<UCSZ1)
805 #define UART0_UCSZ0_BIT_VALUE (1<<UCSZ0)
806 #ifdef URSEL
807 #define UART0_URSEL_BIT_VALUE (1<<URSEL)
808 #else
809 #define UART0_URSEL_BIT_VALUE (0)
810 #endif
811 #define UART0_TXEN_BIT_VALUE (1<<TXEN)
812 #define UART0_UDR UDR
813 #define UART0_U2X U2X
814
815 #endif //UBRR0H
816 #endif //IRMP_EXT_LOGGING
817
818 /*---------------------------------------------------------------------------------------------------------------------------------------------------
819 * Initialize UART
820 * @details Initializes UART
821 *---------------------------------------------------------------------------------------------------------------------------------------------------
822 */
823 void
824 irmp_uart_init (void)
825 {
826 #if (IRMP_EXT_LOGGING == 0) // use UART
827 UART0_UBRRH = UBRRH_VALUE; // set baud rate
828 UART0_UBRRL = UBRRL_VALUE;
829
830 #if USE_2X
831 UART0_UCSRA |= (1<<UART0_U2X);
832 #else
833 UART0_UCSRA &= ~(1<<UART0_U2X);
834 #endif
835
836 UART0_UCSRC = UART0_UCSZ1_BIT_VALUE | UART0_UCSZ0_BIT_VALUE | UART0_URSEL_BIT_VALUE;
837 UART0_UCSRB |= UART0_TXEN_BIT_VALUE; // enable UART TX
838 #else // other log method
839 initextlog();
840 #endif //IRMP_EXT_LOGGING
841 }
842
843 /*---------------------------------------------------------------------------------------------------------------------------------------------------
844 * Send character
845 * @details Sends character
846 * @param ch character to be transmitted
847 *---------------------------------------------------------------------------------------------------------------------------------------------------
848 */
849 void
850 irmp_uart_putc (unsigned char ch)
851 {
852 #if (IRMP_EXT_LOGGING == 0)
853 while (!(UART0_UCSRA & UART0_UDRE_BIT_VALUE))
854 {
855 ;
856 }
857
858 UART0_UDR = ch;
859 #else
860 sendextlog(ch); //Use external log
861 #endif
862 }
863
864 /*---------------------------------------------------------------------------------------------------------------------------------------------------
865 * Log IR signal
866 *---------------------------------------------------------------------------------------------------------------------------------------------------
867 */
868
869 #define STARTCYCLES 2 // min count of zeros before start of logging
870 #define ENDBITS 1000 // number of sequenced highbits to detect end
871 #define DATALEN 700 // log buffer size
872
873 static void
874 irmp_log (uint8_t val)
875 {
876 static uint8_t buf[DATALEN]; // logging buffer
877 static uint16_t buf_idx; // number of written bits
878 static uint8_t startcycles; // current number of start-zeros
879 static uint16_t cnt; // counts sequenced highbits - to detect end
880
881 if (! val && (startcycles < STARTCYCLES) && !buf_idx) // prevent that single random zeros init logging
882 {
883 startcycles++;
884 }
885 else
886 {
887 startcycles = 0;
888
889 if (! val || (val && buf_idx != 0)) // start or continue logging on "0", "1" cannot init logging
890 {
891 if (buf_idx < DATALEN * 8) // index in range?
892 { // yes
893 if (val)
894 {
895 buf[(buf_idx / 8)] |= (1<<(buf_idx % 8)); // set bit
896 }
897 else
898 {
899 buf[(buf_idx / 8)] &= ~(1<<(buf_idx % 8)); // reset bit
900 }
901
902 buf_idx++;
903 }
904
905 if (val)
906 { // if high received then look at log-stop condition
907 cnt++;
908
909 if (cnt > ENDBITS)
910 { // if stop condition is true, output on uart
911 uint16_t i;
912
913 for (i = 0; i < STARTCYCLES; i++)
914 {
915 irmp_uart_putc ('0'); // the ignored starting zeros
916 }
917
918 for (i = 0; i < (buf_idx - ENDBITS + 20) / 8; i++) // transform bitset into uart chars
919 {
920 uint8_t d = buf[i];
921 uint8_t j;
922
923 for (j = 0; j < 8; j++)
924 {
925 irmp_uart_putc ((d & 1) + '0');
926 d >>= 1;
927 }
928 }
929
930 irmp_uart_putc ('\n');
931 buf_idx = 0;
932 }
933 }
934 else
935 {
936 cnt = 0;
937 }
938 }
939 }
940 }
941
942 #else
943 #define irmp_log(val)
944 #endif //IRMP_LOGGING
945
946 typedef struct
947 {
948 uint8_t protocol; // ir protocol
949 uint8_t pulse_1_len_min; // minimum length of pulse with bit value 1
950 uint8_t pulse_1_len_max; // maximum length of pulse with bit value 1
951 uint8_t pause_1_len_min; // minimum length of pause with bit value 1
952 uint8_t pause_1_len_max; // maximum length of pause with bit value 1
953 uint8_t pulse_0_len_min; // minimum length of pulse with bit value 0
954 uint8_t pulse_0_len_max; // maximum length of pulse with bit value 0
955 uint8_t pause_0_len_min; // minimum length of pause with bit value 0
956 uint8_t pause_0_len_max; // maximum length of pause with bit value 0
957 uint8_t address_offset; // address offset
958 uint8_t address_end; // end of address
959 uint8_t command_offset; // command offset
960 uint8_t command_end; // end of command
961 uint8_t complete_len; // complete length of frame
962 uint8_t stop_bit; // flag: frame has stop bit
963 uint8_t lsb_first; // flag: LSB first
964 uint8_t flags; // some flags
965 } IRMP_PARAMETER;
966
967 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
968
969 static const PROGMEM IRMP_PARAMETER sircs_param =
970 {
971 IRMP_SIRCS_PROTOCOL, // protocol: ir protocol
972 SIRCS_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
973 SIRCS_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
974 SIRCS_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
975 SIRCS_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
976 SIRCS_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
977 SIRCS_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
978 SIRCS_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
979 SIRCS_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
980 SIRCS_ADDRESS_OFFSET, // address_offset: address offset
981 SIRCS_ADDRESS_OFFSET + SIRCS_ADDRESS_LEN, // address_end: end of address
982 SIRCS_COMMAND_OFFSET, // command_offset: command offset
983 SIRCS_COMMAND_OFFSET + SIRCS_COMMAND_LEN, // command_end: end of command
984 SIRCS_COMPLETE_DATA_LEN, // complete_len: complete length of frame
985 SIRCS_STOP_BIT, // stop_bit: flag: frame has stop bit
986 SIRCS_LSB, // lsb_first: flag: LSB first
987 SIRCS_FLAGS // flags: some flags
988 };
989
990 #endif
991
992 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
993
994 static const PROGMEM IRMP_PARAMETER nec_param =
995 {
996 IRMP_NEC_PROTOCOL, // protocol: ir protocol
997 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
998 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
999 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1000 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1001 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1002 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1003 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1004 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1005 NEC_ADDRESS_OFFSET, // address_offset: address offset
1006 NEC_ADDRESS_OFFSET + NEC_ADDRESS_LEN, // address_end: end of address
1007 NEC_COMMAND_OFFSET, // command_offset: command offset
1008 NEC_COMMAND_OFFSET + NEC_COMMAND_LEN, // command_end: end of command
1009 NEC_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1010 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit
1011 NEC_LSB, // lsb_first: flag: LSB first
1012 NEC_FLAGS // flags: some flags
1013 };
1014
1015 static const PROGMEM IRMP_PARAMETER nec_rep_param =
1016 {
1017 IRMP_NEC_PROTOCOL, // protocol: ir protocol
1018 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1019 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1020 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1021 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1022 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1023 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1024 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1025 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1026 0, // address_offset: address offset
1027 0, // address_end: end of address
1028 0, // command_offset: command offset
1029 0, // command_end: end of command
1030 0, // complete_len: complete length of frame
1031 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit
1032 NEC_LSB, // lsb_first: flag: LSB first
1033 NEC_FLAGS // flags: some flags
1034 };
1035
1036 #endif
1037
1038 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
1039
1040 static const PROGMEM IRMP_PARAMETER nec42_param =
1041 {
1042 IRMP_NEC42_PROTOCOL, // protocol: ir protocol
1043 NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1044 NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1045 NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1046 NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1047 NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1048 NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1049 NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1050 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1051 NEC42_ADDRESS_OFFSET, // address_offset: address offset
1052 NEC42_ADDRESS_OFFSET + NEC42_ADDRESS_LEN, // address_end: end of address
1053 NEC42_COMMAND_OFFSET, // command_offset: command offset
1054 NEC42_COMMAND_OFFSET + NEC42_COMMAND_LEN, // command_end: end of command
1055 NEC42_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1056 NEC_STOP_BIT, // stop_bit: flag: frame has stop bit
1057 NEC_LSB, // lsb_first: flag: LSB first
1058 NEC_FLAGS // flags: some flags
1059 };
1060
1061 #endif
1062
1063 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1064
1065 static const PROGMEM IRMP_PARAMETER samsung_param =
1066 {
1067 IRMP_SAMSUNG_PROTOCOL, // protocol: ir protocol
1068 SAMSUNG_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1069 SAMSUNG_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1070 SAMSUNG_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1071 SAMSUNG_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1072 SAMSUNG_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1073 SAMSUNG_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1074 SAMSUNG_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1075 SAMSUNG_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1076 SAMSUNG_ADDRESS_OFFSET, // address_offset: address offset
1077 SAMSUNG_ADDRESS_OFFSET + SAMSUNG_ADDRESS_LEN, // address_end: end of address
1078 SAMSUNG_COMMAND_OFFSET, // command_offset: command offset
1079 SAMSUNG_COMMAND_OFFSET + SAMSUNG_COMMAND_LEN, // command_end: end of command
1080 SAMSUNG_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1081 SAMSUNG_STOP_BIT, // stop_bit: flag: frame has stop bit
1082 SAMSUNG_LSB, // lsb_first: flag: LSB first
1083 SAMSUNG_FLAGS // flags: some flags
1084 };
1085
1086 #endif
1087
1088 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
1089
1090 static const PROGMEM IRMP_PARAMETER matsushita_param =
1091 {
1092 IRMP_MATSUSHITA_PROTOCOL, // protocol: ir protocol
1093 MATSUSHITA_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1094 MATSUSHITA_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1095 MATSUSHITA_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1096 MATSUSHITA_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1097 MATSUSHITA_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1098 MATSUSHITA_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1099 MATSUSHITA_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1100 MATSUSHITA_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1101 MATSUSHITA_ADDRESS_OFFSET, // address_offset: address offset
1102 MATSUSHITA_ADDRESS_OFFSET + MATSUSHITA_ADDRESS_LEN, // address_end: end of address
1103 MATSUSHITA_COMMAND_OFFSET, // command_offset: command offset
1104 MATSUSHITA_COMMAND_OFFSET + MATSUSHITA_COMMAND_LEN, // command_end: end of command
1105 MATSUSHITA_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1106 MATSUSHITA_STOP_BIT, // stop_bit: flag: frame has stop bit
1107 MATSUSHITA_LSB, // lsb_first: flag: LSB first
1108 MATSUSHITA_FLAGS // flags: some flags
1109 };
1110
1111 #endif
1112
1113 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1114
1115 static const PROGMEM IRMP_PARAMETER kaseikyo_param =
1116 {
1117 IRMP_KASEIKYO_PROTOCOL, // protocol: ir protocol
1118 KASEIKYO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1119 KASEIKYO_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1120 KASEIKYO_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1121 KASEIKYO_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1122 KASEIKYO_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1123 KASEIKYO_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1124 KASEIKYO_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1125 KASEIKYO_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1126 KASEIKYO_ADDRESS_OFFSET, // address_offset: address offset
1127 KASEIKYO_ADDRESS_OFFSET + KASEIKYO_ADDRESS_LEN, // address_end: end of address
1128 KASEIKYO_COMMAND_OFFSET, // command_offset: command offset
1129 KASEIKYO_COMMAND_OFFSET + KASEIKYO_COMMAND_LEN, // command_end: end of command
1130 KASEIKYO_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1131 KASEIKYO_STOP_BIT, // stop_bit: flag: frame has stop bit
1132 KASEIKYO_LSB, // lsb_first: flag: LSB first
1133 KASEIKYO_FLAGS // flags: some flags
1134 };
1135
1136 #endif
1137
1138 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
1139
1140 static const PROGMEM IRMP_PARAMETER recs80_param =
1141 {
1142 IRMP_RECS80_PROTOCOL, // protocol: ir protocol
1143 RECS80_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1144 RECS80_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1145 RECS80_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1146 RECS80_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1147 RECS80_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1148 RECS80_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1149 RECS80_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1150 RECS80_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1151 RECS80_ADDRESS_OFFSET, // address_offset: address offset
1152 RECS80_ADDRESS_OFFSET + RECS80_ADDRESS_LEN, // address_end: end of address
1153 RECS80_COMMAND_OFFSET, // command_offset: command offset
1154 RECS80_COMMAND_OFFSET + RECS80_COMMAND_LEN, // command_end: end of command
1155 RECS80_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1156 RECS80_STOP_BIT, // stop_bit: flag: frame has stop bit
1157 RECS80_LSB, // lsb_first: flag: LSB first
1158 RECS80_FLAGS // flags: some flags
1159 };
1160
1161 #endif
1162
1163 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1164
1165 static const PROGMEM IRMP_PARAMETER rc5_param =
1166 {
1167 IRMP_RC5_PROTOCOL, // protocol: ir protocol
1168 RC5_BIT_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1169 RC5_BIT_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1170 RC5_BIT_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1171 RC5_BIT_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1172 0, // pulse_0_len_min: here: not used
1173 0, // pulse_0_len_max: here: not used
1174 0, // pause_0_len_min: here: not used
1175 0, // pause_0_len_max: here: not used
1176 RC5_ADDRESS_OFFSET, // address_offset: address offset
1177 RC5_ADDRESS_OFFSET + RC5_ADDRESS_LEN, // address_end: end of address
1178 RC5_COMMAND_OFFSET, // command_offset: command offset
1179 RC5_COMMAND_OFFSET + RC5_COMMAND_LEN, // command_end: end of command
1180 RC5_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1181 RC5_STOP_BIT, // stop_bit: flag: frame has stop bit
1182 RC5_LSB, // lsb_first: flag: LSB first
1183 RC5_FLAGS // flags: some flags
1184 };
1185
1186 #endif
1187
1188 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1189
1190 static const PROGMEM IRMP_PARAMETER denon_param =
1191 {
1192 IRMP_DENON_PROTOCOL, // protocol: ir protocol
1193 DENON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1194 DENON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1195 DENON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1196 DENON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1197 DENON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1198 DENON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1199 DENON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1200 DENON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1201 DENON_ADDRESS_OFFSET, // address_offset: address offset
1202 DENON_ADDRESS_OFFSET + DENON_ADDRESS_LEN, // address_end: end of address
1203 DENON_COMMAND_OFFSET, // command_offset: command offset
1204 DENON_COMMAND_OFFSET + DENON_COMMAND_LEN, // command_end: end of command
1205 DENON_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1206 DENON_STOP_BIT, // stop_bit: flag: frame has stop bit
1207 DENON_LSB, // lsb_first: flag: LSB first
1208 DENON_FLAGS // flags: some flags
1209 };
1210
1211 #endif
1212
1213 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1214
1215 static const PROGMEM IRMP_PARAMETER rc6_param =
1216 {
1217 IRMP_RC6_PROTOCOL, // protocol: ir protocol
1218
1219 RC6_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1220 RC6_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1221 RC6_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1222 RC6_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1223 0, // pulse_0_len_min: here: not used
1224 0, // pulse_0_len_max: here: not used
1225 0, // pause_0_len_min: here: not used
1226 0, // pause_0_len_max: here: not used
1227 RC6_ADDRESS_OFFSET, // address_offset: address offset
1228 RC6_ADDRESS_OFFSET + RC6_ADDRESS_LEN, // address_end: end of address
1229 RC6_COMMAND_OFFSET, // command_offset: command offset
1230 RC6_COMMAND_OFFSET + RC6_COMMAND_LEN, // command_end: end of command
1231 RC6_COMPLETE_DATA_LEN_SHORT, // complete_len: complete length of frame
1232 RC6_STOP_BIT, // stop_bit: flag: frame has stop bit
1233 RC6_LSB, // lsb_first: flag: LSB first
1234 RC6_FLAGS // flags: some flags
1235 };
1236
1237 #endif
1238
1239 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
1240
1241 static const PROGMEM IRMP_PARAMETER recs80ext_param =
1242 {
1243 IRMP_RECS80EXT_PROTOCOL, // protocol: ir protocol
1244 RECS80EXT_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1245 RECS80EXT_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1246 RECS80EXT_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1247 RECS80EXT_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1248 RECS80EXT_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1249 RECS80EXT_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1250 RECS80EXT_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1251 RECS80EXT_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1252 RECS80EXT_ADDRESS_OFFSET, // address_offset: address offset
1253 RECS80EXT_ADDRESS_OFFSET + RECS80EXT_ADDRESS_LEN, // address_end: end of address
1254 RECS80EXT_COMMAND_OFFSET, // command_offset: command offset
1255 RECS80EXT_COMMAND_OFFSET + RECS80EXT_COMMAND_LEN, // command_end: end of command
1256 RECS80EXT_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1257 RECS80EXT_STOP_BIT, // stop_bit: flag: frame has stop bit
1258 RECS80EXT_LSB, // lsb_first: flag: LSB first
1259 RECS80EXT_FLAGS // flags: some flags
1260 };
1261
1262 #endif
1263
1264 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1265
1266 static const PROGMEM IRMP_PARAMETER nubert_param =
1267 {
1268 IRMP_NUBERT_PROTOCOL, // protocol: ir protocol
1269 NUBERT_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1270 NUBERT_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1271 NUBERT_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1272 NUBERT_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1273 NUBERT_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1274 NUBERT_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1275 NUBERT_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1276 NUBERT_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1277 NUBERT_ADDRESS_OFFSET, // address_offset: address offset
1278 NUBERT_ADDRESS_OFFSET + NUBERT_ADDRESS_LEN, // address_end: end of address
1279 NUBERT_COMMAND_OFFSET, // command_offset: command offset
1280 NUBERT_COMMAND_OFFSET + NUBERT_COMMAND_LEN, // command_end: end of command
1281 NUBERT_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1282 NUBERT_STOP_BIT, // stop_bit: flag: frame has stop bit
1283 NUBERT_LSB, // lsb_first: flag: LSB first
1284 NUBERT_FLAGS // flags: some flags
1285 };
1286
1287 #endif
1288
1289 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1290
1291 static const PROGMEM IRMP_PARAMETER bang_olufsen_param =
1292 {
1293 IRMP_BANG_OLUFSEN_PROTOCOL, // protocol: ir protocol
1294 BANG_OLUFSEN_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1295 BANG_OLUFSEN_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1296 BANG_OLUFSEN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1297 BANG_OLUFSEN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1298 BANG_OLUFSEN_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1299 BANG_OLUFSEN_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1300 BANG_OLUFSEN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1301 BANG_OLUFSEN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1302 BANG_OLUFSEN_ADDRESS_OFFSET, // address_offset: address offset
1303 BANG_OLUFSEN_ADDRESS_OFFSET + BANG_OLUFSEN_ADDRESS_LEN, // address_end: end of address
1304 BANG_OLUFSEN_COMMAND_OFFSET, // command_offset: command offset
1305 BANG_OLUFSEN_COMMAND_OFFSET + BANG_OLUFSEN_COMMAND_LEN, // command_end: end of command
1306 BANG_OLUFSEN_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1307 BANG_OLUFSEN_STOP_BIT, // stop_bit: flag: frame has stop bit
1308 BANG_OLUFSEN_LSB, // lsb_first: flag: LSB first
1309 BANG_OLUFSEN_FLAGS // flags: some flags
1310 };
1311
1312 #endif
1313
1314 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
1315
1316 static uint8_t first_bit;
1317
1318 static const PROGMEM IRMP_PARAMETER grundig_param =
1319 {
1320 IRMP_GRUNDIG_PROTOCOL, // protocol: ir protocol
1321
1322 GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1323 GRUNDIG_NOKIA_IR60_BIT_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1324 GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1325 GRUNDIG_NOKIA_IR60_BIT_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1326 0, // pulse_0_len_min: here: not used
1327 0, // pulse_0_len_max: here: not used
1328 0, // pause_0_len_min: here: not used
1329 0, // pause_0_len_max: here: not used
1330 GRUNDIG_ADDRESS_OFFSET, // address_offset: address offset
1331 GRUNDIG_ADDRESS_OFFSET + GRUNDIG_ADDRESS_LEN, // address_end: end of address
1332 GRUNDIG_COMMAND_OFFSET, // command_offset: command offset
1333 GRUNDIG_COMMAND_OFFSET + GRUNDIG_COMMAND_LEN + 1, // command_end: end of command (USE 1 bit MORE to STORE NOKIA DATA!)
1334 NOKIA_COMPLETE_DATA_LEN, // complete_len: complete length of frame, here: NOKIA instead of GRUNDIG!
1335 GRUNDIG_NOKIA_IR60_STOP_BIT, // stop_bit: flag: frame has stop bit
1336 GRUNDIG_NOKIA_IR60_LSB, // lsb_first: flag: LSB first
1337 GRUNDIG_NOKIA_IR60_FLAGS // flags: some flags
1338 };
1339
1340 #endif
1341
1342 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
1343
1344 static const PROGMEM IRMP_PARAMETER ruwido_param =
1345 {
1346 IRMP_RUWIDO_PROTOCOL, // protocol: ir protocol
1347 SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1348 SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1349 SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1350 SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1351 0, // pulse_0_len_min: here: not used
1352 0, // pulse_0_len_max: here: not used
1353 0, // pause_0_len_min: here: not used
1354 0, // pause_0_len_max: here: not used
1355 RUWIDO_ADDRESS_OFFSET, // address_offset: address offset
1356 RUWIDO_ADDRESS_OFFSET + RUWIDO_ADDRESS_LEN, // address_end: end of address
1357 RUWIDO_COMMAND_OFFSET, // command_offset: command offset
1358 RUWIDO_COMMAND_OFFSET + RUWIDO_COMMAND_LEN, // command_end: end of command
1359 SIEMENS_COMPLETE_DATA_LEN, // complete_len: complete length of frame, here: SIEMENS instead of RUWIDO!
1360 SIEMENS_OR_RUWIDO_STOP_BIT, // stop_bit: flag: frame has stop bit
1361 SIEMENS_OR_RUWIDO_LSB, // lsb_first: flag: LSB first
1362 SIEMENS_OR_RUWIDO_FLAGS // flags: some flags
1363 };
1364
1365 #endif
1366
1367 #if IRMP_SUPPORT_GRUNDIG2_PROTOCOL == 1
1368
1369 static const PROGMEM IRMP_PARAMETER grundig2_param =
1370 {
1371 IRMP_GRUNDIG2_PROTOCOL, // protocol: ir protocol
1372 GRUNDIG2_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse
1373 GRUNDIG2_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse
1374 GRUNDIG2_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause
1375 GRUNDIG2_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause
1376 0, // pulse_0_len_min: here: not used
1377 0, // pulse_0_len_max: here: not used
1378 0, // pause_0_len_min: here: not used
1379 0, // pause_0_len_max: here: not used
1380 GRUNDIG2_ADDRESS_OFFSET, // address_offset: address offset
1381 GRUNDIG2_ADDRESS_OFFSET + GRUNDIG2_ADDRESS_LEN, // address_end: end of address
1382 GRUNDIG2_COMMAND_OFFSET, // command_offset: command offset
1383 GRUNDIG2_COMMAND_OFFSET + GRUNDIG2_COMMAND_LEN, // command_end: end of command
1384 GRUNDIG2_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1385 GRUNDIG2_STOP_BIT, // stop_bit: flag: frame has stop bit
1386 GRUNDIG2_LSB, // lsb_first: flag: LSB first
1387 GRUNDIG2_FLAGS // flags: some flags
1388 };
1389
1390 #endif
1391
1392 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
1393
1394 static const PROGMEM IRMP_PARAMETER fdc_param =
1395 {
1396 IRMP_FDC_PROTOCOL, // protocol: ir protocol
1397 FDC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1398 FDC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1399 FDC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1400 FDC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1401 FDC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1402 FDC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1403 FDC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1404 FDC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1405 FDC_ADDRESS_OFFSET, // address_offset: address offset
1406 FDC_ADDRESS_OFFSET + FDC_ADDRESS_LEN, // address_end: end of address
1407 FDC_COMMAND_OFFSET, // command_offset: command offset
1408 FDC_COMMAND_OFFSET + FDC_COMMAND_LEN, // command_end: end of command
1409 FDC_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1410 FDC_STOP_BIT, // stop_bit: flag: frame has stop bit
1411 FDC_LSB, // lsb_first: flag: LSB first
1412 FDC_FLAGS // flags: some flags
1413 };
1414
1415 #endif
1416
1417 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
1418
1419 static const PROGMEM IRMP_PARAMETER rccar_param =
1420 {
1421 IRMP_RCCAR_PROTOCOL, // protocol: ir protocol
1422 RCCAR_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1423 RCCAR_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1424 RCCAR_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1425 RCCAR_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1426 RCCAR_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1427 RCCAR_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1428 RCCAR_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1429 RCCAR_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1430 RCCAR_ADDRESS_OFFSET, // address_offset: address offset
1431 RCCAR_ADDRESS_OFFSET + RCCAR_ADDRESS_LEN, // address_end: end of address
1432 RCCAR_COMMAND_OFFSET, // command_offset: command offset
1433 RCCAR_COMMAND_OFFSET + RCCAR_COMMAND_LEN, // command_end: end of command
1434 RCCAR_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1435 RCCAR_STOP_BIT, // stop_bit: flag: frame has stop bit
1436 RCCAR_LSB, // lsb_first: flag: LSB first
1437 RCCAR_FLAGS // flags: some flags
1438 };
1439
1440 #endif
1441
1442 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1
1443
1444 static const PROGMEM IRMP_PARAMETER nikon_param =
1445 {
1446 IRMP_NIKON_PROTOCOL, // protocol: ir protocol
1447 NIKON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1448 NIKON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1449 NIKON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1450 NIKON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1451 NIKON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1452 NIKON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1453 NIKON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1454 NIKON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1455 NIKON_ADDRESS_OFFSET, // address_offset: address offset
1456 NIKON_ADDRESS_OFFSET + NIKON_ADDRESS_LEN, // address_end: end of address
1457 NIKON_COMMAND_OFFSET, // command_offset: command offset
1458 NIKON_COMMAND_OFFSET + NIKON_COMMAND_LEN, // command_end: end of command
1459 NIKON_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1460 NIKON_STOP_BIT, // stop_bit: flag: frame has stop bit
1461 NIKON_LSB, // lsb_first: flag: LSB first
1462 NIKON_FLAGS // flags: some flags
1463 };
1464
1465 #endif
1466
1467 #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
1468
1469 static const PROGMEM IRMP_PARAMETER kathrein_param =
1470 {
1471 IRMP_KATHREIN_PROTOCOL, // protocol: ir protocol
1472 KATHREIN_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1473 KATHREIN_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1474 KATHREIN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1475 KATHREIN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1476 KATHREIN_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1477 KATHREIN_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1478 KATHREIN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1479 KATHREIN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1480 KATHREIN_ADDRESS_OFFSET, // address_offset: address offset
1481 KATHREIN_ADDRESS_OFFSET + KATHREIN_ADDRESS_LEN, // address_end: end of address
1482 KATHREIN_COMMAND_OFFSET, // command_offset: command offset
1483 KATHREIN_COMMAND_OFFSET + KATHREIN_COMMAND_LEN, // command_end: end of command
1484 KATHREIN_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1485 KATHREIN_STOP_BIT, // stop_bit: flag: frame has stop bit
1486 KATHREIN_LSB, // lsb_first: flag: LSB first
1487 KATHREIN_FLAGS // flags: some flags
1488 };
1489
1490 #endif
1491
1492 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1
1493
1494 static const PROGMEM IRMP_PARAMETER netbox_param =
1495 {
1496 IRMP_NETBOX_PROTOCOL, // protocol: ir protocol
1497 NETBOX_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1, here: exact value
1498 NETBOX_PULSE_REST_LEN, // pulse_1_len_max: maximum length of pulse with bit value 1, here: rest value
1499 NETBOX_PAUSE_LEN, // pause_1_len_min: minimum length of pause with bit value 1, here: exact value
1500 NETBOX_PAUSE_REST_LEN, // pause_1_len_max: maximum length of pause with bit value 1, here: rest value
1501 NETBOX_PULSE_LEN, // pulse_0_len_min: minimum length of pulse with bit value 0, here: exact value
1502 NETBOX_PULSE_REST_LEN, // pulse_0_len_max: maximum length of pulse with bit value 0, here: rest value
1503 NETBOX_PAUSE_LEN, // pause_0_len_min: minimum length of pause with bit value 0, here: exact value
1504 NETBOX_PAUSE_REST_LEN, // pause_0_len_max: maximum length of pause with bit value 0, here: rest value
1505 NETBOX_ADDRESS_OFFSET, // address_offset: address offset
1506 NETBOX_ADDRESS_OFFSET + NETBOX_ADDRESS_LEN, // address_end: end of address
1507 NETBOX_COMMAND_OFFSET, // command_offset: command offset
1508 NETBOX_COMMAND_OFFSET + NETBOX_COMMAND_LEN, // command_end: end of command
1509 NETBOX_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1510 NETBOX_STOP_BIT, // stop_bit: flag: frame has stop bit
1511 NETBOX_LSB, // lsb_first: flag: LSB first
1512 NETBOX_FLAGS // flags: some flags
1513 };
1514
1515 #endif
1516
1517 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1
1518
1519 static const PROGMEM IRMP_PARAMETER lego_param =
1520 {
1521 IRMP_LEGO_PROTOCOL, // protocol: ir protocol
1522 LEGO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1523 LEGO_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1524 LEGO_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1525 LEGO_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1526 LEGO_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1527 LEGO_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1528 LEGO_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1529 LEGO_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1530 LEGO_ADDRESS_OFFSET, // address_offset: address offset
1531 LEGO_ADDRESS_OFFSET + LEGO_ADDRESS_LEN, // address_end: end of address
1532 LEGO_COMMAND_OFFSET, // command_offset: command offset
1533 LEGO_COMMAND_OFFSET + LEGO_COMMAND_LEN, // command_end: end of command
1534 LEGO_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1535 LEGO_STOP_BIT, // stop_bit: flag: frame has stop bit
1536 LEGO_LSB, // lsb_first: flag: LSB first
1537 LEGO_FLAGS // flags: some flags
1538 };
1539
1540 #endif
1541
1542 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1
1543
1544 static const PROGMEM IRMP_PARAMETER thomson_param =
1545 {
1546 IRMP_THOMSON_PROTOCOL, // protocol: ir protocol
1547 THOMSON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1
1548 THOMSON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1
1549 THOMSON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1
1550 THOMSON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1
1551 THOMSON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0
1552 THOMSON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0
1553 THOMSON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0
1554 THOMSON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0
1555 THOMSON_ADDRESS_OFFSET, // address_offset: address offset
1556 THOMSON_ADDRESS_OFFSET + THOMSON_ADDRESS_LEN, // address_end: end of address
1557 THOMSON_COMMAND_OFFSET, // command_offset: command offset
1558 THOMSON_COMMAND_OFFSET + THOMSON_COMMAND_LEN, // command_end: end of command
1559 THOMSON_COMPLETE_DATA_LEN, // complete_len: complete length of frame
1560 THOMSON_STOP_BIT, // stop_bit: flag: frame has stop bit
1561 THOMSON_LSB, // lsb_first: flag: LSB first
1562 THOMSON_FLAGS // flags: some flags
1563 };
1564
1565 #endif
1566
1567 static uint8_t irmp_bit; // current bit position
1568 static IRMP_PARAMETER irmp_param;
1569
1570 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
1571 static IRMP_PARAMETER irmp_param2;
1572 #endif
1573
1574 static volatile uint8_t irmp_ir_detected;
1575 static volatile uint8_t irmp_protocol;
1576 static volatile uint16_t irmp_address;
1577 static volatile uint16_t irmp_command;
1578 static volatile uint16_t irmp_id; // only used for SAMSUNG protocol
1579 static volatile uint8_t irmp_flags;
1580 // static volatile uint8_t irmp_busy_flag;
1581
1582 #ifdef ANALYZE
1583 static uint8_t IRMP_PIN;
1584 #endif
1585
1586 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1587 * Initialize IRMP decoder
1588 * @details Configures IRMP input pin
1589 *---------------------------------------------------------------------------------------------------------------------------------------------------
1590 */
1591 #ifndef ANALYZE
1592 void
1593 irmp_init (void)
1594 {
1595 #if !defined(PIC_CCS_COMPILER) && !defined(PIC_C18) // only AVR
1596 IRMP_PORT &= ~(1<<IRMP_BIT); // deactivate pullup
1597 IRMP_DDR &= ~(1<<IRMP_BIT); // set pin to input
1598 #endif
1599
1600 #if IRMP_LOGGING == 1
1601 irmp_uart_init ();
1602 #endif
1603 }
1604 #endif
1605 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1606 * Get IRMP data
1607 * @details gets decoded IRMP data
1608 * @param pointer in order to store IRMP data
1609 * @return TRUE: successful, FALSE: failed
1610 *---------------------------------------------------------------------------------------------------------------------------------------------------
1611 */
1612 uint8_t
1613 irmp_get_data (IRMP_DATA * irmp_data_p)
1614 {
1615 uint8_t rtc = FALSE;
1616
1617 if (irmp_ir_detected)
1618 {
1619 switch (irmp_protocol)
1620 {
1621 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1622 case IRMP_SAMSUNG_PROTOCOL:
1623 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))
1624 {
1625 irmp_command &= 0xff;
1626 irmp_command |= irmp_id << 8;
1627 rtc = TRUE;
1628 }
1629 break;
1630 #endif
1631 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
1632 case IRMP_NEC_PROTOCOL:
1633 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))
1634 {
1635 irmp_command &= 0xff;
1636 rtc = TRUE;
1637 }
1638 else if (irmp_address == 0x87EE)
1639 {
1640 ANALYZE_PRINTF ("Switching to APPLE protocol\n");
1641 irmp_protocol = IRMP_APPLE_PROTOCOL;
1642 irmp_address = (irmp_command & 0xFF00) >> 8;
1643 irmp_command &= 0x00FF;
1644 rtc = TRUE;
1645 }
1646 break;
1647 #endif
1648 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
1649 case IRMP_SIEMENS_PROTOCOL:
1650 case IRMP_RUWIDO_PROTOCOL:
1651 if (((irmp_command >> 1) & 0x0001) == (~irmp_command & 0x0001))
1652 {
1653 irmp_command >>= 1;
1654 rtc = TRUE;
1655 }
1656 break;
1657 #endif
1658 #if IRMP_SUPPORT_GRUNDIG2_PROTOCOL == 1
1659 case IRMP_GRUNDIG2_PROTOCOL:
1660 if (irmp_command & 0x0001)
1661 {
1662 irmp_command >>= 1;
1663 rtc = TRUE;
1664 }
1665 break;
1666 #endif
1667 #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
1668 case IRMP_KATHREIN_PROTOCOL:
1669 if (irmp_command != 0x0000)
1670 {
1671 rtc = TRUE;
1672 }
1673 break;
1674 #endif
1675 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1676 case IRMP_RC5_PROTOCOL:
1677 irmp_address &= ~0x20; // clear toggle bit
1678 rtc = TRUE;
1679 break;
1680 #endif
1681 #if IRMP_SUPPORT_IR60_PROTOCOL == 1
1682 case IRMP_IR60_PROTOCOL:
1683 if (irmp_command != 0x007d) // 0x007d (== 62<<1 + 1) is start instruction frame
1684 {
1685 rtc = TRUE;
1686 }
1687 break;
1688 #endif
1689 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
1690 case IRMP_RCCAR_PROTOCOL:
1691 // frame in irmp_data:
1692 // Bit 12 11 10 9 8 7 6 5 4 3 2 1 0
1693 // V D7 D6 D5 D4 D3 D2 D1 D0 A1 A0 C1 C0 // 10 9 8 7 6 5 4 3 2 1 0
1694 irmp_address = (irmp_command & 0x000C) >> 2; // addr: 0 0 0 0 0 0 0 0 0 A1 A0
1695 irmp_command = ((irmp_command & 0x1000) >> 2) | // V-Bit: V 0 0 0 0 0 0 0 0 0 0
1696 ((irmp_command & 0x0003) << 8) | // C-Bits: 0 C1 C0 0 0 0 0 0 0 0 0
1697 ((irmp_command & 0x0FF0) >> 4); // D-Bits: D7 D6 D5 D4 D3 D2 D1 D0
1698 rtc = TRUE; // Summe: V C1 C0 D7 D6 D5 D4 D3 D2 D1 D0
1699 break;
1700 #endif
1701
1702 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 // squeeze code to 8 bit, upper bit indicates release-key
1703 case IRMP_NETBOX_PROTOCOL:
1704 if (irmp_command & 0x1000) // last bit set?
1705 {
1706 if ((irmp_command & 0x1f) == 0x15) // key pressed: 101 01 (LSB)
1707 {
1708 irmp_command >>= 5;
1709 irmp_command &= 0x7F;
1710 rtc = TRUE;
1711 }
1712 else if ((irmp_command & 0x1f) == 0x10) // key released: 000 01 (LSB)
1713 {
1714 irmp_command >>= 5;
1715 irmp_command |= 0x80;
1716 rtc = TRUE;
1717 }
1718 else
1719 {
1720 ANALYZE_PRINTF("error NETBOX: bit6/7 must be 0/1\n");
1721 }
1722 }
1723 else
1724 {
1725 ANALYZE_PRINTF("error NETBOX: last bit not set\n");
1726 }
1727 break;
1728 #endif
1729 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1
1730 case IRMP_LEGO_PROTOCOL:
1731 {
1732 uint8_t crc = 0x0F ^ ((irmp_command & 0xF000) >> 12) ^ ((irmp_command & 0x0F00) >> 8) ^ ((irmp_command & 0x00F0) >> 4);
1733
1734 if ((irmp_command & 0x000F) == crc)
1735 {
1736 irmp_command >>= 4;
1737 rtc = TRUE;
1738 }
1739 else
1740 {
1741 ANALYZE_PRINTF ("CRC error in LEGO protocol\n");
1742 rtc = TRUE;
1743 }
1744 break;
1745 }
1746 #endif
1747 default:
1748 rtc = TRUE;
1749 }
1750
1751 if (rtc)
1752 {
1753 irmp_data_p->protocol = irmp_protocol;
1754 irmp_data_p->address = irmp_address;
1755 irmp_data_p->command = irmp_command;
1756 irmp_data_p->flags = irmp_flags;
1757 irmp_command = 0;
1758 irmp_address = 0;
1759 irmp_flags = 0;
1760 }
1761
1762 irmp_ir_detected = FALSE;
1763 }
1764
1765 return rtc;
1766 }
1767
1768 // uint8_t
1769 // irmp_is_busy (void)
1770 // {
1771 // return irmp_busy_flag;
1772 // }
1773
1774 #if IRMP_USE_CALLBACK == 1
1775 void
1776 irmp_set_callback_ptr (void (*cb)(uint8_t))
1777 {
1778 irmp_callback_ptr = cb;
1779 }
1780 #endif // IRMP_USE_CALLBACK == 1
1781
1782 // these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR()
1783 static uint16_t irmp_tmp_address; // ir address
1784 static uint16_t irmp_tmp_command; // ir command
1785
1786 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1
1787 static uint16_t irmp_tmp_address2; // ir address
1788 static uint16_t irmp_tmp_command2; // ir command
1789 #endif
1790
1791 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1792 static uint16_t irmp_tmp_id; // ir id (only SAMSUNG)
1793 #endif
1794 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1795 static uint8_t xor_check[6]; // check kaseikyo "parity" bits
1796 static uint8_t genre2; // save genre2 bits here, later copied to MSB in flags
1797 #endif
1798
1799 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1800 * store bit
1801 * @details store bit in temp address or temp command
1802 * @param value to store: 0 or 1
1803 *---------------------------------------------------------------------------------------------------------------------------------------------------
1804 */
1805 // verhindert, dass irmp_store_bit() inline compiliert wird:
1806 // static void irmp_store_bit (uint8_t) __attribute__ ((noinline));
1807
1808 static void
1809 irmp_store_bit (uint8_t value)
1810 {
1811 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
1812 if (irmp_bit == 0 && irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL)
1813 {
1814 first_bit = value;
1815 }
1816 else
1817 #endif
1818
1819 if (irmp_bit >= irmp_param.address_offset && irmp_bit < irmp_param.address_end)
1820 {
1821 if (irmp_param.lsb_first)
1822 {
1823 irmp_tmp_address |= (((uint16_t) (value)) << (irmp_bit - irmp_param.address_offset)); // CV wants cast
1824 }
1825 else
1826 {
1827 irmp_tmp_address <<= 1;
1828 irmp_tmp_address |= value;
1829 }
1830 }
1831 else if (irmp_bit >= irmp_param.command_offset && irmp_bit < irmp_param.command_end)
1832 {
1833 if (irmp_param.lsb_first)
1834 {
1835 irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast
1836 }
1837 else
1838 {
1839 irmp_tmp_command <<= 1;
1840 irmp_tmp_command |= value;
1841 }
1842 }
1843
1844 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
1845 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit >= 13 && irmp_bit < 26)
1846 {
1847 irmp_tmp_address2 |= (((uint16_t) (value)) << (irmp_bit - 13)); // CV wants cast
1848 }
1849 #endif
1850
1851 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1852 else if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit >= SAMSUNG_ID_OFFSET && irmp_bit < SAMSUNG_ID_OFFSET + SAMSUNG_ID_LEN)
1853 {
1854 irmp_tmp_id |= (((uint16_t) (value)) << (irmp_bit - SAMSUNG_ID_OFFSET)); // store with LSB first
1855 }
1856 #endif
1857
1858 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1859 else if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)
1860 {
1861 if (irmp_bit >= 20 && irmp_bit < 24)
1862 {
1863 irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first
1864 }
1865 else if (irmp_bit >= 24 && irmp_bit < 28)
1866 {
1867 genre2 |= (((uint8_t) (value)) << (irmp_bit - 20)); // store 4 system bits (genre 2) in upper nibble with LSB first
1868 }
1869
1870 if (irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)
1871 {
1872 if (value)
1873 {
1874 xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8);
1875 }
1876 else
1877 {
1878 xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8));
1879 }
1880 }
1881 }
1882 #endif
1883
1884 irmp_bit++;
1885 }
1886
1887 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1888 * store bit
1889 * @details store bit in temp address or temp command
1890 * @param value to store: 0 or 1
1891 *---------------------------------------------------------------------------------------------------------------------------------------------------
1892 */
1893 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
1894 static void
1895 irmp_store_bit2 (uint8_t value)
1896 {
1897 uint8_t irmp_bit2;
1898
1899 if (irmp_param.protocol)
1900 {
1901 irmp_bit2 = irmp_bit - 2;
1902 }
1903 else
1904 {
1905 irmp_bit2 = irmp_bit - 1;
1906 }
1907
1908 if (irmp_bit2 >= irmp_param2.address_offset && irmp_bit2 < irmp_param2.address_end)
1909 {
1910 irmp_tmp_address2 |= (((uint16_t) (value)) << (irmp_bit2 - irmp_param2.address_offset)); // CV wants cast
1911 }
1912 else if (irmp_bit2 >= irmp_param2.command_offset && irmp_bit2 < irmp_param2.command_end)
1913 {
1914 irmp_tmp_command2 |= (((uint16_t) (value)) << (irmp_bit2 - irmp_param2.command_offset)); // CV wants cast
1915 }
1916 }
1917 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
1918
1919 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1920 * ISR routine
1921 * @details ISR routine, called 10000 times per second
1922 *---------------------------------------------------------------------------------------------------------------------------------------------------
1923 */
1924 uint8_t
1925 irmp_ISR (void)
1926 {
1927 static uint8_t irmp_start_bit_detected; // flag: start bit detected
1928 static uint8_t wait_for_space; // flag: wait for data bit space
1929 static uint8_t wait_for_start_space; // flag: wait for start bit space
1930 static uint8_t irmp_pulse_time; // count bit time for pulse
1931 static PAUSE_LEN irmp_pause_time; // count bit time for pause
1932 static uint16_t last_irmp_address = 0xFFFF; // save last irmp address to recognize key repetition
1933 static uint16_t last_irmp_command = 0xFFFF; // save last irmp command to recognize key repetition
1934 static uint16_t repetition_len; // SIRCS repeats frame 2-5 times with 45 ms pause
1935 static uint8_t repetition_frame_number;
1936 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1937 static uint16_t last_irmp_denon_command; // save last irmp command to recognize DENON frame repetition
1938 #endif
1939 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1940 static uint8_t rc5_cmd_bit6; // bit 6 of RC5 command is the inverted 2nd start bit
1941 #endif
1942 #if IRMP_SUPPORT_MANCHESTER == 1
1943 static PAUSE_LEN last_pause; // last pause value
1944 #endif
1945 #if IRMP_SUPPORT_MANCHESTER == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1946 static uint8_t last_value; // last bit value
1947 #endif
1948 uint8_t irmp_input; // input value
1949
1950 #ifdef ANALYZE
1951 time_counter++;
1952 #endif
1953
1954 irmp_input = input(IRMP_PIN);
1955
1956 #if IRMP_USE_CALLBACK == 1
1957 if (irmp_callback_ptr)
1958 {
1959 static uint8_t last_inverted_input;
1960
1961 if (last_inverted_input != !irmp_input)
1962 {
1963 (*irmp_callback_ptr) (! irmp_input);
1964 last_inverted_input = !irmp_input;
1965 }
1966 }
1967 #endif // IRMP_USE_CALLBACK == 1
1968
1969 irmp_log(irmp_input); // log ir signal, if IRMP_LOGGING defined
1970
1971 if (! irmp_ir_detected) // ir code already detected?
1972 { // no...
1973 if (! irmp_start_bit_detected) // start bit detected?
1974 { // no...
1975 if (! irmp_input) // receiving burst?
1976 { // yes...
1977 // irmp_busy_flag = TRUE;
1978 #ifdef ANALYZE
1979 if (! irmp_pulse_time)
1980 {
1981 ANALYZE_PRINTF("%8.3fms [starting pulse]\n", (double) (time_counter * 1000) / F_INTERRUPTS);
1982 }
1983 #endif
1984 irmp_pulse_time++; // increment counter
1985 }
1986 else
1987 { // no...
1988 if (irmp_pulse_time) // it's dark....
1989 { // set flags for counting the time of darkness...
1990 irmp_start_bit_detected = 1;
1991 wait_for_start_space = 1;
1992 wait_for_space = 0;
1993 irmp_tmp_command = 0;
1994 irmp_tmp_address = 0;
1995 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1996 genre2 = 0;
1997 #endif
1998
1999 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1
2000 irmp_tmp_command2 = 0;
2001 irmp_tmp_address2 = 0;
2002 #endif
2003
2004 irmp_bit = 0xff;
2005 irmp_pause_time = 1; // 1st pause: set to 1, not to 0!
2006 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
2007 rc5_cmd_bit6 = 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame!
2008 #endif
2009 }
2010 else
2011 {
2012 if (repetition_len < 0xFFFF) // avoid overflow of counter
2013 {
2014 repetition_len++;
2015 }
2016 }
2017 }
2018 }
2019 else
2020 {
2021 if (wait_for_start_space) // we have received start bit...
2022 { // ...and are counting the time of darkness
2023 if (irmp_input) // still dark?
2024 { // yes
2025 irmp_pause_time++; // increment counter
2026
2027 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1
2028 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) ||
2029 irmp_pause_time > IRMP_TIMEOUT_NIKON_LEN)
2030 #else
2031 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?
2032 #endif
2033 { // yes...
2034 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2035 if (irmp_protocol == IRMP_JVC_PROTOCOL) // don't show eror if JVC protocol, irmp_pulse_time has been set below!
2036 {
2037 ;
2038 }
2039 else
2040 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2041 {
2042 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);
2043 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2044 }
2045 // irmp_busy_flag = FALSE;
2046 irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit
2047 irmp_pulse_time = 0;
2048 irmp_pause_time = 0;
2049 }
2050 }
2051 else
2052 { // receiving first data pulse!
2053 IRMP_PARAMETER * irmp_param_p = (IRMP_PARAMETER *) 0;
2054
2055 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2056 irmp_param2.protocol = 0;
2057 #endif
2058
2059 ANALYZE_PRINTF ("%8.3fms [start-bit: pulse = %2d, pause = %2d]\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);
2060
2061 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
2062 if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX &&
2063 irmp_pause_time >= SIRCS_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIRCS_START_BIT_PAUSE_LEN_MAX)
2064 { // it's SIRCS
2065 ANALYZE_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2066 SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX,
2067 SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX);
2068 irmp_param_p = (IRMP_PARAMETER *) (IRMP_PARAMETER *) &sircs_param;
2069 }
2070 else
2071 #endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1
2072
2073 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2074 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame
2075 irmp_pulse_time >= JVC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= JVC_START_BIT_PULSE_LEN_MAX &&
2076 irmp_pause_time >= JVC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= JVC_REPEAT_START_BIT_PAUSE_LEN_MAX)
2077 {
2078 ANALYZE_PRINTF ("protocol = NEC or JVC (type 1) repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2079 JVC_START_BIT_PULSE_LEN_MIN, JVC_START_BIT_PULSE_LEN_MAX,
2080 JVC_REPEAT_START_BIT_PAUSE_LEN_MIN, JVC_REPEAT_START_BIT_PAUSE_LEN_MAX);
2081 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
2082 }
2083 else
2084 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2085
2086 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2087 if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&
2088 irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)
2089 {
2090 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
2091 ANALYZE_PRINTF ("protocol = NEC42, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2092 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
2093 NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);
2094 irmp_param_p = (IRMP_PARAMETER *) &nec42_param;
2095 #else
2096 ANALYZE_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2097 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
2098 NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);
2099 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
2100 #endif
2101
2102 }
2103 else if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&
2104 irmp_pause_time >= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX)
2105 { // it's NEC
2106 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2107 if (irmp_protocol == IRMP_JVC_PROTOCOL) // last protocol was JVC, awaiting repeat frame
2108 { // some jvc remote controls use nec repetition frame for jvc repetition frame
2109 ANALYZE_PRINTF ("protocol = JVC repeat frame type 2, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2110 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
2111 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);
2112 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
2113 }
2114 else
2115 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2116 {
2117 ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2118 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
2119 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);
2120
2121 irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param;
2122 }
2123 }
2124 else
2125
2126 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2127 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame
2128 irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&
2129 irmp_pause_time >= NEC_0_PAUSE_LEN_MIN && irmp_pause_time <= NEC_0_PAUSE_LEN_MAX)
2130 { // it's JVC repetition type 3
2131 ANALYZE_PRINTF ("protocol = JVC repeat frame type 3, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2132 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
2133 NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX);
2134 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
2135 }
2136 else
2137 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2138
2139 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
2140
2141 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1
2142 if (irmp_pulse_time >= NIKON_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NIKON_START_BIT_PULSE_LEN_MAX &&
2143 irmp_pause_time >= NIKON_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NIKON_START_BIT_PAUSE_LEN_MAX)
2144 {
2145 ANALYZE_PRINTF ("protocol = NIKON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2146 NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX,
2147 NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX);
2148 irmp_param_p = (IRMP_PARAMETER *) &nikon_param;
2149 }
2150 else
2151 #endif // IRMP_SUPPORT_NIKON_PROTOCOL == 1
2152
2153 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2154 if (irmp_pulse_time >= SAMSUNG_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_START_BIT_PULSE_LEN_MAX &&
2155 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)
2156 { // it's SAMSUNG
2157 ANALYZE_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2158 SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX,
2159 SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX);
2160 irmp_param_p = (IRMP_PARAMETER *) &samsung_param;
2161 }
2162 else
2163 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2164
2165 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
2166 if (irmp_pulse_time >= MATSUSHITA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MATSUSHITA_START_BIT_PULSE_LEN_MAX &&
2167 irmp_pause_time >= MATSUSHITA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MATSUSHITA_START_BIT_PAUSE_LEN_MAX)
2168 { // it's MATSUSHITA
2169 ANALYZE_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2170 MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX,
2171 MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX);
2172 irmp_param_p = (IRMP_PARAMETER *) &matsushita_param;
2173 }
2174 else
2175 #endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
2176
2177 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2178 if (irmp_pulse_time >= KASEIKYO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KASEIKYO_START_BIT_PULSE_LEN_MAX &&
2179 irmp_pause_time >= KASEIKYO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KASEIKYO_START_BIT_PAUSE_LEN_MAX)
2180 { // it's KASEIKYO
2181 ANALYZE_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2182 KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX,
2183 KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX);
2184 irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param;
2185 }
2186 else
2187 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2188
2189 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
2190 if (irmp_pulse_time >= RECS80_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80_START_BIT_PULSE_LEN_MAX &&
2191 irmp_pause_time >= RECS80_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80_START_BIT_PAUSE_LEN_MAX)
2192 { // it's RECS80
2193 ANALYZE_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2194 RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX,
2195 RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX);
2196 irmp_param_p = (IRMP_PARAMETER *) &recs80_param;
2197 }
2198 else
2199 #endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1
2200
2201 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
2202 if (((irmp_pulse_time >= RC5_START_BIT_LEN_MIN && irmp_pulse_time <= RC5_START_BIT_LEN_MAX) ||
2203 (irmp_pulse_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX)) &&
2204 ((irmp_pause_time >= RC5_START_BIT_LEN_MIN && irmp_pause_time <= RC5_START_BIT_LEN_MAX) ||
2205 (irmp_pause_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)))
2206 { // it's RC5
2207 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
2208 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&
2209 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)
2210 {
2211 ANALYZE_PRINTF ("protocol = RC5 or FDC\n");
2212 ANALYZE_PRINTF ("FDC start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2213 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,
2214 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);
2215 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2216 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
2217 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);
2218 memcpy_P (&irmp_param2, &fdc_param, sizeof (IRMP_PARAMETER));
2219 }
2220 else
2221 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
2222
2223 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
2224 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&
2225 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)
2226 {
2227 ANALYZE_PRINTF ("protocol = RC5 or RCCAR\n");
2228 ANALYZE_PRINTF ("RCCAR start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2229 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,
2230 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);
2231 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2232 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
2233 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);
2234 memcpy_P (&irmp_param2, &rccar_param, sizeof (IRMP_PARAMETER));
2235 }
2236 else
2237 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
2238 {
2239 ANALYZE_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n",
2240 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
2241 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX,
2242 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
2243 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX);
2244 }
2245
2246 irmp_param_p = (IRMP_PARAMETER *) &rc5_param;
2247 last_pause = irmp_pause_time;
2248
2249 if ((irmp_pulse_time > RC5_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX) ||
2250 (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX))
2251 {
2252 last_value = 0;
2253 rc5_cmd_bit6 = 1<<6;
2254 }
2255 else
2256 {
2257 last_value = 1;
2258 }
2259 }
2260 else
2261 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1
2262
2263 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
2264 if ( (irmp_pulse_time >= DENON_PULSE_LEN_MIN && irmp_pulse_time <= DENON_PULSE_LEN_MAX) &&
2265 ((irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) ||
2266 (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)))
2267 { // it's DENON
2268 ANALYZE_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
2269 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX,
2270 DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX,
2271 DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX);
2272 irmp_param_p = (IRMP_PARAMETER *) &denon_param;
2273 }
2274 else
2275 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
2276
2277 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1
2278 if ( (irmp_pulse_time >= THOMSON_PULSE_LEN_MIN && irmp_pulse_time <= THOMSON_PULSE_LEN_MAX) &&
2279 ((irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX) ||
2280 (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)))
2281 { // it's THOMSON
2282 ANALYZE_PRINTF ("protocol = THOMSON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
2283 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX,
2284 THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX,
2285 THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX);
2286 irmp_param_p = (IRMP_PARAMETER *) &thomson_param;
2287 }
2288 else
2289 #endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1
2290
2291 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
2292 if (irmp_pulse_time >= RC6_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RC6_START_BIT_PULSE_LEN_MAX &&
2293 irmp_pause_time >= RC6_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RC6_START_BIT_PAUSE_LEN_MAX)
2294 { // it's RC6
2295 ANALYZE_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2296 RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX,
2297 RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX);
2298 irmp_param_p = (IRMP_PARAMETER *) &rc6_param;
2299 last_pause = 0;
2300 last_value = 1;
2301 }
2302 else
2303 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
2304
2305 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
2306 if (irmp_pulse_time >= RECS80EXT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80EXT_START_BIT_PULSE_LEN_MAX &&
2307 irmp_pause_time >= RECS80EXT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80EXT_START_BIT_PAUSE_LEN_MAX)
2308 { // it's RECS80EXT
2309 ANALYZE_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2310 RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX,
2311 RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX);
2312 irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param;
2313 }
2314 else
2315 #endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
2316
2317 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
2318 if (irmp_pulse_time >= NUBERT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NUBERT_START_BIT_PULSE_LEN_MAX &&
2319 irmp_pause_time >= NUBERT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NUBERT_START_BIT_PAUSE_LEN_MAX)
2320 { // it's NUBERT
2321 ANALYZE_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2322 NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX,
2323 NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX);
2324 irmp_param_p = (IRMP_PARAMETER *) &nubert_param;
2325 }
2326 else
2327 #endif // IRMP_SUPPORT_NUBERT_PROTOCOL == 1
2328
2329 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
2330 if (irmp_pulse_time >= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX &&
2331 irmp_pause_time >= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX)
2332 { // it's BANG_OLUFSEN
2333 ANALYZE_PRINTF ("protocol = BANG_OLUFSEN\n");
2334 ANALYZE_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2335 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,
2336 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);
2337 ANALYZE_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2338 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,
2339 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);
2340 ANALYZE_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2341 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,
2342 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);
2343 ANALYZE_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2344 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX,
2345 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX);
2346 irmp_param_p = (IRMP_PARAMETER *) &bang_olufsen_param;
2347 last_value = 0;
2348 }
2349 else
2350 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
2351
2352 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
2353 if (irmp_pulse_time >= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX &&
2354 irmp_pause_time >= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX)
2355 { // it's GRUNDIG
2356 ANALYZE_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2357 GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX,
2358 GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX);
2359 irmp_param_p = (IRMP_PARAMETER *) &grundig_param;
2360 last_pause = irmp_pause_time;
2361 last_value = 1;
2362 }
2363 else
2364 #endif // IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
2365
2366 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
2367 if (((irmp_pulse_time >= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX) ||
2368 (irmp_pulse_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX)) &&
2369 ((irmp_pause_time >= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX) ||
2370 (irmp_pause_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX)))
2371 { // it's RUWIDO or SIEMENS
2372 ANALYZE_PRINTF ("protocol = RUWIDO, start bit timings: pulse: %3d - %3d or %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
2373 SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,
2374 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,
2375 SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX,
2376 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX);
2377 irmp_param_p = (IRMP_PARAMETER *) &ruwido_param;
2378 last_pause = irmp_pause_time;
2379 last_value = 1;
2380 }
2381 else
2382 #endif // IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
2383
2384 #if IRMP_SUPPORT_GRUNDIG2_PROTOCOL == 1
2385 if ((irmp_pulse_time >= GRUNDIG2_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= GRUNDIG2_START_BIT_PULSE_LEN_MAX) &&
2386 (irmp_pause_time >= GRUNDIG2_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG2_START_BIT_PAUSE_LEN_MAX))
2387 { // it's GRUNDIG2
2388 ANALYZE_PRINTF ("protocol = GRUNDIG2, start bit timings: pulse: %3d - %3d or %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
2389 GRUNDIG2_START_BIT_PULSE_LEN_MIN, GRUNDIG2_START_BIT_PULSE_LEN_MAX,
2390 2 * GRUNDIG2_START_BIT_PULSE_LEN_MIN, 2 * GRUNDIG2_START_BIT_PULSE_LEN_MAX,
2391 GRUNDIG2_START_BIT_PAUSE_LEN_MIN, GRUNDIG2_START_BIT_PAUSE_LEN_MAX,
2392 2 * GRUNDIG2_START_BIT_PAUSE_LEN_MIN, 2 * GRUNDIG2_START_BIT_PAUSE_LEN_MAX);
2393 irmp_param_p = (IRMP_PARAMETER *) &grundig2_param;
2394 last_pause = irmp_pause_time;
2395 last_value = 1;
2396 }
2397 else
2398 #endif // IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
2399
2400 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
2401 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&
2402 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)
2403 {
2404 ANALYZE_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2405 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,
2406 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);
2407 irmp_param_p = (IRMP_PARAMETER *) &fdc_param;
2408 }
2409 else
2410 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
2411
2412 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
2413 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&
2414 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)
2415 {
2416 ANALYZE_PRINTF ("protocol = RCCAR, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2417 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,
2418 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);
2419 irmp_param_p = (IRMP_PARAMETER *) &rccar_param;
2420 }
2421 else
2422 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
2423
2424 #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
2425 if (irmp_pulse_time >= KATHREIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_START_BIT_PULSE_LEN_MAX &&
2426 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)
2427 { // it's KATHREIN
2428 ANALYZE_PRINTF ("protocol = KATHREIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2429 KATHREIN_START_BIT_PULSE_LEN_MIN, KATHREIN_START_BIT_PULSE_LEN_MAX,
2430 KATHREIN_START_BIT_PAUSE_LEN_MIN, KATHREIN_START_BIT_PAUSE_LEN_MAX);
2431 irmp_param_p = (IRMP_PARAMETER *) &kathrein_param;
2432 }
2433 else
2434 #endif // IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
2435
2436 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1
2437 if (irmp_pulse_time >= NETBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NETBOX_START_BIT_PULSE_LEN_MAX &&
2438 irmp_pause_time >= NETBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NETBOX_START_BIT_PAUSE_LEN_MAX)
2439 { // it's NETBOX
2440 ANALYZE_PRINTF ("protocol = NETBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2441 NETBOX_START_BIT_PULSE_LEN_MIN, NETBOX_START_BIT_PULSE_LEN_MAX,
2442 NETBOX_START_BIT_PAUSE_LEN_MIN, NETBOX_START_BIT_PAUSE_LEN_MAX);
2443 irmp_param_p = (IRMP_PARAMETER *) &netbox_param;
2444 }
2445 else
2446 #endif // IRMP_SUPPORT_NETBOX_PROTOCOL == 1
2447
2448 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1
2449 if (irmp_pulse_time >= LEGO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= LEGO_START_BIT_PULSE_LEN_MAX &&
2450 irmp_pause_time >= LEGO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= LEGO_START_BIT_PAUSE_LEN_MAX)
2451 {
2452 ANALYZE_PRINTF ("protocol = LEGO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2453 LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX,
2454 LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX);
2455 irmp_param_p = (IRMP_PARAMETER *) &lego_param;
2456 }
2457 else
2458 #endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1
2459
2460 {
2461 ANALYZE_PRINTF ("protocol = UNKNOWN\n");
2462 // irmp_busy_flag = FALSE;
2463 irmp_start_bit_detected = 0; // wait for another start bit...
2464 }
2465
2466 if (irmp_start_bit_detected)
2467 {
2468 memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER));
2469
2470 #ifdef ANALYZE
2471 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))
2472 {
2473 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max);
2474 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max);
2475 }
2476 else
2477 {
2478 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max,
2479 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max);
2480 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max,
2481 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max);
2482 }
2483
2484 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2485 if (irmp_param2.protocol)
2486 {
2487 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param2.pulse_0_len_min, irmp_param2.pulse_0_len_max);
2488 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param2.pause_0_len_min, irmp_param2.pause_0_len_max);
2489 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param2.pulse_1_len_min, irmp_param2.pulse_1_len_max);
2490 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param2.pause_1_len_min, irmp_param2.pause_1_len_max);
2491 }
2492 #endif
2493
2494
2495 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
2496 if (irmp_param.protocol == IRMP_RC6_PROTOCOL)
2497 {
2498 ANALYZE_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX);
2499 }
2500 #endif
2501
2502 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))
2503 {
2504 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);
2505 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max);
2506 }
2507 else
2508 {
2509 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max,
2510 2 * irmp_param.pulse_0_len_min, 2 * irmp_param.pulse_0_len_max);
2511 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max,
2512 2 * irmp_param.pause_0_len_min, 2 * irmp_param.pause_0_len_max);
2513 }
2514
2515 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
2516 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)
2517 {
2518 ANALYZE_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);
2519 ANALYZE_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX);
2520 }
2521 #endif
2522
2523 ANALYZE_PRINTF ("command_offset: %2d\n", irmp_param.command_offset);
2524 ANALYZE_PRINTF ("command_len: %3d\n", irmp_param.command_end - irmp_param.command_offset);
2525 ANALYZE_PRINTF ("complete_len: %3d\n", irmp_param.complete_len);
2526 ANALYZE_PRINTF ("stop_bit: %3d\n", irmp_param.stop_bit);
2527 #endif // ANALYZE
2528 }
2529
2530 irmp_bit = 0;
2531
2532 #if IRMP_SUPPORT_MANCHESTER == 1
2533 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&
2534 irmp_param.protocol != IRMP_RUWIDO_PROTOCOL && // Manchester, but not RUWIDO
2535 irmp_param.protocol != IRMP_RC6_PROTOCOL) // Manchester, but not RC6
2536 {
2537 if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max)
2538 {
2539 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
2540 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');
2541 ANALYZE_NEWLINE ();
2542 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1);
2543 }
2544 else if (! last_value) // && irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)
2545 {
2546 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
2547
2548 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');
2549 ANALYZE_NEWLINE ();
2550 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0);
2551 }
2552 }
2553 else
2554 #endif // IRMP_SUPPORT_MANCHESTER == 1
2555
2556 #if IRMP_SUPPORT_SERIAL == 1
2557 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)
2558 {
2559 ; // do nothing
2560 }
2561 else
2562 #endif // IRMP_SUPPORT_SERIAL == 1
2563
2564
2565 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
2566 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)
2567 {
2568 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
2569
2570 if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX)
2571 { // pause timings correct for "1"?
2572 ANALYZE_PUTCHAR ('1'); // yes, store 1
2573 ANALYZE_NEWLINE ();
2574 irmp_store_bit (1);
2575 }
2576 else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)
2577 { // pause timings correct for "0"?
2578 ANALYZE_PUTCHAR ('0'); // yes, store 0
2579 ANALYZE_NEWLINE ();
2580 irmp_store_bit (0);
2581 }
2582 }
2583 else
2584 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
2585 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1
2586 if (irmp_param.protocol == IRMP_THOMSON_PROTOCOL)
2587 {
2588 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
2589
2590 if (irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX)
2591 { // pause timings correct for "1"?
2592 ANALYZE_PUTCHAR ('1'); // yes, store 1
2593 ANALYZE_NEWLINE ();
2594 irmp_store_bit (1);
2595 }
2596 else // if (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)
2597 { // pause timings correct for "0"?
2598 ANALYZE_PUTCHAR ('0'); // yes, store 0
2599 ANALYZE_NEWLINE ();
2600 irmp_store_bit (0);
2601 }
2602 }
2603 else
2604 #endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1
2605 {
2606 ; // else do nothing
2607 }
2608
2609 irmp_pulse_time = 1; // set counter to 1, not 0
2610 irmp_pause_time = 0;
2611 wait_for_start_space = 0;
2612 }
2613 }
2614 else if (wait_for_space) // the data section....
2615 { // counting the time of darkness....
2616 uint8_t got_light = FALSE;
2617
2618 if (irmp_input) // still dark?
2619 { // yes...
2620 if (irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 1)
2621 {
2622 if (
2623 #if IRMP_SUPPORT_MANCHESTER == 1
2624 (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) ||
2625 #endif
2626 #if IRMP_SUPPORT_SERIAL == 1
2627 (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) ||
2628 #endif
2629 (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max))
2630 {
2631 #ifdef ANALYZE
2632 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))
2633 {
2634 ANALYZE_PRINTF ("stop bit detected\n");
2635 }
2636 #endif
2637 irmp_param.stop_bit = 0;
2638 }
2639 else
2640 {
2641 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",
2642 irmp_bit, irmp_pulse_time, irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);
2643
2644 // irmp_busy_flag = FALSE;
2645 irmp_start_bit_detected = 0; // wait for another start bit...
2646 irmp_pulse_time = 0;
2647 irmp_pause_time = 0;
2648 }
2649 }
2650 else
2651 {
2652 irmp_pause_time++; // increment counter
2653
2654 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
2655 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && // Sony has a variable number of bits:
2656 irmp_pause_time > SIRCS_PAUSE_LEN_MAX && // minimum is 12
2657 irmp_bit >= 12 - 1) // pause too long?
2658 { // yes, break and close this frame
2659 irmp_param.complete_len = irmp_bit + 1; // set new complete length
2660 got_light = TRUE; // this is a lie, but helps (generates stop bit)
2661 irmp_tmp_address |= (irmp_bit - SIRCS_MINIMUM_DATA_LEN + 1) << 8; // new: store number of additional bits in upper byte of address!
2662 irmp_param.command_end = irmp_param.command_offset + irmp_bit + 1; // correct command length
2663 irmp_pause_time = SIRCS_PAUSE_LEN_MAX - 1; // correct pause length
2664 }
2665 else
2666 #endif
2667 #if IRMP_SUPPORT_SERIAL == 1
2668 // NETBOX generates no stop bit, here is the timeout condition:
2669 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) && irmp_param.protocol == IRMP_NETBOX_PROTOCOL &&
2670 irmp_pause_time >= NETBOX_PULSE_LEN * (NETBOX_COMPLETE_DATA_LEN - irmp_bit))
2671 {
2672 got_light = TRUE; // this is a lie, but helps (generates stop bit)
2673 }
2674 else
2675 #endif
2676 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
2677 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit)
2678 {
2679 if (irmp_pause_time > IR60_TIMEOUT_LEN && irmp_bit == 6)
2680 {
2681 ANALYZE_PRINTF ("Switching to IR60 protocol\n");
2682 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
2683 irmp_param.stop_bit = TRUE; // set flag
2684
2685 irmp_param.protocol = IRMP_IR60_PROTOCOL; // change protocol
2686 irmp_param.complete_len = IR60_COMPLETE_DATA_LEN; // correct complete len
2687 irmp_param.address_offset = IR60_ADDRESS_OFFSET;
2688 irmp_param.address_end = IR60_ADDRESS_OFFSET + IR60_ADDRESS_LEN;
2689 irmp_param.command_offset = IR60_COMMAND_OFFSET;
2690 irmp_param.command_end = IR60_COMMAND_OFFSET + IR60_COMMAND_LEN;
2691
2692 irmp_tmp_command <<= 1;
2693 irmp_tmp_command |= first_bit;
2694 }
2695 else if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2)
2696 { // special manchester decoder
2697 irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len
2698 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
2699 irmp_param.stop_bit = TRUE; // set flag
2700 }
2701 else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN)
2702 {
2703 ANALYZE_PRINTF ("Switching to NOKIA protocol\n");
2704 irmp_param.protocol = IRMP_NOKIA_PROTOCOL; // change protocol
2705 irmp_param.address_offset = NOKIA_ADDRESS_OFFSET;
2706 irmp_param.address_end = NOKIA_ADDRESS_OFFSET + NOKIA_ADDRESS_LEN;
2707 irmp_param.command_offset = NOKIA_COMMAND_OFFSET;
2708 irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN;
2709
2710 if (irmp_tmp_command & 0x300)
2711 {
2712 irmp_tmp_address = (irmp_tmp_command >> 8);
2713 irmp_tmp_command &= 0xFF;
2714 }
2715 }
2716 }
2717 else
2718 #endif
2719 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
2720 if (irmp_param.protocol == IRMP_RUWIDO_PROTOCOL && !irmp_param.stop_bit)
2721 {
2722 if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= RUWIDO_COMPLETE_DATA_LEN - 2)
2723 { // special manchester decoder
2724 irmp_param.complete_len = RUWIDO_COMPLETE_DATA_LEN; // correct complete len
2725 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
2726 irmp_param.stop_bit = TRUE; // set flag
2727 }
2728 else if (irmp_bit >= RUWIDO_COMPLETE_DATA_LEN)
2729 {
2730 ANALYZE_PRINTF ("Switching to SIEMENS protocol\n");
2731 irmp_param.protocol = IRMP_SIEMENS_PROTOCOL; // change protocol
2732 irmp_param.address_offset = SIEMENS_ADDRESS_OFFSET;
2733 irmp_param.address_end = SIEMENS_ADDRESS_OFFSET + SIEMENS_ADDRESS_LEN;
2734 irmp_param.command_offset = SIEMENS_COMMAND_OFFSET;
2735 irmp_param.command_end = SIEMENS_COMMAND_OFFSET + SIEMENS_COMMAND_LEN;
2736
2737 // 76543210
2738 // RUWIDO: AAAAAAAAACCCCCCCp
2739 // SIEMENS: AAAAAAAAAAACCCCCCCCCCp
2740 irmp_tmp_address <<= 2;
2741 irmp_tmp_address |= (irmp_tmp_command >> 6);
2742 irmp_tmp_command &= 0x003F;
2743 irmp_tmp_command <<= 4;
2744 irmp_tmp_command |= last_value;
2745 }
2746 }
2747 else
2748 #endif
2749 #if IRMP_SUPPORT_MANCHESTER == 1
2750 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&
2751 irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit)
2752 { // special manchester decoder
2753 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
2754 irmp_param.stop_bit = TRUE; // set flag
2755 }
2756 else
2757 #endif // IRMP_SUPPORT_MANCHESTER == 1
2758 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?
2759 { // yes...
2760 if (irmp_bit == irmp_param.complete_len - 1 && irmp_param.stop_bit == 0)
2761 {
2762 irmp_bit++;
2763 }
2764 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2765 else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit
2766 {
2767 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);
2768 irmp_param.stop_bit = TRUE; // set flag
2769 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol
2770 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
2771 irmp_tmp_command = (irmp_tmp_address >> 4); // set command: upper 12 bits are command bits
2772 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits
2773 irmp_start_bit_detected = 1; // tricky: don't wait for another start bit...
2774 }
2775 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2776
2777 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
2778 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2779 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 32) // it was a NEC stop bit
2780 {
2781 ANALYZE_PRINTF ("Switching to NEC protocol\n");
2782 irmp_param.stop_bit = TRUE; // set flag
2783 irmp_param.protocol = IRMP_NEC_PROTOCOL; // switch protocol
2784 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
2785
2786 // 0123456789ABC0123456789ABC0123456701234567
2787 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc
2788 // NEC: AAAAAAAAaaaaaaaaCCCCCCCCcccccccc
2789 irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 13; // fm 2012-02-13: 12 -> 13
2790 irmp_tmp_command = (irmp_tmp_address2 >> 3) | (irmp_tmp_command << 10);
2791 }
2792 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
2793 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2794 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit
2795 {
2796 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);
2797 irmp_param.stop_bit = TRUE; // set flag
2798 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol
2799 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
2800
2801 // 0123456789ABC0123456789ABC0123456701234567
2802 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc
2803 // JVC: AAAACCCCCCCCCCCC
2804 irmp_tmp_command = (irmp_tmp_address >> 4) | (irmp_tmp_address2 << 9); // set command: upper 12 bits are command bits
2805 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits
2806 }
2807 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2808 #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1
2809 else
2810 {
2811 ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit);
2812 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2813
2814 // irmp_busy_flag = FALSE;
2815 irmp_start_bit_detected = 0; // wait for another start bit...
2816 irmp_pulse_time = 0;
2817 irmp_pause_time = 0;
2818 }
2819 }
2820 }
2821 }
2822 else
2823 { // got light now!
2824 got_light = TRUE;
2825 }
2826
2827 if (got_light)
2828 {
2829 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
2830
2831 #if IRMP_SUPPORT_MANCHESTER == 1
2832 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester
2833 {
2834 #if 1
2835 if (irmp_pulse_time > irmp_param.pulse_1_len_max /* && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max */)
2836 #else // better, but some IR-RCs use asymmetric timings :-/
2837 if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max &&
2838 irmp_pause_time <= 2 * irmp_param.pause_1_len_max)
2839 #endif
2840 {
2841 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
2842 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit
2843 {
2844 ANALYZE_PUTCHAR ('T');
2845 if (irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode 6A
2846 {
2847 irmp_store_bit (1);
2848 last_value = 1;
2849 }
2850 else // RC6 mode 0
2851 {
2852 irmp_store_bit (0);
2853 last_value = 0;
2854 }
2855 ANALYZE_NEWLINE ();
2856 }
2857 else
2858 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
2859 {
2860 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');
2861 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 );
2862
2863 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
2864 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit
2865 {
2866 ANALYZE_PUTCHAR ('T');
2867 irmp_store_bit (1);
2868
2869 if (irmp_pause_time > 2 * irmp_param.pause_1_len_max)
2870 {
2871 last_value = 0;
2872 }
2873 else
2874 {
2875 last_value = 1;
2876 }
2877 ANALYZE_NEWLINE ();
2878 }
2879 else
2880 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
2881 {
2882 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');
2883 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 );
2884 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2885 if (! irmp_param2.protocol)
2886 #endif
2887 {
2888 ANALYZE_NEWLINE ();
2889 }
2890 last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0;
2891 }
2892 }
2893 }
2894 else if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max
2895 /* && irmp_pause_time <= 2 * irmp_param.pause_1_len_max */)
2896 {
2897 uint8_t manchester_value;
2898
2899 if (last_pause > irmp_param.pause_1_len_max && last_pause <= 2 * irmp_param.pause_1_len_max)
2900 {
2901 manchester_value = last_value ? 0 : 1;
2902 last_value = manchester_value;
2903 }
2904 else
2905 {
2906 manchester_value = last_value;
2907 }
2908
2909 ANALYZE_PUTCHAR (manchester_value + '0');
2910
2911 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2912 if (! irmp_param2.protocol)
2913 #endif
2914 {
2915 ANALYZE_NEWLINE ();
2916 }
2917
2918 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
2919 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 1) // RC6 mode != 0 ???
2920 {
2921 ANALYZE_PRINTF ("Switching to RC6A protocol\n");
2922 irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG;
2923 irmp_param.address_offset = 5;
2924 irmp_param.address_end = irmp_param.address_offset + 15;
2925 irmp_param.command_offset = irmp_param.address_end + 1; // skip 1 system bit, changes like a toggle bit
2926 irmp_param.command_end = irmp_param.command_offset + 16 - 1;
2927 irmp_tmp_address = 0;
2928 }
2929 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
2930
2931 irmp_store_bit (manchester_value);
2932 }
2933 else
2934 {
2935 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1
2936 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL &&
2937 irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX &&
2938 ((irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) ||
2939 (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)))
2940 {
2941 ANALYZE_PUTCHAR ('?');
2942 irmp_param.protocol = 0; // switch to FDC, see below
2943 }
2944 else
2945 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
2946 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1
2947 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL &&
2948 irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX &&
2949 ((irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) ||
2950 (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)))
2951 {
2952 ANALYZE_PUTCHAR ('?');
2953 irmp_param.protocol = 0; // switch to RCCAR, see below
2954 }
2955 else
2956 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
2957 {
2958 ANALYZE_PUTCHAR ('?');
2959 ANALYZE_NEWLINE ();
2960 ANALYZE_PRINTF ("error 3 manchester: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
2961 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2962 // irmp_busy_flag = FALSE;
2963 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
2964 irmp_pause_time = 0;
2965 }
2966 }
2967
2968 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1
2969 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL && irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX)
2970 {
2971 if (irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX)
2972 {
2973 ANALYZE_PRINTF (" 1 (FDC)\n");
2974 irmp_store_bit2 (1);
2975 }
2976 else if (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)
2977 {
2978 ANALYZE_PRINTF (" 0 (FDC)\n");
2979 irmp_store_bit2 (0);
2980 }
2981
2982 if (! irmp_param.protocol)
2983 {
2984 ANALYZE_PRINTF ("Switching to FDC protocol\n");
2985 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));
2986 irmp_param2.protocol = 0;
2987 irmp_tmp_address = irmp_tmp_address2;
2988 irmp_tmp_command = irmp_tmp_command2;
2989 }
2990 }
2991 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
2992 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1
2993 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL && irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX)
2994 {
2995 if (irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX)
2996 {
2997 ANALYZE_PRINTF (" 1 (RCCAR)\n");
2998 irmp_store_bit2 (1);
2999 }
3000 else if (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)
3001 {
3002 ANALYZE_PRINTF (" 0 (RCCAR)\n");
3003 irmp_store_bit2 (0);
3004 }
3005
3006 if (! irmp_param.protocol)
3007 {
3008 ANALYZE_PRINTF ("Switching to RCCAR protocol\n");
3009 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));
3010 irmp_param2.protocol = 0;
3011 irmp_tmp_address = irmp_tmp_address2;
3012 irmp_tmp_command = irmp_tmp_command2;
3013 }
3014 }
3015 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
3016
3017 last_pause = irmp_pause_time;
3018 wait_for_space = 0;
3019 }
3020 else
3021 #endif // IRMP_SUPPORT_MANCHESTER == 1
3022
3023 #if IRMP_SUPPORT_SERIAL == 1
3024 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)
3025 {
3026 while (irmp_bit < irmp_param.complete_len && irmp_pulse_time > irmp_param.pulse_1_len_max)
3027 {
3028 ANALYZE_PUTCHAR ('1');
3029 irmp_store_bit (1);
3030
3031 if (irmp_pulse_time >= irmp_param.pulse_1_len_min)
3032 {
3033 irmp_pulse_time -= irmp_param.pulse_1_len_min;
3034 }
3035 else
3036 {
3037 irmp_pulse_time = 0;
3038 }
3039 }
3040
3041 while (irmp_bit < irmp_param.complete_len && irmp_pause_time > irmp_param.pause_1_len_max)
3042 {
3043 ANALYZE_PUTCHAR ('0');
3044 irmp_store_bit (0);
3045
3046 if (irmp_pause_time >= irmp_param.pause_1_len_min)
3047 {
3048 irmp_pause_time -= irmp_param.pause_1_len_min;
3049 }
3050 else
3051 {
3052 irmp_pause_time = 0;
3053 }
3054 }
3055 ANALYZE_NEWLINE ();
3056 wait_for_space = 0;
3057 }
3058 else
3059 #endif // IRMP_SUPPORT_SERIAL == 1
3060
3061 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
3062 if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit == 16) // Samsung: 16th bit
3063 {
3064 if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX &&
3065 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)
3066 {
3067 ANALYZE_PRINTF ("SYNC\n");
3068 wait_for_space = 0;
3069 irmp_tmp_id = 0;
3070 irmp_bit++;
3071 }
3072 else if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX)
3073 {
3074 irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL;
3075 irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET;
3076 irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN;
3077 irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN;
3078
3079 if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX)
3080 {
3081 ANALYZE_PUTCHAR ('1');
3082 ANALYZE_NEWLINE ();
3083 irmp_store_bit (1);
3084 wait_for_space = 0;
3085 }
3086 else
3087 {
3088 ANALYZE_PUTCHAR ('0');
3089 ANALYZE_NEWLINE ();
3090 irmp_store_bit (0);
3091 wait_for_space = 0;
3092 }
3093
3094 ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n");
3095 }
3096 else
3097 { // timing incorrect!
3098 ANALYZE_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
3099 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
3100 // irmp_busy_flag = FALSE;
3101 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
3102 irmp_pause_time = 0;
3103 }
3104 }
3105 else
3106 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL
3107
3108 #if IRMP_SUPPORT_NEC16_PROTOCOL
3109 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
3110 if (irmp_param.protocol == IRMP_NEC42_PROTOCOL &&
3111 #else // IRMP_SUPPORT_NEC_PROTOCOL instead
3112 if (irmp_param.protocol == IRMP_NEC_PROTOCOL &&
3113 #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1
3114 irmp_bit == 8 && irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)
3115 {
3116 ANALYZE_PRINTF ("Switching to NEC16 protocol\n");
3117 irmp_param.protocol = IRMP_NEC16_PROTOCOL;
3118 irmp_param.address_offset = NEC16_ADDRESS_OFFSET;
3119 irmp_param.address_end = NEC16_ADDRESS_OFFSET + NEC16_ADDRESS_LEN;
3120 irmp_param.command_offset = NEC16_COMMAND_OFFSET;
3121 irmp_param.command_end = NEC16_COMMAND_OFFSET + NEC16_COMMAND_LEN;
3122 irmp_param.complete_len = NEC16_COMPLETE_DATA_LEN;
3123 wait_for_space = 0;
3124 }
3125 else
3126 #endif // IRMP_SUPPORT_NEC16_PROTOCOL
3127
3128 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
3129 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)
3130 {
3131 if (irmp_pulse_time >= BANG_OLUFSEN_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_PULSE_LEN_MAX)
3132 {
3133 if (irmp_bit == 1) // Bang & Olufsen: 3rd bit
3134 {
3135 if (irmp_pause_time >= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX)
3136 {
3137 ANALYZE_PRINTF ("3rd start bit\n");
3138 wait_for_space = 0;
3139 irmp_bit++;
3140 }
3141 else
3142 { // timing incorrect!
3143 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);
3144 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
3145 // irmp_busy_flag = FALSE;
3146 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
3147 irmp_pause_time = 0;
3148 }
3149 }
3150 else if (irmp_bit == 19) // Bang & Olufsen: trailer bit
3151 {
3152 if (irmp_pause_time >= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX)
3153 {
3154 ANALYZE_PRINTF ("trailer bit\n");
3155 wait_for_space = 0;
3156 irmp_bit++;
3157 }
3158 else
3159 { // timing incorrect!
3160 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);
3161 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
3162 // irmp_busy_flag = FALSE;
3163 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
3164 irmp_pause_time = 0;
3165 }
3166 }
3167 else
3168 {
3169 if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX)
3170 { // pulse & pause timings correct for "1"?
3171 ANALYZE_PUTCHAR ('1');
3172 ANALYZE_NEWLINE ();
3173 irmp_store_bit (1);
3174 last_value = 1;
3175 wait_for_space = 0;
3176 }
3177 else if (irmp_pause_time >= BANG_OLUFSEN_0_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_0_PAUSE_LEN_MAX)
3178 { // pulse & pause timings correct for "0"?
3179 ANALYZE_PUTCHAR ('0');
3180 ANALYZE_NEWLINE ();
3181 irmp_store_bit (0);
3182 last_value = 0;
3183 wait_for_space = 0;
3184 }
3185 else if (irmp_pause_time >= BANG_OLUFSEN_R_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_R_PAUSE_LEN_MAX)
3186 {
3187 ANALYZE_PUTCHAR (last_value + '0');
3188 ANALYZE_NEWLINE ();
3189 irmp_store_bit (last_value);
3190 wait_for_space = 0;
3191 }
3192 else
3193 { // timing incorrect!
3194 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);
3195 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
3196 // irmp_busy_flag = FALSE;
3197 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
3198 irmp_pause_time = 0;
3199 }
3200 }
3201 }
3202 else
3203 { // timing incorrect!
3204 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);
3205 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
3206 // irmp_busy_flag = FALSE;
3207 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
3208 irmp_pause_time = 0;
3209 }
3210 }
3211 else
3212 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL
3213
3214 if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max &&
3215 irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)
3216 { // pulse & pause timings correct for "1"?
3217 ANALYZE_PUTCHAR ('1');
3218 ANALYZE_NEWLINE ();
3219 irmp_store_bit (1);
3220 wait_for_space = 0;
3221 }
3222 else if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max &&
3223 irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max)
3224 { // pulse & pause timings correct for "0"?
3225 ANALYZE_PUTCHAR ('0');
3226 ANALYZE_NEWLINE ();
3227 irmp_store_bit (0);
3228 wait_for_space = 0;
3229 }
3230 else
3231 #if IRMP_SUPPORT_KATHREIN_PROTOCOL
3232
3233 if (irmp_param.protocol == IRMP_KATHREIN_PROTOCOL &&
3234 irmp_pulse_time >= KATHREIN_1_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_1_PULSE_LEN_MAX &&
3235 (((irmp_bit == 8 || irmp_bit == 6) &&
3236 irmp_pause_time >= KATHREIN_SYNC_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_SYNC_BIT_PAUSE_LEN_MAX) ||
3237 (irmp_bit == 12 &&
3238 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)))
3239
3240 {
3241 if (irmp_bit == 8)
3242 {
3243 irmp_bit++;
3244 ANALYZE_PUTCHAR ('S');
3245 ANALYZE_NEWLINE ();
3246 irmp_tmp_command <<= 1;
3247 }
3248 else
3249 {
3250 ANALYZE_PUTCHAR ('S');
3251 ANALYZE_NEWLINE ();
3252 irmp_store_bit (1);
3253 }
3254 wait_for_space = 0;
3255 }
3256 else
3257 #endif // IRMP_SUPPORT_KATHREIN_PROTOCOL
3258 { // timing incorrect!
3259 ANALYZE_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
3260 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
3261 // irmp_busy_flag = FALSE;
3262 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
3263 irmp_pause_time = 0;
3264 }
3265
3266 irmp_pulse_time = 1; // set counter to 1, not 0
3267 }
3268 }
3269 else
3270 { // counting the pulse length ...
3271 if (! irmp_input) // still light?
3272 { // yes...
3273 irmp_pulse_time++; // increment counter
3274 }
3275 else
3276 { // now it's dark!
3277 wait_for_space = 1; // let's count the time (see above)
3278 irmp_pause_time = 1; // set pause counter to 1, not 0
3279 }
3280 }
3281
3282 if (irmp_start_bit_detected && irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0) // enough bits received?
3283 {
3284 if (last_irmp_command == irmp_tmp_command && repetition_len < AUTO_FRAME_REPETITION_LEN)
3285 {
3286 repetition_frame_number++;
3287 }
3288 else
3289 {
3290 repetition_frame_number = 0;
3291 }
3292
3293 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
3294 // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame
3295 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2))
3296 {
3297 ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
3298 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);
3299 repetition_len = 0;
3300 }
3301 else
3302 #endif
3303
3304 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
3305 // if KASEIKYO protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame
3306 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && repetition_frame_number == 1)
3307 {
3308 ANALYZE_PRINTF ("code skipped: KASEIKYO auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
3309 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);
3310 repetition_len = 0;
3311 }
3312 else
3313 #endif
3314
3315 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
3316 // if SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
3317 if (irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL && (repetition_frame_number & 0x01))
3318 {
3319 ANALYZE_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
3320 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);
3321 repetition_len = 0;
3322 }
3323 else
3324 #endif
3325
3326 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
3327 // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
3328 if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01))
3329 {
3330 ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
3331 repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN);
3332 repetition_len = 0;
3333 }
3334 else
3335 #endif
3336
3337 {
3338 ANALYZE_PRINTF ("%8.3fms code detected, length = %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit);
3339 irmp_ir_detected = TRUE;
3340
3341 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
3342 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)
3343 { // check for repetition frame
3344 if ((~irmp_tmp_command & 0x3FF) == last_irmp_denon_command) // command bits must be inverted
3345 {
3346 irmp_tmp_command = last_irmp_denon_command; // use command received before!
3347
3348 irmp_protocol = irmp_param.protocol; // store protocol
3349 irmp_address = irmp_tmp_address; // store address
3350 irmp_command = irmp_tmp_command ; // store command
3351 }
3352 else
3353 {
3354 ANALYZE_PRINTF ("waiting for inverted command repetition\n");
3355 irmp_ir_detected = FALSE;
3356 last_irmp_denon_command = irmp_tmp_command;
3357 }
3358 }
3359 else
3360 #endif // IRMP_SUPPORT_DENON_PROTOCOL
3361
3362 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
3363 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && irmp_tmp_command == 0x01ff)
3364 { // Grundig start frame?
3365 ANALYZE_PRINTF ("Detected GRUNDIG start frame, ignoring it\n");
3366 irmp_ir_detected = FALSE;
3367 }
3368 else
3369 #endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL
3370
3371 #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1
3372 if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL && irmp_tmp_address == 0x00ff && irmp_tmp_command == 0x00fe)
3373 { // Nokia start frame?
3374 ANALYZE_PRINTF ("Detected NOKIA start frame, ignoring it\n");
3375 irmp_ir_detected = FALSE;
3376 }
3377 else
3378 #endif // IRMP_SUPPORT_NOKIA_PROTOCOL
3379 {
3380 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
3381 if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame
3382 {
3383 if (repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX)
3384 {
3385 ANALYZE_PRINTF ("Detected NEC repetition frame, repetition_len = %d\n", repetition_len);
3386 irmp_tmp_address = last_irmp_address; // address is last address
3387 irmp_tmp_command = last_irmp_command; // command is last command
3388 irmp_flags |= IRMP_FLAG_REPETITION;
3389 repetition_len = 0;
3390 }
3391 else
3392 {
3393 ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, repetition_len = %d > %d\n",
3394 repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX);
3395 irmp_ir_detected = FALSE;
3396 }
3397 }
3398 #endif // IRMP_SUPPORT_NEC_PROTOCOL
3399
3400 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
3401 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)
3402 {
3403 uint8_t xor;
3404 // ANALYZE_PRINTF ("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
3405 // xor_check[0], xor_check[1], xor_check[2], xor_check[3], xor_check[4], xor_check[5]);
3406
3407 xor = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4);
3408
3409 if (xor != (xor_check[2] & 0x0F))
3410 {
3411 ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor, xor_check[2] & 0x0F);
3412 irmp_ir_detected = FALSE;
3413 }
3414
3415 xor = xor_check[2] ^ xor_check[3] ^ xor_check[4];
3416
3417 if (xor != xor_check[5])
3418 {
3419 ANALYZE_PRINTF ("error 4: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor, xor_check[5]);
3420 irmp_ir_detected = FALSE;
3421 }
3422
3423 irmp_flags |= genre2; // write the genre2 bits into MSB of the flag byte
3424 }
3425 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
3426
3427 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
3428 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode = 6?
3429 {
3430 irmp_protocol = IRMP_RC6A_PROTOCOL;
3431 }
3432 else
3433 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
3434
3435 irmp_protocol = irmp_param.protocol;
3436
3437 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
3438 if (irmp_param.protocol == IRMP_FDC_PROTOCOL)
3439 {
3440 if (irmp_tmp_command & 0x000F) // released key?
3441 {
3442 irmp_tmp_command = (irmp_tmp_command >> 4) | 0x80; // yes, set bit 7
3443 }
3444 else
3445 {
3446 irmp_tmp_command >>= 4; // no, it's a pressed key
3447 }
3448 irmp_tmp_command |= (irmp_tmp_address << 2) & 0x0F00; // 000000CCCCAAAAAA -> 0000CCCC00000000
3449 irmp_tmp_address &= 0x003F;
3450 }
3451 #endif
3452
3453 irmp_address = irmp_tmp_address; // store address
3454 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
3455 if (irmp_param.protocol == IRMP_NEC_PROTOCOL)
3456 {
3457 last_irmp_address = irmp_tmp_address; // store as last address, too
3458 }
3459 #endif
3460
3461 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
3462 if (irmp_param.protocol == IRMP_RC5_PROTOCOL)
3463 {
3464 irmp_tmp_command |= rc5_cmd_bit6; // store bit 6
3465 }
3466 #endif
3467 irmp_command = irmp_tmp_command; // store command
3468
3469 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
3470 irmp_id = irmp_tmp_id;
3471 #endif
3472 }
3473 }
3474
3475 if (irmp_ir_detected)
3476 {
3477 if (last_irmp_command == irmp_tmp_command &&
3478 last_irmp_address == irmp_tmp_address &&
3479 repetition_len < IRMP_KEY_REPETITION_LEN)
3480 {
3481 irmp_flags |= IRMP_FLAG_REPETITION;
3482 }
3483
3484 last_irmp_address = irmp_tmp_address; // store as last address, too
3485 last_irmp_command = irmp_tmp_command; // store as last command, too
3486
3487 repetition_len = 0;
3488 }
3489 else
3490 {
3491 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
3492 }
3493
3494 // irmp_busy_flag = FALSE;
3495 irmp_start_bit_detected = 0; // and wait for next start bit
3496 irmp_tmp_command = 0;
3497 irmp_pulse_time = 0;
3498 irmp_pause_time = 0;
3499
3500 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
3501 if (irmp_protocol == IRMP_JVC_PROTOCOL) // the stop bit of JVC frame is also start bit of next frame
3502 { // set pulse time here!
3503 irmp_pulse_time = ((uint8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME));
3504 }
3505 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
3506 }
3507 }
3508 }
3509 return (irmp_ir_detected);
3510 }
3511
3512 #ifdef ANALYZE
3513
3514 /*---------------------------------------------------------------------------------------------------------------------------------------------------
3515 * main functions - for Unix/Linux + Windows only!
3516 *
3517 * AVR: see main.c!
3518 *
3519 * Compile it under linux with:
3520 * cc irmp.c -o irmp
3521 *
3522 * usage: ./irmp [-v|-s|-a|-l|-p] < file
3523 *
3524 * options:
3525 * -v verbose
3526 * -s silent
3527 * -a analyze
3528 * -l list pulse/pauses
3529 * -p print timings
3530 *---------------------------------------------------------------------------------------------------------------------------------------------------
3531 */
3532
3533 static void
3534 print_timings (void)
3535 {
3536 printf ("IRMP_TIMEOUT_LEN: %d [%d byte(s)]\n", IRMP_TIMEOUT_LEN, sizeof (PAUSE_LEN));
3537 printf ("IRMP_KEY_REPETITION_LEN %d\n", IRMP_KEY_REPETITION_LEN);
3538 puts ("");
3539 printf ("PROTOCOL S S-PULSE S-PAUSE PULSE-0 PAUSE-0 PULSE-1 PAUSE-1\n");
3540 printf ("====================================================================================\n");
3541 printf ("SIRCS 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3542 SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX, SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX,
3543 SIRCS_0_PULSE_LEN_MIN, SIRCS_0_PULSE_LEN_MAX, SIRCS_PAUSE_LEN_MIN, SIRCS_PAUSE_LEN_MAX,
3544 SIRCS_1_PULSE_LEN_MIN, SIRCS_1_PULSE_LEN_MAX, SIRCS_PAUSE_LEN_MIN, SIRCS_PAUSE_LEN_MAX);
3545
3546 printf ("NEC 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3547 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX,
3548 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX,
3549 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_1_PAUSE_LEN_MIN, NEC_1_PAUSE_LEN_MAX);
3550
3551 printf ("NEC (rep) 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3552 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX,
3553 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX,
3554 NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_1_PAUSE_LEN_MIN, NEC_1_PAUSE_LEN_MAX);
3555
3556 printf ("SAMSUNG 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3557 SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX, SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX,
3558 SAMSUNG_PULSE_LEN_MIN, SAMSUNG_PULSE_LEN_MAX, SAMSUNG_0_PAUSE_LEN_MIN, SAMSUNG_0_PAUSE_LEN_MAX,
3559 SAMSUNG_PULSE_LEN_MIN, SAMSUNG_PULSE_LEN_MAX, SAMSUNG_1_PAUSE_LEN_MIN, SAMSUNG_1_PAUSE_LEN_MAX);
3560
3561 printf ("MATSUSHITA 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3562 MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX, MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX,
3563 MATSUSHITA_PULSE_LEN_MIN, MATSUSHITA_PULSE_LEN_MAX, MATSUSHITA_0_PAUSE_LEN_MIN, MATSUSHITA_0_PAUSE_LEN_MAX,
3564 MATSUSHITA_PULSE_LEN_MIN, MATSUSHITA_PULSE_LEN_MAX, MATSUSHITA_1_PAUSE_LEN_MIN, MATSUSHITA_1_PAUSE_LEN_MAX);
3565
3566 printf ("KASEIKYO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3567 KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX, KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX,
3568 KASEIKYO_PULSE_LEN_MIN, KASEIKYO_PULSE_LEN_MAX, KASEIKYO_0_PAUSE_LEN_MIN, KASEIKYO_0_PAUSE_LEN_MAX,
3569 KASEIKYO_PULSE_LEN_MIN, KASEIKYO_PULSE_LEN_MAX, KASEIKYO_1_PAUSE_LEN_MIN, KASEIKYO_1_PAUSE_LEN_MAX);
3570
3571 printf ("RECS80 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3572 RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX, RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX,
3573 RECS80_PULSE_LEN_MIN, RECS80_PULSE_LEN_MAX, RECS80_0_PAUSE_LEN_MIN, RECS80_0_PAUSE_LEN_MAX,
3574 RECS80_PULSE_LEN_MIN, RECS80_PULSE_LEN_MAX, RECS80_1_PAUSE_LEN_MIN, RECS80_1_PAUSE_LEN_MAX);
3575
3576 printf ("RC5 1 %3d - %3d %3d - %3d %3d - %3d\n",
3577 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
3578 RC5_BIT_LEN_MIN, RC5_BIT_LEN_MAX);
3579
3580 printf ("DENON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3581 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX,
3582 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX,
3583 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX);
3584
3585 printf ("THOMSON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3586 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX,
3587 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX,
3588 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX);
3589
3590 printf ("RC6 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3591 RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX, RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX,
3592 RC6_BIT_PULSE_LEN_MIN, RC6_BIT_PULSE_LEN_MAX, RC6_BIT_PAUSE_LEN_MIN, RC6_BIT_PAUSE_LEN_MAX);
3593
3594 printf ("RECS80EXT 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3595 RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX, RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX,
3596 RECS80EXT_PULSE_LEN_MIN, RECS80EXT_PULSE_LEN_MAX, RECS80EXT_0_PAUSE_LEN_MIN, RECS80EXT_0_PAUSE_LEN_MAX,
3597 RECS80EXT_PULSE_LEN_MIN, RECS80EXT_PULSE_LEN_MAX, RECS80EXT_1_PAUSE_LEN_MIN, RECS80EXT_1_PAUSE_LEN_MAX);
3598
3599 printf ("NUBERT 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3600 NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX, NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX,
3601 NUBERT_0_PULSE_LEN_MIN, NUBERT_0_PULSE_LEN_MAX, NUBERT_0_PAUSE_LEN_MIN, NUBERT_0_PAUSE_LEN_MAX,
3602 NUBERT_1_PULSE_LEN_MIN, NUBERT_1_PULSE_LEN_MAX, NUBERT_1_PAUSE_LEN_MIN, NUBERT_1_PAUSE_LEN_MAX);
3603
3604 printf ("BANG_OLUFSEN 1 %3d - %3d %3d - %3d\n",
3605 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,
3606 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);
3607
3608 printf ("BANG_OLUFSEN 2 %3d - %3d %3d - %3d\n",
3609 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,
3610 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);
3611
3612 printf ("BANG_OLUFSEN 3 %3d - %3d %3d - %3d\n",
3613 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,
3614 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);
3615
3616 printf ("BANG_OLUFSEN 4 %3d - %3d %3d - %3d\n",
3617 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX,
3618 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX);
3619
3620 printf ("BANG_OLUFSEN - %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3621 BANG_OLUFSEN_PULSE_LEN_MIN, BANG_OLUFSEN_PULSE_LEN_MAX, BANG_OLUFSEN_0_PAUSE_LEN_MIN, BANG_OLUFSEN_0_PAUSE_LEN_MAX,
3622 BANG_OLUFSEN_PULSE_LEN_MIN, BANG_OLUFSEN_PULSE_LEN_MAX, BANG_OLUFSEN_1_PAUSE_LEN_MIN, BANG_OLUFSEN_1_PAUSE_LEN_MAX);
3623
3624 printf ("GRUNDIG/NOKIA 1 %3d - %3d %3d - %3d %3d - %3d\n",
3625 GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX,
3626 GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX,
3627 GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_BIT_LEN_MAX);
3628
3629 printf ("SIEMENS/RUWIDO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3630 SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,
3631 SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX,
3632 SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX,
3633 SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX,
3634 2 * SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX,
3635 2 * SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX);
3636
3637 printf ("GRUNDIG2 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3638 GRUNDIG2_START_BIT_PULSE_LEN_MIN, GRUNDIG2_START_BIT_PULSE_LEN_MAX,
3639 GRUNDIG2_START_BIT_PAUSE_LEN_MIN, GRUNDIG2_START_BIT_PAUSE_LEN_MAX,
3640 GRUNDIG2_BIT_PULSE_LEN_MIN, GRUNDIG2_BIT_PULSE_LEN_MAX,
3641 GRUNDIG2_BIT_PAUSE_LEN_MIN, GRUNDIG2_BIT_PAUSE_LEN_MAX,
3642 2 * GRUNDIG2_BIT_PULSE_LEN_MIN, 2 * GRUNDIG2_BIT_PULSE_LEN_MAX,
3643 2 * GRUNDIG2_BIT_PAUSE_LEN_MIN, 2 * GRUNDIG2_BIT_PAUSE_LEN_MAX);
3644
3645 printf ("FDC 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3646 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX, FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX,
3647 FDC_PULSE_LEN_MIN, FDC_PULSE_LEN_MAX, FDC_0_PAUSE_LEN_MIN, FDC_0_PAUSE_LEN_MAX,
3648 FDC_PULSE_LEN_MIN, FDC_PULSE_LEN_MAX, FDC_1_PAUSE_LEN_MIN, FDC_1_PAUSE_LEN_MAX);
3649
3650 printf ("RCCAR 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3651 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX, RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX,
3652 RCCAR_PULSE_LEN_MIN, RCCAR_PULSE_LEN_MAX, RCCAR_0_PAUSE_LEN_MIN, RCCAR_0_PAUSE_LEN_MAX,
3653 RCCAR_PULSE_LEN_MIN, RCCAR_PULSE_LEN_MAX, RCCAR_1_PAUSE_LEN_MIN, RCCAR_1_PAUSE_LEN_MAX);
3654
3655 printf ("NIKON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3656 NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX, NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX,
3657 NIKON_PULSE_LEN_MIN, NIKON_PULSE_LEN_MAX, NIKON_0_PAUSE_LEN_MIN, NIKON_0_PAUSE_LEN_MAX,
3658 NIKON_PULSE_LEN_MIN, NIKON_PULSE_LEN_MAX, NIKON_1_PAUSE_LEN_MIN, NIKON_1_PAUSE_LEN_MAX);
3659
3660 printf ("LEGO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n",
3661 LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX, LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX,
3662 LEGO_PULSE_LEN_MIN, LEGO_PULSE_LEN_MAX, LEGO_0_PAUSE_LEN_MIN, LEGO_0_PAUSE_LEN_MAX,
3663 LEGO_PULSE_LEN_MIN, LEGO_PULSE_LEN_MAX, LEGO_1_PAUSE_LEN_MIN, LEGO_1_PAUSE_LEN_MAX);
3664
3665 }
3666
3667 void
3668 print_spectrum (char * text, int * buf, int is_pulse)
3669 {
3670 int i;
3671 int j;
3672 int min;
3673 int max;
3674 int max_value = 0;
3675 int value;
3676 int sum = 0;
3677 int counter = 0;
3678 double average = 0;
3679 double tolerance;
3680
3681 puts ("-------------------------------------------------------------------------------");
3682 printf ("%s:\n", text);
3683
3684 for (i = 0; i < 256; i++)
3685 {
3686 if (buf[i] > max_value)
3687 {
3688 max_value = buf[i];
3689 }
3690 }
3691
3692 for (i = 1; i < 100; i++)
3693 {
3694 if (buf[i] > 0)
3695 {
3696 printf ("%3d ", i);
3697 value = (buf[i] * 60) / max_value;
3698
3699 for (j = 0; j < value; j++)
3700 {
3701 putchar ('o');
3702 }
3703 printf (" %d\n", buf[i]);
3704
3705 sum += i * buf[i];
3706 counter += buf[i];
3707 }
3708 else
3709 {
3710 max = i - 1;
3711
3712 if (counter > 0)
3713 {
3714 average = (float) sum / (float) counter;
3715
3716 if (is_pulse)
3717 {
3718 printf ("pulse ");
3719 }
3720 else
3721 {
3722 printf ("pause ");
3723 }
3724
3725 printf ("avg: %4.1f=%6.1f us, ", average, (1000000. * average) / (float) F_INTERRUPTS);
3726 printf ("min: %2d=%6.1f us, ", min, (1000000. * min) / (float) F_INTERRUPTS);
3727 printf ("max: %2d=%6.1f us, ", max, (1000000. * max) / (float) F_INTERRUPTS);
3728
3729 tolerance = (max - average);
3730
3731 if (average - min > tolerance)
3732 {
3733 tolerance = average - min;
3734 }
3735
3736 tolerance = tolerance * 100 / average;
3737 printf ("tol: %4.1f%%\n", tolerance);
3738 }
3739
3740 counter = 0;
3741 sum = 0;
3742 min = i + 1;
3743 }
3744 }
3745 }
3746
3747 #define STATE_LEFT_SHIFT 0x01
3748 #define STATE_RIGHT_SHIFT 0x02
3749 #define STATE_LEFT_CTRL 0x04
3750 #define STATE_LEFT_ALT 0x08
3751 #define STATE_RIGHT_ALT 0x10
3752
3753 #define KEY_ESCAPE 0x1B // keycode = 0x006e
3754 #define KEY_MENUE 0x80 // keycode = 0x0070
3755 #define KEY_BACK 0x81 // keycode = 0x0071
3756 #define KEY_FORWARD 0x82 // keycode = 0x0072
3757 #define KEY_ADDRESS 0x83 // keycode = 0x0073
3758 #define KEY_WINDOW 0x84 // keycode = 0x0074
3759 #define KEY_1ST_PAGE 0x85 // keycode = 0x0075
3760 #define KEY_STOP 0x86 // keycode = 0x0076
3761 #define KEY_MAIL 0x87 // keycode = 0x0077
3762 #define KEY_FAVORITES 0x88 // keycode = 0x0078
3763 #define KEY_NEW_PAGE 0x89 // keycode = 0x0079
3764 #define KEY_SETUP 0x8A // keycode = 0x007a
3765 #define KEY_FONT 0x8B // keycode = 0x007b
3766 #define KEY_PRINT 0x8C // keycode = 0x007c
3767 #define KEY_ON_OFF 0x8E // keycode = 0x007c
3768
3769 #define KEY_INSERT 0x90 // keycode = 0x004b
3770 #define KEY_DELETE 0x91 // keycode = 0x004c
3771 #define KEY_LEFT 0x92 // keycode = 0x004f
3772 #define KEY_HOME 0x93 // keycode = 0x0050
3773 #define KEY_END 0x94 // keycode = 0x0051
3774 #define KEY_UP 0x95 // keycode = 0x0053
3775 #define KEY_DOWN 0x96 // keycode = 0x0054
3776 #define KEY_PAGE_UP 0x97 // keycode = 0x0055
3777 #define KEY_PAGE_DOWN 0x98 // keycode = 0x0056
3778 #define KEY_RIGHT 0x99 // keycode = 0x0059
3779 #define KEY_MOUSE_1 0x9E // keycode = 0x0400
3780 #define KEY_MOUSE_2 0x9F // keycode = 0x0800
3781
3782 static uint8_t
3783 get_fdc_key (uint16_t cmd)
3784 {
3785 static uint8_t key_table[128] =
3786 {
3787 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
3788 0, '^', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'ß', '´', 0, '\b',
3789 '\t','q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 'ü', '+', 0, 0, 'a',
3790 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'ö', 'ä', '#', '\r', 0, '<', 'y', 'x',
3791 'c', 'v', 'b', 'n', 'm', ',', '.', '-', 0, 0, 0, 0, 0, ' ', 0, 0,
3792
3793 0, '°', '!', '"', '§', '$', '%', '&', '/', '(', ')', '=', '?', '`', 0, '\b',
3794 '\t','Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 'Ü', '*', 0, 0, 'A',
3795 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Ö', 'Ä', '\'','\r', 0, '>', 'Y', 'X',
3796 'C', 'V', 'B', 'N', 'M', ';', ':', '_', 0, 0, 0, 0, 0, ' ', 0, 0
3797 };
3798 static uint8_t state;
3799
3800 uint8_t key = 0;
3801
3802 switch (cmd)
3803 {
3804 case 0x002C: state |= STATE_LEFT_SHIFT; break; // pressed left shift
3805 case 0x00AC: state &= ~STATE_LEFT_SHIFT; break; // released left shift
3806 case 0x0039: state |= STATE_RIGHT_SHIFT; break; // pressed right shift
3807 case 0x00B9: state &= ~STATE_RIGHT_SHIFT; break; // released right shift
3808 case 0x003A: state |= STATE_LEFT_CTRL; break; // pressed left ctrl
3809 case 0x00BA: state &= ~STATE_LEFT_CTRL; break; // released left ctrl
3810 case 0x003C: state |= STATE_LEFT_ALT; break; // pressed left alt
3811 case 0x00BC: state &= ~STATE_LEFT_ALT; break; // released left alt
3812 case 0x003E: state |= STATE_RIGHT_ALT; break; // pressed left alt
3813 case 0x00BE: state &= ~STATE_RIGHT_ALT; break; // released left alt
3814
3815 case 0x006e: key = KEY_ESCAPE; break;
3816 case 0x004b: key = KEY_INSERT; break;
3817 case 0x004c: key = KEY_DELETE; break;
3818 case 0x004f: key = KEY_LEFT; break;
3819 case 0x0050: key = KEY_HOME; break;
3820 case 0x0051: key = KEY_END; break;
3821 case 0x0053: key = KEY_UP; break;
3822 case 0x0054: key = KEY_DOWN; break;
3823 case 0x0055: key = KEY_PAGE_UP; break;
3824 case 0x0056: key = KEY_PAGE_DOWN; break;
3825 case 0x0059: key = KEY_RIGHT; break;
3826 case 0x0400: key = KEY_MOUSE_1; break;
3827 case 0x0800: key = KEY_MOUSE_2; break;
3828
3829 default:
3830 {
3831 if (!(cmd & 0x80)) // pressed key
3832 {
3833 if (cmd >= 0x70 && cmd <= 0x7F) // function keys
3834 {
3835 key = cmd + 0x10; // 7x -> 8x
3836 }
3837 else if (cmd < 64) // key listed in key_table
3838 {
3839 if (state & (STATE_LEFT_ALT | STATE_RIGHT_ALT))
3840 {
3841 switch (cmd)
3842 {
3843 case 0x0003: key = '²'; break;
3844 case 0x0008: key = '{'; break;
3845 case 0x0009: key = '['; break;
3846 case 0x000A: key = ']'; break;
3847 case 0x000B: key = '}'; break;
3848 case 0x000C: key = '\\'; break;
3849 case 0x001C: key = '~'; break;
3850 case 0x002D: key = '|'; break;
3851 case 0x0034: key = 0xB5; break; // Mu
3852 }
3853 }
3854 else if (state & (STATE_LEFT_CTRL))
3855 {
3856 if (key_table[cmd] >= 'a' && key_table[cmd] <= 'z')
3857 {
3858 key = key_table[cmd] - 'a' + 1;
3859 }
3860 else
3861 {
3862 key = key_table[cmd];
3863 }
3864 }
3865 else
3866 {
3867 int idx = cmd + ((state & (STATE_LEFT_SHIFT | STATE_RIGHT_SHIFT)) ? 64 : 0);
3868
3869 if (key_table[idx])
3870 {
3871 key = key_table[idx];
3872 }
3873 }
3874 }
3875 }
3876 break;
3877 }
3878 }
3879
3880 return (key);
3881 }
3882
3883 static int analyze = FALSE;
3884 static int list = FALSE;
3885 static IRMP_DATA irmp_data;
3886
3887 static void
3888 next_tick (void)
3889 {
3890 if (! analyze && ! list)
3891 {
3892 (void) irmp_ISR ();
3893
3894 if (irmp_get_data (&irmp_data))
3895 {
3896 uint8_t key;
3897
3898 ANALYZE_ONLY_NORMAL_PUTCHAR (' ');
3899
3900 if (verbose)
3901 {
3902 printf ("%8.3fms ", (double) (time_counter * 1000) / F_INTERRUPTS);
3903 }
3904
3905 if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0)
3906 {
3907 if ((key >= 0x20 && key < 0x7F) || key >= 0xA0)
3908 {
3909 printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = '%c'\n",
3910 irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, key);
3911 }
3912 else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F)) // function keys
3913 {
3914 char * p = (char *) NULL;
3915
3916 switch (key)
3917 {
3918 case '\t' : p = "TAB"; break;
3919 case '\r' : p = "CR"; break;
3920 case KEY_ESCAPE : p = "ESCAPE"; break;
3921 case KEY_MENUE : p = "MENUE"; break;
3922 case KEY_BACK : p = "BACK"; break;
3923 case KEY_FORWARD : p = "FORWARD"; break;
3924 case KEY_ADDRESS : p = "ADDRESS"; break;
3925 case KEY_WINDOW : p = "WINDOW"; break;
3926 case KEY_1ST_PAGE : p = "1ST_PAGE"; break;
3927 case KEY_STOP : p = "STOP"; break;
3928 case KEY_MAIL : p = "MAIL"; break;
3929 case KEY_FAVORITES : p = "FAVORITES"; break;
3930 case KEY_NEW_PAGE : p = "NEW_PAGE"; break;
3931 case KEY_SETUP : p = "SETUP"; break;
3932 case KEY_FONT : p = "FONT"; break;
3933 case KEY_PRINT : p = "PRINT"; break;
3934 case KEY_ON_OFF : p = "ON_OFF"; break;
3935
3936 case KEY_INSERT : p = "INSERT"; break;
3937 case KEY_DELETE : p = "DELETE"; break;
3938 case KEY_LEFT : p = "LEFT"; break;
3939 case KEY_HOME : p = "HOME"; break;
3940 case KEY_END : p = "END"; break;
3941 case KEY_UP : p = "UP"; break;
3942 case KEY_DOWN : p = "DOWN"; break;
3943 case KEY_PAGE_UP : p = "PAGE_UP"; break;
3944 case KEY_PAGE_DOWN : p = "PAGE_DOWN"; break;
3945 case KEY_RIGHT : p = "RIGHT"; break;
3946 case KEY_MOUSE_1 : p = "KEY_MOUSE_1"; break;
3947 case KEY_MOUSE_2 : p = "KEY_MOUSE_2"; break;
3948 default : p = "<UNKNWON>"; break;
3949 }
3950
3951 printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = %s\n",
3952 irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, p);
3953 }
3954 else
3955 {
3956 printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x\n",
3957 irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key);
3958 }
3959 }
3960 else
3961 {
3962 printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n",
3963 irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags);
3964 }
3965 }
3966 }
3967 }
3968
3969 int
3970 main (int argc, char ** argv)
3971 {
3972 int i;
3973 int ch;
3974 int last_ch = 0;
3975 int pulse = 0;
3976 int pause = 0;
3977
3978 int start_pulses[256];
3979 int start_pauses[256];
3980 int pulses[256];
3981 int pauses[256];
3982
3983 int first_pulse = TRUE;
3984 int first_pause = TRUE;
3985
3986 if (argc == 2)
3987 {
3988 if (! strcmp (argv[1], "-v"))
3989 {
3990 verbose = TRUE;
3991 }
3992 else if (! strcmp (argv[1], "-l"))
3993 {
3994 list = TRUE;
3995 }
3996 else if (! strcmp (argv[1], "-a"))
3997 {
3998 analyze = TRUE;
3999 }
4000 else if (! strcmp (argv[1], "-s"))
4001 {
4002 silent = TRUE;
4003 }
4004 else if (! strcmp (argv[1], "-p"))
4005 {
4006 print_timings ();
4007 return (0);
4008 }
4009 }
4010
4011 for (i = 0; i < 256; i++)
4012 {
4013 start_pulses[i] = 0;
4014 start_pauses[i] = 0;
4015 pulses[i] = 0;
4016 pauses[i] = 0;
4017 }
4018
4019 IRMP_PIN = 0xFF;
4020
4021 while ((ch = getchar ()) != EOF)
4022 {
4023 if (ch == '_' || ch == '0')
4024 {
4025 if (last_ch != ch)
4026 {
4027 if (pause > 0)
4028 {
4029 if (list)
4030 {
4031 printf ("pause: %d\n", pause);
4032 }
4033
4034 if (analyze)
4035 {
4036 if (first_pause)
4037 {
4038 if (pause < 256)
4039 {
4040 start_pauses[pause]++;
4041 }
4042 first_pause = FALSE;
4043 }
4044 else
4045 {
4046 if (pause < 256)
4047 {
4048 pauses[pause]++;
4049 }
4050 }
4051 }
4052 }
4053 pause = 0;
4054 }
4055 pulse++;
4056 IRMP_PIN = 0x00;
4057 }
4058 else if (ch == 0xaf || ch == '-' || ch == '1')
4059 {
4060 if (last_ch != ch)
4061 {
4062 if (list)
4063 {
4064 printf ("pulse: %d ", pulse);
4065 }
4066
4067 if (analyze)
4068 {
4069 if (first_pulse)
4070 {
4071 if (pulse < 256)
4072 {
4073 start_pulses[pulse]++;
4074 }
4075 first_pulse = FALSE;
4076 }
4077 else
4078 {
4079 if (pulse < 256)
4080 {
4081 pulses[pulse]++;
4082 }
4083 }
4084 }
4085 pulse = 0;
4086 }
4087
4088 pause++;
4089 IRMP_PIN = 0xff;
4090 }
4091 else if (ch == '\n')
4092 {
4093 IRMP_PIN = 0xff;
4094
4095 if (list && pause > 0)
4096 {
4097 printf ("pause: %d\n", pause);
4098 }
4099 pause = 0;
4100
4101 if (! analyze)
4102 {
4103 for (i = 0; i < (int) ((8000.0 * F_INTERRUPTS) / 10000); i++) // newline: long pause of 800 msec
4104 {
4105 next_tick ();
4106 }
4107 }
4108 first_pulse = TRUE;
4109 first_pause = TRUE;
4110 }
4111 else if (ch == '#')
4112 {
4113 if (analyze)
4114 {
4115 while ((ch = getchar()) != '\n' && ch != EOF)
4116 {
4117 ;
4118 }
4119 }
4120 else
4121 {
4122 puts ("-------------------------------------------------------------------");
4123 putchar (ch);
4124
4125 while ((ch = getchar()) != '\n' && ch != EOF)
4126 {
4127 if (ch != '\r') // ignore CR in DOS/Windows files
4128 {
4129 putchar (ch);
4130 }
4131 }
4132 putchar ('\n');
4133 }
4134
4135 }
4136
4137 last_ch = ch;
4138
4139 next_tick ();
4140 }
4141
4142 if (analyze)
4143 {
4144 print_spectrum ("START PULSES", start_pulses, TRUE);
4145 print_spectrum ("START PAUSES", start_pauses, FALSE);
4146 print_spectrum ("PULSES", pulses, TRUE);
4147 print_spectrum ("PAUSES", pauses, FALSE);
4148 puts ("-------------------------------------------------------------------------------");
4149 }
4150 return 0;
4151 }
4152
4153 #endif // ANALYZE