1 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2 * irmp.c - infrared multi-protocol decoder, supports several remote control protocols
4 * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de
6 * $Id: irmp.c,v 1.50 2010/06/14 22:00:51 fm Exp $
10 * Typical manufacturers:
13 * NEC - NEC, Yamaha, Canon, Tevion, Harman/Kardon, Hitachi, JVC, Pioneer, Toshiba, Xoro, Orion, and many other Japanese manufacturers
16 * MATSUSHITA - Matsushita
17 * KASEIKYO - Panasonic, Denon & other Japanese manufacturers (members of "Japan's Association for Electric Home Application")
18 * RECS80 - Philips, Nokia, Thomson, Nordmende, Telefunken, Saba
19 * RC5 - Philips and other European manufacturers
21 * RC6 - Philips and other European manufacturers
23 * NUBERT - Nubert Subwoofer System
24 * B&O - Bang & Olufsen
25 * PANASONIC - Panasonic (older, yet not implemented)
28 * SIEMENS - Siemens, e.g. Gigaset M740AV
30 *---------------------------------------------------------------------------------------------------------------------------------------------------
35 * frame: 1 start bit + 12-20 data bits + no stop bit
36 * data: 7 command bits + 5 address bits + 0 to 8 additional bits
38 * start bit: data "0": data "1": stop bit:
39 * -----------------_________ ------_____ ------------______
40 * 2400us 600us 600us 600us 1200us 600 us no stop bit
42 *---------------------------------------------------------------------------------------------------------------------------------------------------
45 * -------------------------
47 * frame: 1 start bit + 32 data bits + 1 stop bit
48 * data NEC: 8 address bits + 8 inverted address bits + 8 command bits + 8 inverted command bits
49 * data extended NEC: 16 address bits + 8 command bits + 8 inverted command bits
51 * start bit: data "0": data "1": stop bit:
52 * -----------------_________ ------______ ------________________ ------______....
53 * 9000us 4500us 560us 560us 560us 1690 us 560us
58 * -----------------_________------______ .... ~100ms Pause, then repeat
61 *---------------------------------------------------------------------------------------------------------------------------------------------------
66 * frame: 1 start bit + 16 data(1) bits + 1 sync bit + additional 20 data(2) bits + 1 stop bit
67 * data(1): 16 address bits
68 * data(2): 4 ID bits + 8 command bits + 8 inverted command bits
70 * start bit: data "0": data "1": sync bit: stop bit:
71 * ----------______________ ------______ ------________________ ------______________ ------______....
72 * 4500us 4500us 550us 450us 550us 1450us 550us 4500us 550us
74 *---------------------------------------------------------------------------------------------------------------------------------------------------
79 * frame: 1 start bit + 32 data bits + 1 stop bit
80 * data: 16 address bits + 16 command bits
82 * start bit: data "0": data "1": stop bit:
83 * ----------______________ ------______ ------________________ ------______....
84 * 4500us 4500us 550us 450us 550us 1450us 550us
86 *---------------------------------------------------------------------------------------------------------------------------------------------------
91 * frame: 1 start bit + 24 data bits + 1 stop bit
92 * data: 6 custom bits + 6 command bits + 12 address bits
94 * start bit: data "0": data "1": stop bit:
95 * ----------_________ ------______ ------________________ ------______....
96 * 3488us 3488us 872us 872us 872us 2616us 872us
98 *---------------------------------------------------------------------------------------------------------------------------------------------------
103 * frame: 1 start bit + 48 data bits + 1 stop bit
104 * data: 16 manufacturer bits + 4 parity bits + 4 genre1 bits + 4 genre2 bits + 10 command bits + 2 id bits + 8 parity bits
106 * start bit: data "0": data "1": stop bit:
107 * ----------______ ------______ ------________________ ------______....
108 * 3380us 1690us 423us 423us 423us 1269us 423us
110 *---------------------------------------------------------------------------------------------------------------------------------------------------
115 * frame: 2 start bits + 10 data bits + 1 stop bit
116 * data: 1 toggle bit + 3 address bits + 6 command bits
118 * start bit: data "0": data "1": stop bit:
119 * -----_____________________ -----____________ -----______________ ------_______....
120 * 158us 7432us 158us 4902us 158us 7432us 158us
122 *---------------------------------------------------------------------------------------------------------------------------------------------------
127 * frame: 2 start bits + 11 data bits + 1 stop bit
128 * data: 1 toggle bit + 4 address bits + 6 command bits
130 * start bit: data "0": data "1": stop bit:
131 * -----_____________________ -----____________ -----______________ ------_______....
132 * 158us 3637us 158us 4902us 158us 7432us 158us
134 *---------------------------------------------------------------------------------------------------------------------------------------------------
139 * RC5 frame: 2 start bits + 12 data bits + no stop bit
140 * RC5 data: 1 toggle bit + 5 address bits + 6 command bits
141 * RC5X frame: 1 start bit + 13 data bits + no stop bit
142 * RC5X data: 1 inverted command bit + 1 toggle bit + 5 address bits + 6 command bits
144 * start bit: data "0": data "1":
145 * ______----- ------______ ______------
146 * 889us 889us 889us 889us 889us 889us
148 *---------------------------------------------------------------------------------------------------------------------------------------------------
153 * frame: 0 start bits + 16 data bits + stop bit + 65ms pause + 16 inverted data bits + stop bit
154 * data: 5 address bits + 10 command bits
156 * data "0": data "1":
157 * ------________________ ------______________
158 * 275us 775us 275us 1900us
160 *---------------------------------------------------------------------------------------------------------------------------------------------------
165 * RC6 frame: 1 start bit + 1 bit "1" + 3 mode bits + 1 toggle bit + 16 data bits + 2666 µs pause
166 * RC6 data: 8 address bits + 8 command bits
168 * start bit toggle bit "0": toggle bit "1": data/mode "0": data/mode "1":
169 * ____________------- _______------- -------_______ _______------- -------_______
170 * 2666us 889us 889us 889us 889us 889us 444us 444us 444us 444us
172 *---------------------------------------------------------------------------------------------------------------------------------------------------
177 * frame: 1 start bit + 32 data bits + 1 stop bit
178 * data: 16 address bits + 11100000 + 8 command bits
180 * start bit: data "0": data "1": stop bit:
181 * -----------------_________ ------______ ------________________ ------______....
182 * 9000us 4500us 560us 560us 560us 1690 us 560us
184 *---------------------------------------------------------------------------------------------------------------------------------------------------
186 * NUBERT (subwoofer system)
187 * -------------------------
189 * frame: 1 start bit + 10 data bits + 1 stop bit
190 * data: 0 address bits + 10 command bits ?
192 * start bit: data "0": data "1": stop bit:
193 * ----------_____ ------______ ------________________ ------______....
194 * 1340us 340us 500us 1300us 1340us 340us 500us
196 *---------------------------------------------------------------------------------------------------------------------------------------------------
201 * frame: 4 start bits + 16 data bits + 1 trailer bit + 1 stop bit
202 * data: 0 address bits + 16 command bits
204 * 1st start bit: 2nd start bit: 3rd start bit: 4th start bit:
205 * -----________ -----________ -----_____________ -----________
206 * 210us 3000us 210us 3000us 210us 15000us 210us 3000us
208 * data "0": data "1": data "repeat bit": trailer bit: stop bit:
209 * -----________ -----_____________ -----___________ -----_____________ -----____...
210 * 210us 3000us 210us 9000us 210us 6000us 210us 12000us 210us
212 *---------------------------------------------------------------------------------------------------------------------------------------------------
217 * packet: 1 start frame + 19,968ms pause + N info frames + 117,76ms pause + 1 stop frame
218 * frame: 1 pre bit + 1 start bit + 9 data bits + no stop bit
219 * pause between info frames: 117,76ms
221 * data of start frame: 9 x 1
222 * data of info frame: 9 command bits
223 * data of stop frame: 9 x 1
225 * pre bit: start bit data "0": data "1":
226 * ------____________ ------______ ______------ ------______
227 * 528us 2639us 528us 528us 528us 528us 528us 528us
229 *---------------------------------------------------------------------------------------------------------------------------------------------------
234 * Timing similar to Grundig, but 16 data bits:
235 * frame: 1 pre bit + 1 start bit + 8 command bits + 8 address bits + no stop bit
237 *---------------------------------------------------------------------------------------------------------------------------------------------------
239 * PANASONIC (older protocol, yet not implemented, see also MATSUSHITA, timing very similar)
240 * -----------------------------------------------------------------------------------------
242 * frame: 1 start bit + 22 data bits + 1 stop bit
243 * 22 data bits = 5 custom bits + 6 data bits + 5 inverted custom bits + 6 inverted data bits
245 * European version: T = 456us
246 * USA & Canada version: T = 422us
248 * start bit: data "0": data "1": stop bit:
249 * 8T 8T 2T 2T 2T 6T 2T
250 * -------------____________ ------_____ ------_____________ ------_______....
251 * 3648us 3648us 912us 912us 912us 2736us 912us (Europe)
252 * 3376us 3376us 844us 844us 844us 2532us 844us (US)
254 *---------------------------------------------------------------------------------------------------------------------------------------------------
256 * This program is free software; you can redistribute it and/or modify
257 * it under the terms of the GNU General Public License as published by
258 * the Free Software Foundation; either version 2 of the License, or
259 * (at your option) any later version.
260 *---------------------------------------------------------------------------------------------------------------------------------------------------
263 #if defined(__PCM__) || defined(__PCB__) || defined(__PCH__) // CCS PIC Compiler instead of AVR
264 #define PIC_CCS_COMPILER
267 #ifdef unix // test on linux/unix
272 #include <inttypes.h>
276 #define memcpy_P memcpy
283 typedef unsigned char uint8_t;
284 typedef unsigned short uint16_t;
287 #define memcpy_P memcpy
293 #ifdef PIC_CCS_COMPILER
296 typedef unsigned int8
uint8_t;
297 typedef unsigned int16
uint16_t;
299 #define memcpy_P memcpy
303 #include <inttypes.h>
307 #include <util/delay.h>
308 #include <avr/pgmspace.h>
310 #endif // PIC_CCS_COMPILER
317 #include "irmpconfig.h"
319 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRMP_SUPPORT_NOKIA_PROTOCOL == 1
320 #define IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL 1
322 #define IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL 0
325 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_RC6_PROTOCOL == 1 || IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1 || IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
326 #define IRMP_SUPPORT_MANCHESTER 1
328 #define IRMP_SUPPORT_MANCHESTER 0
331 #define IRMP_TIMEOUT_TIME 16000.0e-6 // timeout after 16 ms darkness
332 #define IRMP_TIMEOUT_TIME_MS 16L // timeout after 16 ms darkness
334 #if (F_INTERRUPTS * IRMP_TIMEOUT_TIME_MS) / 1000 >= 255
335 #define IRMP_TIMEOUT_LEN (uint16_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)
336 typedef uint16_t PAUSE_LEN
;
338 #define IRMP_TIMEOUT_LEN (uint8_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)
339 typedef uint8_t PAUSE_LEN
;
342 #define IRMP_KEY_REPETITION_LEN (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec
344 #define MIN_TOLERANCE_00 1.0 // -0%
345 #define MAX_TOLERANCE_00 1.0 // +0%
347 #define MIN_TOLERANCE_05 0.95 // -5%
348 #define MAX_TOLERANCE_05 1.05 // +5%
350 #define MIN_TOLERANCE_10 0.9 // -10%
351 #define MAX_TOLERANCE_10 1.1 // +10%
353 #define MIN_TOLERANCE_15 0.85 // -15%
354 #define MAX_TOLERANCE_15 1.15 // +15%
356 #define MIN_TOLERANCE_20 0.8 // -20%
357 #define MAX_TOLERANCE_20 1.2 // +20%
359 #define MIN_TOLERANCE_30 0.7 // -30%
360 #define MAX_TOLERANCE_30 1.3 // +30%
362 #define MIN_TOLERANCE_40 0.6 // -40%
363 #define MAX_TOLERANCE_40 1.4 // +40%
365 #define MIN_TOLERANCE_50 0.5 // -50%
366 #define MAX_TOLERANCE_50 1.5 // +50%
368 #define MIN_TOLERANCE_60 0.4 // -60%
369 #define MAX_TOLERANCE_60 1.6 // +60%
371 #define SIRCS_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
372 #define SIRCS_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
373 #define SIRCS_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
374 #define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) // only 5% to avoid conflict with RC6
375 #define SIRCS_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
376 #define SIRCS_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
377 #define SIRCS_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
378 #define SIRCS_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
379 #define SIRCS_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
380 #define SIRCS_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
382 #define NEC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
383 #define NEC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
384 #define NEC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
385 #define NEC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
386 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
387 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
388 #define NEC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
389 #define NEC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
390 #define NEC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
391 #define NEC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
392 #define NEC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
393 #define NEC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
395 #define SAMSUNG_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
396 #define SAMSUNG_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
397 #define SAMSUNG_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
398 #define SAMSUNG_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
399 #define SAMSUNG_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
400 #define SAMSUNG_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
401 #define SAMSUNG_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
402 #define SAMSUNG_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
403 #define SAMSUNG_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
404 #define SAMSUNG_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
406 #define MATSUSHITA_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
407 #define MATSUSHITA_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
408 #define MATSUSHITA_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
409 #define MATSUSHITA_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
410 #define MATSUSHITA_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
411 #define MATSUSHITA_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
412 #define MATSUSHITA_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
413 #define MATSUSHITA_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
414 #define MATSUSHITA_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
415 #define MATSUSHITA_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
417 #define KASEIKYO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
418 #define KASEIKYO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
419 #define KASEIKYO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
420 #define KASEIKYO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
421 #define KASEIKYO_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
422 #define KASEIKYO_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_60 + 0.5) + 1)
423 #define KASEIKYO_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
424 #define KASEIKYO_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
425 #define KASEIKYO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
426 #define KASEIKYO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
428 #define RECS80_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)
429 #define RECS80_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
430 #define RECS80_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
431 #define RECS80_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
432 #define RECS80_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
433 #define RECS80_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
434 #define RECS80_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
435 #define RECS80_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
436 #define RECS80_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
437 #define RECS80_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
439 #define RC5_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
440 #define RC5_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
441 #define RC5_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
442 #define RC5_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
444 #define DENON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
445 #define DENON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
446 #define DENON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
447 #define DENON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
448 #define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
449 #define DENON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
451 #define RC6_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
452 #define RC6_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
453 #define RC6_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
454 #define RC6_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
455 #define RC6_TOGGLE_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
456 #define RC6_TOGGLE_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
457 #define RC6_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
458 #define RC6_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
460 #define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)
461 #define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_00 + 0.5) + 1)
462 #define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
463 #define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
464 #define RECS80EXT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
465 #define RECS80EXT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
466 #define RECS80EXT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
467 #define RECS80EXT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
468 #define RECS80EXT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
469 #define RECS80EXT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
471 #define NUBERT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
472 #define NUBERT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
473 #define NUBERT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
474 #define NUBERT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
475 #define NUBERT_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
476 #define NUBERT_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
477 #define NUBERT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
478 #define NUBERT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
479 #define NUBERT_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
480 #define NUBERT_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
481 #define NUBERT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
482 #define NUBERT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
484 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
485 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
486 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
487 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
488 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
489 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
490 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
491 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
492 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
493 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
494 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
495 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) // 10% is too big (uint8_t)
496 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
497 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
498 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
499 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
500 #define BANG_OLUFSEN_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
501 #define BANG_OLUFSEN_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
502 #define BANG_OLUFSEN_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
503 #define BANG_OLUFSEN_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
504 #define BANG_OLUFSEN_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
505 #define BANG_OLUFSEN_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
506 #define BANG_OLUFSEN_R_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
507 #define BANG_OLUFSEN_R_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
508 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
509 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
511 #define GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
512 #define GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
513 #define GRUNDIG_OR_NOKIA_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
514 #define GRUNDIG_OR_NOKIA_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
515 #define GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_PRE_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) + 1)
516 #define GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_PRE_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
518 #define SIEMENS_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) - 1)
519 #define SIEMENS_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) + 1)
520 #define SIEMENS_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) - 1)
521 #define SIEMENS_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) + 1)
523 #define FDC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
524 #define FDC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
525 #define FDC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
526 #define FDC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
527 #define FDC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
528 #define FDC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
529 #define FDC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
530 #define FDC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
531 #define FDC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
532 #define FDC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
534 #define RCCAR_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
535 #define RCCAR_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
536 #define RCCAR_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
537 #define RCCAR_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
538 #define RCCAR_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
539 #define RCCAR_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
540 #define RCCAR_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
541 #define RCCAR_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
542 #define RCCAR_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
543 #define RCCAR_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
545 #define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t!
548 #define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } }
549 #define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } }
550 #define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } }
551 #define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } }
553 static int time_counter
;
556 #define ANALYZE_PUTCHAR(a)
557 #define ANALYZE_ONLY_NORMAL_PUTCHAR(a)
558 #define ANALYZE_PRINTF(...)
559 #define ANALYZE_NEWLINE()
562 #if IRMP_LOGGING == 1
564 #include <util/setbaud.h>
568 #define UART0_UBRRH UBRR0H
569 #define UART0_UBRRL UBRR0L
570 #define UART0_UCSRA UCSR0A
571 #define UART0_UCSRB UCSR0B
572 #define UART0_UCSRC UCSR0C
573 #define UART0_UDRE_BIT_VALUE (1<<UDRE0)
574 #define UART0_UCSZ1_BIT_VALUE (1<<UCSZ01)
575 #define UART0_UCSZ0_BIT_VALUE (1<<UCSZ00)
577 #define UART0_URSEL_BIT_VALUE (1<<URSEL0)
579 #define UART0_URSEL_BIT_VALUE (0)
581 #define UART0_TXEN_BIT_VALUE (1<<TXEN0)
582 #define UART0_UDR UDR0
586 #define UART0_UBRRH UBRRH
587 #define UART0_UBRRL UBRRL
588 #define UART0_UCSRA UCSRA
589 #define UART0_UCSRB UCSRB
590 #define UART0_UCSRC UCSRC
591 #define UART0_UDRE_BIT_VALUE (1<<UDRE)
592 #define UART0_UCSZ1_BIT_VALUE (1<<UCSZ1)
593 #define UART0_UCSZ0_BIT_VALUE (1<<UCSZ0)
595 #define UART0_URSEL_BIT_VALUE (1<<URSEL)
597 #define UART0_URSEL_BIT_VALUE (0)
599 #define UART0_TXEN_BIT_VALUE (1<<TXEN)
600 #define UART0_UDR UDR
604 /*---------------------------------------------------------------------------------------------------------------------------------------------------
606 * @details Initializes UART
607 *---------------------------------------------------------------------------------------------------------------------------------------------------
610 irmp_uart_init (void)
612 UART0_UBRRH
= UBRRH_VALUE
; // set baud rate
613 UART0_UBRRL
= UBRRL_VALUE
;
616 UART0_UCSRA
= (1<<U2X
);
621 UART0_UCSRC
= UART0_UCSZ1_BIT_VALUE
| UART0_UCSZ0_BIT_VALUE
| UART0_URSEL_BIT_VALUE
;
622 UART0_UCSRB
|= UART0_TXEN_BIT_VALUE
; // enable UART TX
625 /*---------------------------------------------------------------------------------------------------------------------------------------------------
627 * @details Sends character
628 * @param ch character to be transmitted
629 *---------------------------------------------------------------------------------------------------------------------------------------------------
632 irmp_uart_putc (unsigned char ch
)
634 while (!(UART0_UCSRA
& UART0_UDRE_BIT_VALUE
))
642 /*---------------------------------------------------------------------------------------------------------------------------------------------------
644 *---------------------------------------------------------------------------------------------------------------------------------------------------
647 #define STARTCYCLES 2 // min count of zeros before start of logging
648 #define ENDBITS 1000 // number of sequenced highbits to detect end
649 #define DATALEN 700 // log buffer size
652 irmp_log (uint8_t val
)
654 static uint8_t buf
[DATALEN
]; // logging buffer
655 static uint16_t buf_idx
; // number of written bits
656 static uint8_t startcycles
; // current number of start-zeros
657 static uint16_t cnt
; // counts sequenced highbits - to detect end
659 if (! val
&& (startcycles
< STARTCYCLES
) && !buf_idx
) // prevent that single random zeros init logging
667 if (! val
|| (val
&& buf_idx
!= 0)) // start or continue logging on "0", "1" cannot init logging
669 if (buf_idx
< DATALEN
* 8) // index in range?
673 buf
[(buf_idx
/ 8)] |= (1<<(buf_idx
% 8)); // set bit
677 buf
[(buf_idx
/ 8)] &= ~(1<<(buf_idx
% 8)); // reset bit
684 { // if high received then look at log-stop condition
688 { // if stop condition is true, output on uart
691 for (i
= 0; i
< STARTCYCLES
; i
++)
693 irmp_uart_putc ('0'); // the ignored starting zeros
696 for (i
= 0; i
< (buf_idx
- ENDBITS
+ 20) / 8; i
++) // transform bitset into uart chars
701 for (j
= 0; j
< 8; j
++)
703 irmp_uart_putc ((d
& 1) + '0');
708 irmp_uart_putc ('\n');
721 #define irmp_log(val)
726 uint8_t protocol
; // ir protocol
727 uint8_t pulse_1_len_min
; // minimum length of pulse with bit value 1
728 uint8_t pulse_1_len_max
; // maximum length of pulse with bit value 1
729 uint8_t pause_1_len_min
; // minimum length of pause with bit value 1
730 uint8_t pause_1_len_max
; // maximum length of pause with bit value 1
731 uint8_t pulse_0_len_min
; // minimum length of pulse with bit value 0
732 uint8_t pulse_0_len_max
; // maximum length of pulse with bit value 0
733 uint8_t pause_0_len_min
; // minimum length of pause with bit value 0
734 uint8_t pause_0_len_max
; // maximum length of pause with bit value 0
735 uint8_t address_offset
; // address offset
736 uint8_t address_end
; // end of address
737 uint8_t command_offset
; // command offset
738 uint8_t command_end
; // end of command
739 uint8_t complete_len
; // complete length of frame
740 uint8_t stop_bit
; // flag: frame has stop bit
741 uint8_t lsb_first
; // flag: LSB first
742 uint8_t flags
; // some flags
745 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
747 static PROGMEM IRMP_PARAMETER sircs_param
=
749 IRMP_SIRCS_PROTOCOL
, // protocol: ir protocol
750 SIRCS_1_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
751 SIRCS_1_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
752 SIRCS_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
753 SIRCS_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
754 SIRCS_0_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
755 SIRCS_0_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
756 SIRCS_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
757 SIRCS_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
758 SIRCS_ADDRESS_OFFSET
, // address_offset: address offset
759 SIRCS_ADDRESS_OFFSET
+ SIRCS_ADDRESS_LEN
, // address_end: end of address
760 SIRCS_COMMAND_OFFSET
, // command_offset: command offset
761 SIRCS_COMMAND_OFFSET
+ SIRCS_COMMAND_LEN
, // command_end: end of command
762 SIRCS_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
763 SIRCS_STOP_BIT
, // stop_bit: flag: frame has stop bit
764 SIRCS_LSB
, // lsb_first: flag: LSB first
765 SIRCS_FLAGS
// flags: some flags
770 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
772 static PROGMEM IRMP_PARAMETER nec_param
=
774 IRMP_NEC_PROTOCOL
, // protocol: ir protocol
775 NEC_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
776 NEC_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
777 NEC_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
778 NEC_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
779 NEC_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
780 NEC_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
781 NEC_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
782 NEC_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
783 NEC_ADDRESS_OFFSET
, // address_offset: address offset
784 NEC_ADDRESS_OFFSET
+ NEC_ADDRESS_LEN
, // address_end: end of address
785 NEC_COMMAND_OFFSET
, // command_offset: command offset
786 NEC_COMMAND_OFFSET
+ NEC_COMMAND_LEN
, // command_end: end of command
787 NEC_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
788 NEC_STOP_BIT
, // stop_bit: flag: frame has stop bit
789 NEC_LSB
, // lsb_first: flag: LSB first
790 NEC_FLAGS
// flags: some flags
793 static PROGMEM IRMP_PARAMETER nec_rep_param
=
795 IRMP_NEC_PROTOCOL
, // protocol: ir protocol
796 NEC_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
797 NEC_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
798 NEC_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
799 NEC_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
800 NEC_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
801 NEC_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
802 NEC_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
803 NEC_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
804 0, // address_offset: address offset
805 0, // address_end: end of address
806 0, // command_offset: command offset
807 0, // command_end: end of command
808 0, // complete_len: complete length of frame
809 NEC_STOP_BIT
, // stop_bit: flag: frame has stop bit
810 NEC_LSB
, // lsb_first: flag: LSB first
811 NEC_FLAGS
// flags: some flags
816 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
818 static PROGMEM IRMP_PARAMETER samsung_param
=
820 IRMP_SAMSUNG_PROTOCOL
, // protocol: ir protocol
821 SAMSUNG_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
822 SAMSUNG_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
823 SAMSUNG_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
824 SAMSUNG_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
825 SAMSUNG_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
826 SAMSUNG_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
827 SAMSUNG_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
828 SAMSUNG_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
829 SAMSUNG_ADDRESS_OFFSET
, // address_offset: address offset
830 SAMSUNG_ADDRESS_OFFSET
+ SAMSUNG_ADDRESS_LEN
, // address_end: end of address
831 SAMSUNG_COMMAND_OFFSET
, // command_offset: command offset
832 SAMSUNG_COMMAND_OFFSET
+ SAMSUNG_COMMAND_LEN
, // command_end: end of command
833 SAMSUNG_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
834 SAMSUNG_STOP_BIT
, // stop_bit: flag: frame has stop bit
835 SAMSUNG_LSB
, // lsb_first: flag: LSB first
836 SAMSUNG_FLAGS
// flags: some flags
841 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
843 static PROGMEM IRMP_PARAMETER matsushita_param
=
845 IRMP_MATSUSHITA_PROTOCOL
, // protocol: ir protocol
846 MATSUSHITA_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
847 MATSUSHITA_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
848 MATSUSHITA_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
849 MATSUSHITA_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
850 MATSUSHITA_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
851 MATSUSHITA_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
852 MATSUSHITA_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
853 MATSUSHITA_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
854 MATSUSHITA_ADDRESS_OFFSET
, // address_offset: address offset
855 MATSUSHITA_ADDRESS_OFFSET
+ MATSUSHITA_ADDRESS_LEN
, // address_end: end of address
856 MATSUSHITA_COMMAND_OFFSET
, // command_offset: command offset
857 MATSUSHITA_COMMAND_OFFSET
+ MATSUSHITA_COMMAND_LEN
, // command_end: end of command
858 MATSUSHITA_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
859 MATSUSHITA_STOP_BIT
, // stop_bit: flag: frame has stop bit
860 MATSUSHITA_LSB
, // lsb_first: flag: LSB first
861 MATSUSHITA_FLAGS
// flags: some flags
866 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
868 static PROGMEM IRMP_PARAMETER kaseikyo_param
=
870 IRMP_KASEIKYO_PROTOCOL
, // protocol: ir protocol
871 KASEIKYO_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
872 KASEIKYO_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
873 KASEIKYO_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
874 KASEIKYO_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
875 KASEIKYO_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
876 KASEIKYO_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
877 KASEIKYO_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
878 KASEIKYO_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
879 KASEIKYO_ADDRESS_OFFSET
, // address_offset: address offset
880 KASEIKYO_ADDRESS_OFFSET
+ KASEIKYO_ADDRESS_LEN
, // address_end: end of address
881 KASEIKYO_COMMAND_OFFSET
, // command_offset: command offset
882 KASEIKYO_COMMAND_OFFSET
+ KASEIKYO_COMMAND_LEN
, // command_end: end of command
883 KASEIKYO_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
884 KASEIKYO_STOP_BIT
, // stop_bit: flag: frame has stop bit
885 KASEIKYO_LSB
, // lsb_first: flag: LSB first
886 KASEIKYO_FLAGS
// flags: some flags
891 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
893 static PROGMEM IRMP_PARAMETER recs80_param
=
895 IRMP_RECS80_PROTOCOL
, // protocol: ir protocol
896 RECS80_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
897 RECS80_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
898 RECS80_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
899 RECS80_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
900 RECS80_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
901 RECS80_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
902 RECS80_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
903 RECS80_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
904 RECS80_ADDRESS_OFFSET
, // address_offset: address offset
905 RECS80_ADDRESS_OFFSET
+ RECS80_ADDRESS_LEN
, // address_end: end of address
906 RECS80_COMMAND_OFFSET
, // command_offset: command offset
907 RECS80_COMMAND_OFFSET
+ RECS80_COMMAND_LEN
, // command_end: end of command
908 RECS80_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
909 RECS80_STOP_BIT
, // stop_bit: flag: frame has stop bit
910 RECS80_LSB
, // lsb_first: flag: LSB first
911 RECS80_FLAGS
// flags: some flags
916 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
918 static PROGMEM IRMP_PARAMETER rc5_param
=
920 IRMP_RC5_PROTOCOL
, // protocol: ir protocol
921 RC5_BIT_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
922 RC5_BIT_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
923 RC5_BIT_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
924 RC5_BIT_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
925 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0
926 1, // pulse_0_len_max: maximum length of pulse with bit value 0
927 1, // pause_0_len_min: minimum length of pause with bit value 0
928 1, // pause_0_len_max: maximum length of pause with bit value 0
929 RC5_ADDRESS_OFFSET
, // address_offset: address offset
930 RC5_ADDRESS_OFFSET
+ RC5_ADDRESS_LEN
, // address_end: end of address
931 RC5_COMMAND_OFFSET
, // command_offset: command offset
932 RC5_COMMAND_OFFSET
+ RC5_COMMAND_LEN
, // command_end: end of command
933 RC5_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
934 RC5_STOP_BIT
, // stop_bit: flag: frame has stop bit
935 RC5_LSB
, // lsb_first: flag: LSB first
936 RC5_FLAGS
// flags: some flags
941 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
943 static PROGMEM IRMP_PARAMETER denon_param
=
945 IRMP_DENON_PROTOCOL
, // protocol: ir protocol
946 DENON_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
947 DENON_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
948 DENON_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
949 DENON_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
950 DENON_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
951 DENON_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
952 DENON_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
953 DENON_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
954 DENON_ADDRESS_OFFSET
, // address_offset: address offset
955 DENON_ADDRESS_OFFSET
+ DENON_ADDRESS_LEN
, // address_end: end of address
956 DENON_COMMAND_OFFSET
, // command_offset: command offset
957 DENON_COMMAND_OFFSET
+ DENON_COMMAND_LEN
, // command_end: end of command
958 DENON_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
959 DENON_STOP_BIT
, // stop_bit: flag: frame has stop bit
960 DENON_LSB
, // lsb_first: flag: LSB first
961 DENON_FLAGS
// flags: some flags
966 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
968 static PROGMEM IRMP_PARAMETER rc6_param
=
970 IRMP_RC6_PROTOCOL
, // protocol: ir protocol
971 RC6_BIT_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
972 RC6_BIT_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
973 RC6_BIT_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
974 RC6_BIT_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
975 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0
976 1, // pulse_0_len_max: maximum length of pulse with bit value 0
977 1, // pause_0_len_min: minimum length of pause with bit value 0
978 1, // pause_0_len_max: maximum length of pause with bit value 0
979 RC6_ADDRESS_OFFSET
, // address_offset: address offset
980 RC6_ADDRESS_OFFSET
+ RC6_ADDRESS_LEN
, // address_end: end of address
981 RC6_COMMAND_OFFSET
, // command_offset: command offset
982 RC6_COMMAND_OFFSET
+ RC6_COMMAND_LEN
, // command_end: end of command
983 RC6_COMPLETE_DATA_LEN_SHORT
, // complete_len: complete length of frame
984 RC6_STOP_BIT
, // stop_bit: flag: frame has stop bit
985 RC6_LSB
, // lsb_first: flag: LSB first
986 RC6_FLAGS
// flags: some flags
991 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
993 static PROGMEM IRMP_PARAMETER recs80ext_param
=
995 IRMP_RECS80EXT_PROTOCOL
, // protocol: ir protocol
996 RECS80EXT_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
997 RECS80EXT_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
998 RECS80EXT_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
999 RECS80EXT_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1000 RECS80EXT_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
1001 RECS80EXT_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
1002 RECS80EXT_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
1003 RECS80EXT_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
1004 RECS80EXT_ADDRESS_OFFSET
, // address_offset: address offset
1005 RECS80EXT_ADDRESS_OFFSET
+ RECS80EXT_ADDRESS_LEN
, // address_end: end of address
1006 RECS80EXT_COMMAND_OFFSET
, // command_offset: command offset
1007 RECS80EXT_COMMAND_OFFSET
+ RECS80EXT_COMMAND_LEN
, // command_end: end of command
1008 RECS80EXT_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
1009 RECS80EXT_STOP_BIT
, // stop_bit: flag: frame has stop bit
1010 RECS80EXT_LSB
, // lsb_first: flag: LSB first
1011 RECS80EXT_FLAGS
// flags: some flags
1016 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1018 static PROGMEM IRMP_PARAMETER nubert_param
=
1020 IRMP_NUBERT_PROTOCOL
, // protocol: ir protocol
1021 NUBERT_1_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1022 NUBERT_1_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1023 NUBERT_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1024 NUBERT_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1025 NUBERT_0_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
1026 NUBERT_0_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
1027 NUBERT_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
1028 NUBERT_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
1029 NUBERT_ADDRESS_OFFSET
, // address_offset: address offset
1030 NUBERT_ADDRESS_OFFSET
+ NUBERT_ADDRESS_LEN
, // address_end: end of address
1031 NUBERT_COMMAND_OFFSET
, // command_offset: command offset
1032 NUBERT_COMMAND_OFFSET
+ NUBERT_COMMAND_LEN
, // command_end: end of command
1033 NUBERT_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
1034 NUBERT_STOP_BIT
, // stop_bit: flag: frame has stop bit
1035 NUBERT_LSB
, // lsb_first: flag: LSB first
1036 NUBERT_FLAGS
// flags: some flags
1041 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1043 static PROGMEM IRMP_PARAMETER bang_olufsen_param
=
1045 IRMP_BANG_OLUFSEN_PROTOCOL
, // protocol: ir protocol
1046 BANG_OLUFSEN_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1047 BANG_OLUFSEN_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1048 BANG_OLUFSEN_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1049 BANG_OLUFSEN_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1050 BANG_OLUFSEN_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
1051 BANG_OLUFSEN_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
1052 BANG_OLUFSEN_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
1053 BANG_OLUFSEN_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
1054 BANG_OLUFSEN_ADDRESS_OFFSET
, // address_offset: address offset
1055 BANG_OLUFSEN_ADDRESS_OFFSET
+ BANG_OLUFSEN_ADDRESS_LEN
, // address_end: end of address
1056 BANG_OLUFSEN_COMMAND_OFFSET
, // command_offset: command offset
1057 BANG_OLUFSEN_COMMAND_OFFSET
+ BANG_OLUFSEN_COMMAND_LEN
, // command_end: end of command
1058 BANG_OLUFSEN_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
1059 BANG_OLUFSEN_STOP_BIT
, // stop_bit: flag: frame has stop bit
1060 BANG_OLUFSEN_LSB
, // lsb_first: flag: LSB first
1061 BANG_OLUFSEN_FLAGS
// flags: some flags
1066 #if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1068 static PROGMEM IRMP_PARAMETER grundig_param
=
1070 IRMP_GRUNDIG_PROTOCOL
, // protocol: ir protocol
1071 GRUNDIG_OR_NOKIA_BIT_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1072 GRUNDIG_OR_NOKIA_BIT_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1073 GRUNDIG_OR_NOKIA_BIT_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1074 GRUNDIG_OR_NOKIA_BIT_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1075 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0
1076 1, // pulse_0_len_max: maximum length of pulse with bit value 0
1077 1, // pause_0_len_min: minimum length of pause with bit value 0
1078 1, // pause_0_len_max: maximum length of pause with bit value 0
1079 GRUNDIG_ADDRESS_OFFSET
, // address_offset: address offset
1080 GRUNDIG_ADDRESS_OFFSET
+ GRUNDIG_ADDRESS_LEN
, // address_end: end of address
1081 GRUNDIG_COMMAND_OFFSET
, // command_offset: command offset
1082 GRUNDIG_COMMAND_OFFSET
+ GRUNDIG_COMMAND_LEN
+ 1, // command_end: end of command (USE 1 bit MORE to STORE NOKIA DATA!)
1083 NOKIA_COMPLETE_DATA_LEN
, // complete_len: complete length of frame, here: NOKIA instead of GRUNDIG!
1084 GRUNDIG_OR_NOKIA_STOP_BIT
, // stop_bit: flag: frame has stop bit
1085 GRUNDIG_OR_NOKIA_LSB
, // lsb_first: flag: LSB first
1086 GRUNDIG_OR_NOKIA_FLAGS
// flags: some flags
1091 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1093 static PROGMEM IRMP_PARAMETER siemens_param
=
1095 IRMP_SIEMENS_PROTOCOL
, // protocol: ir protocol
1096 SIEMENS_BIT_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1097 SIEMENS_BIT_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1098 SIEMENS_BIT_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1099 SIEMENS_BIT_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1100 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0
1101 1, // pulse_0_len_max: maximum length of pulse with bit value 0
1102 1, // pause_0_len_min: minimum length of pause with bit value 0
1103 1, // pause_0_len_max: maximum length of pause with bit value 0
1104 SIEMENS_ADDRESS_OFFSET
, // address_offset: address offset
1105 SIEMENS_ADDRESS_OFFSET
+ SIEMENS_ADDRESS_LEN
, // address_end: end of address
1106 SIEMENS_COMMAND_OFFSET
, // command_offset: command offset
1107 SIEMENS_COMMAND_OFFSET
+ SIEMENS_COMMAND_LEN
, // command_end: end of command
1108 SIEMENS_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
1109 SIEMENS_STOP_BIT
, // stop_bit: flag: frame has stop bit
1110 SIEMENS_LSB
, // lsb_first: flag: LSB first
1111 SIEMENS_FLAGS
// flags: some flags
1116 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
1118 static PROGMEM IRMP_PARAMETER fdc_param
=
1120 IRMP_FDC_PROTOCOL
, // protocol: ir protocol
1121 FDC_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1122 FDC_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1123 FDC_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1124 FDC_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1125 FDC_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
1126 FDC_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
1127 FDC_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
1128 FDC_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
1129 FDC_ADDRESS_OFFSET
, // address_offset: address offset
1130 FDC_ADDRESS_OFFSET
+ FDC_ADDRESS_LEN
, // address_end: end of address
1131 FDC_COMMAND_OFFSET
, // command_offset: command offset
1132 FDC_COMMAND_OFFSET
+ FDC_COMMAND_LEN
, // command_end: end of command
1133 FDC_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
1134 FDC_STOP_BIT
, // stop_bit: flag: frame has stop bit
1135 FDC_LSB
, // lsb_first: flag: LSB first
1136 FDC_FLAGS
// flags: some flags
1141 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
1143 static PROGMEM IRMP_PARAMETER rccar_param
=
1145 IRMP_RCCAR_PROTOCOL
, // protocol: ir protocol
1146 RCCAR_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1147 RCCAR_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1148 RCCAR_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1149 RCCAR_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1150 RCCAR_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
1151 RCCAR_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
1152 RCCAR_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
1153 RCCAR_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
1154 RCCAR_ADDRESS_OFFSET
, // address_offset: address offset
1155 RCCAR_ADDRESS_OFFSET
+ RCCAR_ADDRESS_LEN
, // address_end: end of address
1156 RCCAR_COMMAND_OFFSET
, // command_offset: command offset
1157 RCCAR_COMMAND_OFFSET
+ RCCAR_COMMAND_LEN
, // command_end: end of command
1158 RCCAR_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
1159 RCCAR_STOP_BIT
, // stop_bit: flag: frame has stop bit
1160 RCCAR_LSB
, // lsb_first: flag: LSB first
1161 RCCAR_FLAGS
// flags: some flags
1166 static uint8_t irmp_bit
; // current bit position
1167 static IRMP_PARAMETER irmp_param
;
1169 static volatile uint8_t irmp_ir_detected
;
1170 static volatile uint8_t irmp_protocol
;
1171 static volatile uint16_t irmp_address
;
1172 static volatile uint16_t irmp_command
;
1173 static volatile uint16_t irmp_id
; // only used for SAMSUNG protocol
1174 static volatile uint8_t irmp_flags
;
1177 static uint8_t IRMP_PIN
;
1180 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1181 * Initialize IRMP decoder
1182 * @details Configures IRMP input pin
1183 *---------------------------------------------------------------------------------------------------------------------------------------------------
1189 #ifndef PIC_CCS_COMPILER
1190 IRMP_PORT
&= ~(1<<IRMP_BIT
); // deactivate pullup
1191 IRMP_DDR
&= ~(1<<IRMP_BIT
); // set pin to input
1192 #endif // PIC_CCS_COMPILER
1194 #if IRMP_LOGGING == 1
1199 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1201 * @details gets decoded IRMP data
1202 * @param pointer in order to store IRMP data
1203 * @return TRUE: successful, FALSE: failed
1204 *---------------------------------------------------------------------------------------------------------------------------------------------------
1207 irmp_get_data (IRMP_DATA
* irmp_data_p
)
1209 uint8_t rtc
= FALSE
;
1211 if (irmp_ir_detected
)
1213 switch (irmp_protocol
)
1215 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1216 case IRMP_SAMSUNG_PROTOCOL
:
1217 if ((irmp_command
>> 8) == (~irmp_command
& 0x00FF))
1219 irmp_command
&= 0xff;
1220 irmp_command
|= irmp_id
<< 8;
1225 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
1226 case IRMP_NEC_PROTOCOL
:
1227 if ((irmp_command
>> 8) == (~irmp_command
& 0x00FF))
1229 irmp_command
&= 0xff;
1232 else if ((irmp_command
& 0xFF00) == 0xD100)
1234 ANALYZE_PRINTF ("Switching to APPLE protocol\n");
1235 irmp_protocol
= IRMP_APPLE_PROTOCOL
;
1236 irmp_command
&= 0xff;
1241 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
1242 case IRMP_RCCAR_PROTOCOL
:
1243 // frame in irmp_data:
1244 // Bit 12 11 10 9 8 7 6 5 4 3 2 1 0
1245 // V D7 D6 D5 D4 D3 D2 D1 D0 A1 A0 C1 C0 // 10 9 8 7 6 5 4 3 2 1 0
1246 irmp_address
= (irmp_command
& 0x000C) >> 2; // addr: 0 0 0 0 0 0 0 0 0 A1 A0
1247 irmp_command
= ((irmp_command
& 0x1000) >> 2) | // V-Bit: V 0 0 0 0 0 0 0 0 0 0
1248 ((irmp_command
& 0x0003) << 8) | // C-Bits: 0 C1 C0 0 0 0 0 0 0 0 0
1249 ((irmp_command
& 0x0FF0) >> 4); // D-Bits: D7 D6 D5 D4 D3 D2 D1 D0
1250 rtc
= TRUE
; // Summe: V C1 C0 D7 D6 D5 D4 D3 D2 D1 D0
1259 irmp_data_p
->protocol
= irmp_protocol
;
1260 irmp_data_p
->address
= irmp_address
;
1261 irmp_data_p
->command
= irmp_command
;
1262 irmp_data_p
->flags
= irmp_flags
;
1268 irmp_ir_detected
= FALSE
;
1274 // these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR()
1275 static uint16_t irmp_tmp_address
; // ir address
1276 static uint16_t irmp_tmp_command
; // ir command
1277 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1278 static uint16_t irmp_tmp_id
; // ir id (only SAMSUNG)
1281 static uint8_t irmp_bit
; // current bit position
1283 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1285 * @details store bit in temp address or temp command
1286 * @param value to store: 0 or 1
1287 *---------------------------------------------------------------------------------------------------------------------------------------------------
1290 irmp_store_bit (uint8_t value
)
1292 if (irmp_bit
>= irmp_param
.address_offset
&& irmp_bit
< irmp_param
.address_end
)
1294 if (irmp_param
.lsb_first
)
1296 irmp_tmp_address
|= (((uint16_t) (value
)) << (irmp_bit
- irmp_param
.address_offset
)); // CV wants cast
1300 irmp_tmp_address
<<= 1;
1301 irmp_tmp_address
|= value
;
1304 else if (irmp_bit
>= irmp_param
.command_offset
&& irmp_bit
< irmp_param
.command_end
)
1306 if (irmp_param
.lsb_first
)
1308 irmp_tmp_command
|= (((uint16_t) (value
)) << (irmp_bit
- irmp_param
.command_offset
)); // CV wants cast
1312 irmp_tmp_command
<<= 1;
1313 irmp_tmp_command
|= value
;
1316 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1317 else if (irmp_param
.protocol
== IRMP_SAMSUNG_PROTOCOL
&& irmp_bit
>= SAMSUNG_ID_OFFSET
&& irmp_bit
< SAMSUNG_ID_OFFSET
+ SAMSUNG_ID_LEN
)
1319 irmp_tmp_id
|= (((uint16_t) (value
)) << (irmp_bit
- SAMSUNG_ID_OFFSET
)); // store with LSB first
1325 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1327 * @details ISR routine, called 10000 times per second
1328 *---------------------------------------------------------------------------------------------------------------------------------------------------
1333 static uint8_t irmp_start_bit_detected
; // flag: start bit detected
1334 static uint8_t wait_for_space
; // flag: wait for data bit space
1335 static uint8_t wait_for_start_space
; // flag: wait for start bit space
1336 static uint8_t irmp_pulse_time
; // count bit time for pulse
1337 static PAUSE_LEN irmp_pause_time
; // count bit time for pause
1338 static uint16_t last_irmp_address
= 0xFFFF; // save last irmp address to recognize key repetition
1339 static uint16_t last_irmp_command
= 0xFFFF; // save last irmp command to recognize key repetition
1340 static uint16_t repetition_counter
; // SIRCS repeats frame 2-5 times with 45 ms pause
1341 static uint8_t repetition_frame_number
;
1342 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1343 static uint16_t last_irmp_denon_command
; // save last irmp command to recognize DENON frame repetition
1345 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1346 static uint8_t rc5_cmd_bit6
; // bit 6 of RC5 command is the inverted 2nd start bit
1348 #if IRMP_SUPPORT_MANCHESTER == 1
1349 static PAUSE_LEN last_pause
; // last pause value
1351 #if IRMP_SUPPORT_MANCHESTER == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1352 static uint8_t last_value
; // last bit value
1354 uint8_t irmp_input
; // input value
1360 irmp_input
= input(IRMP_PIN
);
1362 irmp_log(irmp_input
); // log ir signal, if IRMP_LOGGING defined
1364 if (! irmp_ir_detected
) // ir code already detected?
1366 if (! irmp_start_bit_detected
) // start bit detected?
1368 if (! irmp_input
) // receiving burst?
1371 if (! irmp_pulse_time
)
1373 ANALYZE_PRINTF("%8d [starting pulse]\n", time_counter
);
1376 irmp_pulse_time
++; // increment counter
1380 if (irmp_pulse_time
) // it's dark....
1381 { // set flags for counting the time of darkness...
1382 irmp_start_bit_detected
= 1;
1383 wait_for_start_space
= 1;
1385 irmp_tmp_command
= 0;
1386 irmp_tmp_address
= 0;
1388 irmp_pause_time
= 1; // 1st pause: set to 1, not to 0!
1389 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1390 rc5_cmd_bit6
= 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame!
1395 repetition_counter
++;
1401 if (wait_for_start_space
) // we have received start bit...
1402 { // ...and are counting the time of darkness
1403 if (irmp_input
) // still dark?
1405 irmp_pause_time
++; // increment counter
1407 if (irmp_pause_time
> IRMP_TIMEOUT_LEN
) // timeout?
1409 ANALYZE_PRINTF ("error 1: pause after start bit pulse %d too long: %d\n", irmp_pulse_time
, irmp_pause_time
);
1410 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
1411 irmp_start_bit_detected
= 0; // reset flags, let's wait for another start bit
1412 irmp_pulse_time
= 0;
1413 irmp_pause_time
= 0;
1417 { // receiving first data pulse!
1418 IRMP_PARAMETER
* irmp_param_p
= (IRMP_PARAMETER
*) 0;
1420 ANALYZE_PRINTF ("start-bit: pulse = %d, pause = %d\n", irmp_pulse_time
, irmp_pause_time
);
1422 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1423 if (irmp_pulse_time
>= SIRCS_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= SIRCS_START_BIT_PULSE_LEN_MAX
&&
1424 irmp_pause_time
>= SIRCS_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= SIRCS_START_BIT_PAUSE_LEN_MAX
)
1426 ANALYZE_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1427 SIRCS_START_BIT_PULSE_LEN_MIN
, SIRCS_START_BIT_PULSE_LEN_MAX
,
1428 SIRCS_START_BIT_PAUSE_LEN_MIN
, SIRCS_START_BIT_PAUSE_LEN_MAX
);
1429 irmp_param_p
= (IRMP_PARAMETER
*) (IRMP_PARAMETER
*) &sircs_param
;
1432 #endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1434 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
1435 if (irmp_pulse_time
>= NEC_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= NEC_START_BIT_PULSE_LEN_MAX
&&
1436 irmp_pause_time
>= NEC_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= NEC_START_BIT_PAUSE_LEN_MAX
)
1438 ANALYZE_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1439 NEC_START_BIT_PULSE_LEN_MIN
, NEC_START_BIT_PULSE_LEN_MAX
,
1440 NEC_START_BIT_PAUSE_LEN_MIN
, NEC_START_BIT_PAUSE_LEN_MAX
);
1441 irmp_param_p
= (IRMP_PARAMETER
*) &nec_param
;
1443 else if (irmp_pulse_time
>= NEC_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= NEC_START_BIT_PULSE_LEN_MAX
&&
1444 irmp_pause_time
>= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX
)
1446 ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1447 NEC_START_BIT_PULSE_LEN_MIN
, NEC_START_BIT_PULSE_LEN_MAX
,
1448 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN
, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX
);
1450 irmp_param_p
= (IRMP_PARAMETER
*) &nec_rep_param
;
1453 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
1455 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1456 if (irmp_pulse_time
>= SAMSUNG_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= SAMSUNG_START_BIT_PULSE_LEN_MAX
&&
1457 irmp_pause_time
>= SAMSUNG_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= SAMSUNG_START_BIT_PAUSE_LEN_MAX
)
1459 ANALYZE_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1460 SAMSUNG_START_BIT_PULSE_LEN_MIN
, SAMSUNG_START_BIT_PULSE_LEN_MAX
,
1461 SAMSUNG_START_BIT_PAUSE_LEN_MIN
, SAMSUNG_START_BIT_PAUSE_LEN_MAX
);
1462 irmp_param_p
= (IRMP_PARAMETER
*) &samsung_param
;
1465 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1467 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
1468 if (irmp_pulse_time
>= MATSUSHITA_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= MATSUSHITA_START_BIT_PULSE_LEN_MAX
&&
1469 irmp_pause_time
>= MATSUSHITA_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= MATSUSHITA_START_BIT_PAUSE_LEN_MAX
)
1470 { // it's MATSUSHITA
1471 ANALYZE_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1472 MATSUSHITA_START_BIT_PULSE_LEN_MIN
, MATSUSHITA_START_BIT_PULSE_LEN_MAX
,
1473 MATSUSHITA_START_BIT_PAUSE_LEN_MIN
, MATSUSHITA_START_BIT_PAUSE_LEN_MAX
);
1474 irmp_param_p
= (IRMP_PARAMETER
*) &matsushita_param
;
1477 #endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
1479 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1480 if (irmp_pulse_time
>= KASEIKYO_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= KASEIKYO_START_BIT_PULSE_LEN_MAX
&&
1481 irmp_pause_time
>= KASEIKYO_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= KASEIKYO_START_BIT_PAUSE_LEN_MAX
)
1483 ANALYZE_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1484 KASEIKYO_START_BIT_PULSE_LEN_MIN
, KASEIKYO_START_BIT_PULSE_LEN_MAX
,
1485 KASEIKYO_START_BIT_PAUSE_LEN_MIN
, KASEIKYO_START_BIT_PAUSE_LEN_MAX
);
1486 irmp_param_p
= (IRMP_PARAMETER
*) &kaseikyo_param
;
1489 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1491 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
1492 if (irmp_pulse_time
>= RECS80_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RECS80_START_BIT_PULSE_LEN_MAX
&&
1493 irmp_pause_time
>= RECS80_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RECS80_START_BIT_PAUSE_LEN_MAX
)
1495 ANALYZE_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1496 RECS80_START_BIT_PULSE_LEN_MIN
, RECS80_START_BIT_PULSE_LEN_MAX
,
1497 RECS80_START_BIT_PAUSE_LEN_MIN
, RECS80_START_BIT_PAUSE_LEN_MAX
);
1498 irmp_param_p
= (IRMP_PARAMETER
*) &recs80_param
;
1501 #endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1
1503 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1504 if (((irmp_pulse_time
>= RC5_START_BIT_LEN_MIN
&& irmp_pulse_time
<= RC5_START_BIT_LEN_MAX
) ||
1505 (irmp_pulse_time
>= 2 * RC5_START_BIT_LEN_MIN
&& irmp_pulse_time
<= 2 * RC5_START_BIT_LEN_MAX
)) &&
1506 ((irmp_pause_time
>= RC5_START_BIT_LEN_MIN
&& irmp_pause_time
<= RC5_START_BIT_LEN_MAX
) ||
1507 (irmp_pause_time
>= 2 * RC5_START_BIT_LEN_MIN
&& irmp_pause_time
<= 2 * RC5_START_BIT_LEN_MAX
)))
1509 ANALYZE_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1510 RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
,
1511 RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
);
1512 irmp_param_p
= (IRMP_PARAMETER
*) &rc5_param
;
1513 last_pause
= irmp_pause_time
;
1515 if ((irmp_pulse_time
> RC5_START_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * RC5_START_BIT_LEN_MAX
) ||
1516 (irmp_pause_time
> RC5_START_BIT_LEN_MAX
&& irmp_pause_time
<= 2 * RC5_START_BIT_LEN_MAX
))
1519 rc5_cmd_bit6
= 1<<6;
1527 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1
1529 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1530 if ( (irmp_pulse_time
>= DENON_PULSE_LEN_MIN
&& irmp_pulse_time
<= DENON_PULSE_LEN_MAX
) &&
1531 ((irmp_pause_time
>= DENON_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= DENON_1_PAUSE_LEN_MAX
) ||
1532 (irmp_pause_time
>= DENON_0_PAUSE_LEN_MIN
&& irmp_pause_time
<= DENON_0_PAUSE_LEN_MAX
)))
1534 ANALYZE_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
1535 DENON_PULSE_LEN_MIN
, DENON_PULSE_LEN_MAX
,
1536 DENON_1_PAUSE_LEN_MIN
, DENON_1_PAUSE_LEN_MAX
,
1537 DENON_0_PAUSE_LEN_MIN
, DENON_0_PAUSE_LEN_MAX
);
1538 irmp_param_p
= (IRMP_PARAMETER
*) &denon_param
;
1541 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
1543 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1544 if (irmp_pulse_time
>= RC6_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RC6_START_BIT_PULSE_LEN_MAX
&&
1545 irmp_pause_time
>= RC6_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RC6_START_BIT_PAUSE_LEN_MAX
)
1547 ANALYZE_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1548 RC6_START_BIT_PULSE_LEN_MIN
, RC6_START_BIT_PULSE_LEN_MAX
,
1549 RC6_START_BIT_PAUSE_LEN_MIN
, RC6_START_BIT_PAUSE_LEN_MAX
);
1550 irmp_param_p
= (IRMP_PARAMETER
*) &rc6_param
;
1555 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
1557 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
1558 if (irmp_pulse_time
>= RECS80EXT_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RECS80EXT_START_BIT_PULSE_LEN_MAX
&&
1559 irmp_pause_time
>= RECS80EXT_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RECS80EXT_START_BIT_PAUSE_LEN_MAX
)
1561 ANALYZE_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1562 RECS80EXT_START_BIT_PULSE_LEN_MIN
, RECS80EXT_START_BIT_PULSE_LEN_MAX
,
1563 RECS80EXT_START_BIT_PAUSE_LEN_MIN
, RECS80EXT_START_BIT_PAUSE_LEN_MAX
);
1564 irmp_param_p
= (IRMP_PARAMETER
*) &recs80ext_param
;
1567 #endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
1569 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1570 if (irmp_pulse_time
>= NUBERT_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= NUBERT_START_BIT_PULSE_LEN_MAX
&&
1571 irmp_pause_time
>= NUBERT_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= NUBERT_START_BIT_PAUSE_LEN_MAX
)
1573 ANALYZE_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1574 NUBERT_START_BIT_PULSE_LEN_MIN
, NUBERT_START_BIT_PULSE_LEN_MAX
,
1575 NUBERT_START_BIT_PAUSE_LEN_MIN
, NUBERT_START_BIT_PAUSE_LEN_MAX
);
1576 irmp_param_p
= (IRMP_PARAMETER
*) &nubert_param
;
1579 #endif // IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1581 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1582 if (irmp_pulse_time
>= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN
&& irmp_pulse_time
<= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX
&&
1583 irmp_pause_time
>= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX
)
1584 { // it's BANG_OLUFSEN
1585 ANALYZE_PRINTF ("protocol = BANG_OLUFSEN\n");
1586 ANALYZE_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1587 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX
,
1588 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX
);
1589 ANALYZE_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1590 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX
,
1591 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX
);
1592 ANALYZE_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1593 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX
,
1594 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX
);
1595 ANALYZE_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1596 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX
,
1597 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX
);
1598 irmp_param_p
= (IRMP_PARAMETER
*) &bang_olufsen_param
;
1602 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1604 #if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1605 if (irmp_pulse_time
>= GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN
&& irmp_pulse_time
<= GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX
&&
1606 irmp_pause_time
>= GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN
&& irmp_pause_time
<= GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX
)
1608 ANALYZE_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1609 GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN
, GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX
,
1610 GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN
, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX
);
1611 irmp_param_p
= (IRMP_PARAMETER
*) &grundig_param
;
1612 last_pause
= irmp_pause_time
;
1616 #endif // IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1618 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1619 if (((irmp_pulse_time
>= SIEMENS_START_BIT_LEN_MIN
&& irmp_pulse_time
<= SIEMENS_START_BIT_LEN_MAX
) ||
1620 (irmp_pulse_time
>= 2 * SIEMENS_START_BIT_LEN_MIN
&& irmp_pulse_time
<= 2 * SIEMENS_START_BIT_LEN_MAX
)) &&
1621 ((irmp_pause_time
>= SIEMENS_START_BIT_LEN_MIN
&& irmp_pause_time
<= SIEMENS_START_BIT_LEN_MAX
) ||
1622 (irmp_pause_time
>= 2 * SIEMENS_START_BIT_LEN_MIN
&& irmp_pause_time
<= 2 * SIEMENS_START_BIT_LEN_MAX
)))
1624 ANALYZE_PRINTF ("protocol = SIEMENS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1625 SIEMENS_START_BIT_LEN_MIN
, SIEMENS_START_BIT_LEN_MAX
,
1626 SIEMENS_START_BIT_LEN_MIN
, SIEMENS_START_BIT_LEN_MAX
);
1627 irmp_param_p
= (IRMP_PARAMETER
*) &siemens_param
;
1628 last_pause
= irmp_pause_time
;
1632 #endif // IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1633 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
1634 if (irmp_pulse_time
>= FDC_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= FDC_START_BIT_PULSE_LEN_MAX
&&
1635 irmp_pause_time
>= FDC_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= FDC_START_BIT_PAUSE_LEN_MAX
)
1637 ANALYZE_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1638 FDC_START_BIT_PULSE_LEN_MIN
, FDC_START_BIT_PULSE_LEN_MAX
,
1639 FDC_START_BIT_PAUSE_LEN_MIN
, FDC_START_BIT_PAUSE_LEN_MAX
);
1640 irmp_param_p
= (IRMP_PARAMETER
*) &fdc_param
;
1643 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
1644 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
1645 if (irmp_pulse_time
>= RCCAR_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RCCAR_START_BIT_PULSE_LEN_MAX
&&
1646 irmp_pause_time
>= RCCAR_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RCCAR_START_BIT_PAUSE_LEN_MAX
)
1648 ANALYZE_PRINTF ("protocol = RCCAR, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1649 RCCAR_START_BIT_PULSE_LEN_MIN
, RCCAR_START_BIT_PULSE_LEN_MAX
,
1650 RCCAR_START_BIT_PAUSE_LEN_MIN
, RCCAR_START_BIT_PAUSE_LEN_MAX
);
1651 irmp_param_p
= (IRMP_PARAMETER
*) &rccar_param
;
1654 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
1656 ANALYZE_PRINTF ("protocol = UNKNOWN\n");
1657 irmp_start_bit_detected
= 0; // wait for another start bit...
1660 if (irmp_start_bit_detected
)
1662 memcpy_P (&irmp_param
, irmp_param_p
, sizeof (IRMP_PARAMETER
));
1665 if (! (irmp_param
.flags
& IRMP_PARAM_FLAG_IS_MANCHESTER
))
1667 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param
.pulse_1_len_min
, irmp_param
.pulse_1_len_max
);
1668 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param
.pause_1_len_min
, irmp_param
.pause_1_len_max
);
1672 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param
.pulse_1_len_min
, irmp_param
.pulse_1_len_max
,
1673 2 * irmp_param
.pulse_1_len_min
, 2 * irmp_param
.pulse_1_len_max
);
1674 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param
.pause_1_len_min
, irmp_param
.pause_1_len_max
,
1675 2 * irmp_param
.pause_1_len_min
, 2 * irmp_param
.pause_1_len_max
);
1678 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1679 if (irmp_param
.protocol
== IRMP_RC6_PROTOCOL
)
1681 ANALYZE_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN
, RC6_TOGGLE_BIT_LEN_MAX
);
1685 if (! (irmp_param
.flags
& IRMP_PARAM_FLAG_IS_MANCHESTER
))
1687 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param
.pulse_0_len_min
, irmp_param
.pulse_0_len_max
);
1688 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param
.pause_0_len_min
, irmp_param
.pause_0_len_max
);
1691 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1692 if (irmp_param
.protocol
== IRMP_BANG_OLUFSEN_PROTOCOL
)
1694 ANALYZE_PRINTF ("pulse_r: %3d - %3d\n", irmp_param
.pulse_0_len_min
, irmp_param
.pulse_0_len_max
);
1695 ANALYZE_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN
, BANG_OLUFSEN_R_PAUSE_LEN_MAX
);
1699 ANALYZE_PRINTF ("command_offset: %2d\n", irmp_param
.command_offset
);
1700 ANALYZE_PRINTF ("command_len: %3d\n", irmp_param
.command_end
- irmp_param
.command_offset
);
1701 ANALYZE_PRINTF ("complete_len: %3d\n", irmp_param
.complete_len
);
1702 ANALYZE_PRINTF ("stop_bit: %3d\n", irmp_param
.stop_bit
);
1708 #if IRMP_SUPPORT_MANCHESTER == 1
1709 if ((irmp_param
.flags
& IRMP_PARAM_FLAG_IS_MANCHESTER
) && irmp_param
.protocol
!= IRMP_RC6_PROTOCOL
) // manchester, but not rc6
1711 if (irmp_pause_time
> irmp_param
.pulse_1_len_max
&& irmp_pause_time
<= 2 * irmp_param
.pulse_1_len_max
)
1713 ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1714 ANALYZE_PUTCHAR ((irmp_param
.flags
& IRMP_PARAM_FLAG_1ST_PULSE_IS_1
) ? '0' : '1');
1716 irmp_store_bit ((irmp_param
.flags
& IRMP_PARAM_FLAG_1ST_PULSE_IS_1
) ? 0 : 1);
1718 else if (! last_value
)
1720 ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1722 ANALYZE_PUTCHAR ((irmp_param
.flags
& IRMP_PARAM_FLAG_1ST_PULSE_IS_1
) ? '1' : '0');
1724 irmp_store_bit ((irmp_param
.flags
& IRMP_PARAM_FLAG_1ST_PULSE_IS_1
) ? 1 : 0);
1728 #endif // IRMP_SUPPORT_MANCHESTER == 1
1730 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1731 if (irmp_param
.protocol
== IRMP_DENON_PROTOCOL
)
1733 ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1735 if (irmp_pause_time
>= DENON_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= DENON_1_PAUSE_LEN_MAX
)
1736 { // pause timings correct for "1"?
1737 ANALYZE_PUTCHAR ('1'); // yes, store 1
1741 else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)
1742 { // pause timings correct for "0"?
1743 ANALYZE_PUTCHAR ('0'); // yes, store 0
1748 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
1750 irmp_pulse_time
= 1; // set counter to 1, not 0
1751 irmp_pause_time
= 0;
1752 wait_for_start_space
= 0;
1755 else if (wait_for_space
) // the data section....
1756 { // counting the time of darkness....
1757 uint8_t got_light
= FALSE
;
1759 if (irmp_input
) // still dark?
1761 if (irmp_bit
== irmp_param
.complete_len
&& irmp_param
.stop_bit
== 1)
1763 if (irmp_pulse_time
>= irmp_param
.pulse_0_len_min
&& irmp_pulse_time
<= irmp_param
.pulse_0_len_max
)
1766 if (! (irmp_param
.flags
& IRMP_PARAM_FLAG_IS_MANCHESTER
))
1768 ANALYZE_PRINTF ("stop bit detected\n");
1771 irmp_param
.stop_bit
= 0;
1775 ANALYZE_PRINTF ("stop bit timing wrong\n");
1777 irmp_start_bit_detected
= 0; // wait for another start bit...
1778 irmp_pulse_time
= 0;
1779 irmp_pause_time
= 0;
1784 irmp_pause_time
++; // increment counter
1786 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1787 if (irmp_param
.protocol
== IRMP_SIRCS_PROTOCOL
&& // Sony has a variable number of bits:
1788 irmp_pause_time
> SIRCS_PAUSE_LEN_MAX
&& // minimum is 12
1789 irmp_bit
>= 12 - 1) // pause too long?
1790 { // yes, break and close this frame
1791 irmp_param
.complete_len
= irmp_bit
+ 1; // set new complete length
1792 got_light
= TRUE
; // this is a lie, but helps (generates stop bit)
1793 irmp_param
.command_end
= irmp_param
.command_offset
+ irmp_bit
+ 1; // correct command length
1794 irmp_pause_time
= SIRCS_PAUSE_LEN_MAX
- 1; // correct pause length
1798 #if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1799 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
&& !irmp_param
.stop_bit
)
1801 if (irmp_pause_time
> 2 * irmp_param
.pause_1_len_max
&& irmp_bit
>= GRUNDIG_COMPLETE_DATA_LEN
- 2)
1802 { // special manchester decoder
1803 irmp_param
.complete_len
= GRUNDIG_COMPLETE_DATA_LEN
; // correct complete len
1804 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1805 irmp_param
.stop_bit
= TRUE
; // set flag
1807 else if (irmp_bit
>= GRUNDIG_COMPLETE_DATA_LEN
)
1809 ANALYZE_PRINTF ("Switching to NOKIA protocol\n");
1810 irmp_param
.protocol
= IRMP_NOKIA_PROTOCOL
; // change protocol
1811 irmp_param
.address_offset
= NOKIA_ADDRESS_OFFSET
;
1812 irmp_param
.address_end
= NOKIA_ADDRESS_OFFSET
+ NOKIA_ADDRESS_LEN
;
1813 irmp_param
.command_offset
= NOKIA_COMMAND_OFFSET
;
1814 irmp_param
.command_end
= NOKIA_COMMAND_OFFSET
+ NOKIA_COMMAND_LEN
;
1816 if (irmp_tmp_command
& 0x300)
1818 irmp_tmp_address
= (irmp_tmp_command
>> 8);
1819 irmp_tmp_command
&= 0xFF;
1825 #if IRMP_SUPPORT_MANCHESTER == 1
1826 if ((irmp_param
.flags
& IRMP_PARAM_FLAG_IS_MANCHESTER
) &&
1827 irmp_pause_time
> 2 * irmp_param
.pause_1_len_max
&& irmp_bit
>= irmp_param
.complete_len
- 2 && !irmp_param
.stop_bit
)
1828 { // special manchester decoder
1829 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1830 irmp_param
.stop_bit
= TRUE
; // set flag
1833 #endif // IRMP_SUPPORT_MANCHESTER == 1
1834 if (irmp_pause_time
> IRMP_TIMEOUT_LEN
) // timeout?
1836 if (irmp_bit
== irmp_param
.complete_len
- 1 && irmp_param
.stop_bit
== 0)
1842 ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time
, irmp_bit
);
1843 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
1845 irmp_start_bit_detected
= 0; // wait for another start bit...
1846 irmp_pulse_time
= 0;
1847 irmp_pause_time
= 0;
1859 ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1861 #if IRMP_SUPPORT_MANCHESTER == 1
1862 if ((irmp_param
.flags
& IRMP_PARAM_FLAG_IS_MANCHESTER
)) // manchester
1864 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1865 if (irmp_param
.protocol
== IRMP_RC6_PROTOCOL
&& irmp_bit
>= 3 && irmp_bit
<= 5) // special bits of rc6
1867 if (irmp_pulse_time
> RC6_TOGGLE_BIT_LEN_MAX
&& irmp_pause_time
> RC6_TOGGLE_BIT_LEN_MAX
)
1869 ANALYZE_PUTCHAR ('1');
1873 ANALYZE_PUTCHAR ('0');
1879 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
1880 if (irmp_pulse_time
> irmp_param
.pulse_1_len_max
&& irmp_pulse_time
<= 2 * irmp_param
.pulse_1_len_max
)
1882 ANALYZE_PUTCHAR ((irmp_param
.flags
& IRMP_PARAM_FLAG_1ST_PULSE_IS_1
) ? '0' : '1');
1883 irmp_store_bit ((irmp_param
.flags
& IRMP_PARAM_FLAG_1ST_PULSE_IS_1
) ? 0 : 1 );
1884 ANALYZE_PUTCHAR ((irmp_param
.flags
& IRMP_PARAM_FLAG_1ST_PULSE_IS_1
) ? '1' : '0');
1885 irmp_store_bit ((irmp_param
.flags
& IRMP_PARAM_FLAG_1ST_PULSE_IS_1
) ? 1 : 0 );
1887 last_value
= (irmp_param
.flags
& IRMP_PARAM_FLAG_1ST_PULSE_IS_1
) ? 1 : 0;
1889 else // if (irmp_pulse_time >= irmp_param.pulse_1_len_max && irmp_pulse_time <= irmp_param.pulse_1_len_max)
1891 uint8_t manchester_value
;
1893 if (last_pause
> irmp_param
.pause_1_len_max
&& last_pause
<= 2 * irmp_param
.pause_1_len_max
)
1895 manchester_value
= last_value
? 0 : 1;
1896 last_value
= manchester_value
;
1900 manchester_value
= last_value
;
1904 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1905 if (irmp_param
.protocol
== IRMP_RC6_PROTOCOL
&& irmp_bit
== 1 && manchester_value
== 0) // RC6 mode != 0 ???
1907 irmp_param
.complete_len
= RC6_COMPLETE_DATA_LEN_LONG
;
1909 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
1912 ANALYZE_PUTCHAR (manchester_value
+ '0');
1914 irmp_store_bit (manchester_value
);
1917 last_pause
= irmp_pause_time
;
1921 #endif // IRMP_SUPPORT_MANCHESTER == 1
1924 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1925 if (irmp_param
.protocol
== IRMP_SAMSUNG_PROTOCOL
&& irmp_bit
== 16) // Samsung: 16th bit
1927 if (irmp_pulse_time
>= SAMSUNG_PULSE_LEN_MIN
&& irmp_pulse_time
<= SAMSUNG_PULSE_LEN_MAX
&&
1928 irmp_pause_time
>= SAMSUNG_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= SAMSUNG_START_BIT_PAUSE_LEN_MAX
)
1930 ANALYZE_PRINTF ("SYNC\n");
1935 else if (irmp_pulse_time
>= SAMSUNG_PULSE_LEN_MIN
&& irmp_pulse_time
<= SAMSUNG_PULSE_LEN_MAX
)
1937 irmp_param
.protocol
= IRMP_SAMSUNG32_PROTOCOL
;
1938 irmp_param
.command_offset
= SAMSUNG32_COMMAND_OFFSET
;
1939 irmp_param
.command_end
= SAMSUNG32_COMMAND_OFFSET
+ SAMSUNG32_COMMAND_LEN
;
1940 irmp_param
.complete_len
= SAMSUNG32_COMPLETE_DATA_LEN
;
1942 if (irmp_pause_time
>= SAMSUNG_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= SAMSUNG_1_PAUSE_LEN_MAX
)
1944 ANALYZE_PUTCHAR ('1');
1951 ANALYZE_PUTCHAR ('0');
1957 ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n");
1960 { // timing incorrect!
1961 ANALYZE_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1962 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
1963 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
1964 irmp_pause_time
= 0;
1968 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL
1970 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1971 if (irmp_param
.protocol
== IRMP_BANG_OLUFSEN_PROTOCOL
)
1973 if (irmp_pulse_time
>= BANG_OLUFSEN_PULSE_LEN_MIN
&& irmp_pulse_time
<= BANG_OLUFSEN_PULSE_LEN_MAX
)
1975 if (irmp_bit
== 1) // Bang & Olufsen: 3rd bit
1977 if (irmp_pause_time
>= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX
)
1979 ANALYZE_PRINTF ("3rd start bit\n");
1985 { // timing incorrect!
1986 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
);
1987 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
1988 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
1989 irmp_pause_time
= 0;
1992 else if (irmp_bit
== 19) // Bang & Olufsen: trailer bit
1994 if (irmp_pause_time
>= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX
)
1996 ANALYZE_PRINTF ("trailer bit\n");
2002 { // timing incorrect!
2003 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
);
2004 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2005 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2006 irmp_pause_time
= 0;
2011 if (irmp_pause_time
>= BANG_OLUFSEN_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_1_PAUSE_LEN_MAX
)
2012 { // pulse & pause timings correct for "1"?
2013 ANALYZE_PUTCHAR ('1');
2019 else if (irmp_pause_time
>= BANG_OLUFSEN_0_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_0_PAUSE_LEN_MAX
)
2020 { // pulse & pause timings correct for "0"?
2021 ANALYZE_PUTCHAR ('0');
2027 else if (irmp_pause_time
>= BANG_OLUFSEN_R_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_R_PAUSE_LEN_MAX
)
2029 ANALYZE_PUTCHAR (last_value
+ '0');
2031 irmp_store_bit (last_value
);
2035 { // timing incorrect!
2036 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
);
2037 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2038 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2039 irmp_pause_time
= 0;
2044 { // timing incorrect!
2045 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
);
2046 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2047 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2048 irmp_pause_time
= 0;
2052 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL
2054 if (irmp_pulse_time
>= irmp_param
.pulse_1_len_min
&& irmp_pulse_time
<= irmp_param
.pulse_1_len_max
&&
2055 irmp_pause_time
>= irmp_param
.pause_1_len_min
&& irmp_pause_time
<= irmp_param
.pause_1_len_max
)
2056 { // pulse & pause timings correct for "1"?
2057 ANALYZE_PUTCHAR ('1');
2062 else if (irmp_pulse_time
>= irmp_param
.pulse_0_len_min
&& irmp_pulse_time
<= irmp_param
.pulse_0_len_max
&&
2063 irmp_pause_time
>= irmp_param
.pause_0_len_min
&& irmp_pause_time
<= irmp_param
.pause_0_len_max
)
2064 { // pulse & pause timings correct for "0"?
2065 ANALYZE_PUTCHAR ('0');
2071 { // timing incorrect!
2072 ANALYZE_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
2073 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2074 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2075 irmp_pause_time
= 0;
2078 irmp_pulse_time
= 1; // set counter to 1, not 0
2082 { // counting the pulse length ...
2083 if (! irmp_input
) // still light?
2085 irmp_pulse_time
++; // increment counter
2089 wait_for_space
= 1; // let's count the time (see above)
2090 irmp_pause_time
= 1; // set pause counter to 1, not 0
2094 if (irmp_bit
== irmp_param
.complete_len
&& irmp_param
.stop_bit
== 0) // enough bits received?
2096 if (last_irmp_command
== irmp_tmp_command
&& repetition_counter
< AUTO_FRAME_REPETITION_LEN
)
2098 repetition_frame_number
++;
2102 repetition_frame_number
= 0;
2105 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
2106 // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame
2107 if (irmp_param
.protocol
== IRMP_SIRCS_PROTOCOL
&& (repetition_frame_number
== 1 || repetition_frame_number
== 2))
2109 ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
2110 repetition_frame_number
+ 1, repetition_counter
, AUTO_FRAME_REPETITION_LEN
);
2111 repetition_counter
= 0;
2116 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2117 // if SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
2118 if (irmp_param
.protocol
== IRMP_SAMSUNG32_PROTOCOL
&& (repetition_frame_number
& 0x01))
2120 ANALYZE_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
2121 repetition_frame_number
+ 1, repetition_counter
, AUTO_FRAME_REPETITION_LEN
);
2122 repetition_counter
= 0;
2127 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
2128 // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
2129 if (irmp_param
.protocol
== IRMP_NUBERT_PROTOCOL
&& (repetition_frame_number
& 0x01))
2131 ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
2132 repetition_frame_number
+ 1, repetition_counter
, AUTO_FRAME_REPETITION_LEN
);
2133 repetition_counter
= 0;
2139 ANALYZE_PRINTF ("code detected, length = %d\n", irmp_bit
);
2140 irmp_ir_detected
= TRUE
;
2142 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
2143 if (irmp_param
.protocol
== IRMP_DENON_PROTOCOL
)
2144 { // check for repetition frame
2145 if ((~irmp_tmp_command
& 0x3FF) == last_irmp_denon_command
) // command bits must be inverted
2147 irmp_tmp_command
= last_irmp_denon_command
; // use command received before!
2149 irmp_protocol
= irmp_param
.protocol
; // store protocol
2150 irmp_address
= irmp_tmp_address
; // store address
2151 irmp_command
= irmp_tmp_command
; // store command
2155 ANALYZE_PRINTF ("waiting for inverted command repetition\n");
2156 irmp_ir_detected
= FALSE
;
2157 last_irmp_denon_command
= irmp_tmp_command
;
2161 #endif // IRMP_SUPPORT_DENON_PROTOCOL
2163 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
2164 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
&& irmp_tmp_command
== 0x01ff)
2165 { // Grundig start frame?
2166 ANALYZE_PRINTF ("Detected GRUNDIG start frame, ignoring it\n");
2167 irmp_ir_detected
= FALSE
;
2170 #endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL
2172 #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1
2173 if (irmp_param
.protocol
== IRMP_NOKIA_PROTOCOL
&& irmp_tmp_address
== 0x00ff && irmp_tmp_command
== 0x00fe)
2174 { // Nokia start frame?
2175 ANALYZE_PRINTF ("Detected NOKIA start frame, ignoring it\n");
2176 irmp_ir_detected
= FALSE
;
2179 #endif // IRMP_SUPPORT_NOKIA_PROTOCOL
2181 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2182 if (irmp_param
.protocol
== IRMP_NEC_PROTOCOL
&& irmp_bit
== 0) // repetition frame
2184 irmp_tmp_address
= last_irmp_address
; // address is last address
2185 irmp_tmp_command
= last_irmp_command
; // command is last command
2186 irmp_flags
|= IRMP_FLAG_REPETITION
;
2188 #endif // IRMP_SUPPORT_NEC_PROTOCOL
2189 irmp_protocol
= irmp_param
.protocol
;
2190 irmp_address
= irmp_tmp_address
; // store address
2191 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2192 last_irmp_address
= irmp_tmp_address
; // store as last address, too
2195 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
2196 irmp_tmp_command
|= rc5_cmd_bit6
; // store bit 6
2198 irmp_command
= irmp_tmp_command
; // store command
2200 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2201 irmp_id
= irmp_tmp_id
;
2206 if (irmp_ir_detected
)
2208 if (last_irmp_command
== irmp_command
&&
2209 last_irmp_address
== irmp_address
&&
2210 repetition_counter
< IRMP_KEY_REPETITION_LEN
)
2212 irmp_flags
|= IRMP_FLAG_REPETITION
;
2215 last_irmp_address
= irmp_tmp_address
; // store as last address, too
2216 last_irmp_command
= irmp_tmp_command
; // store as last command, too
2218 repetition_counter
= 0;
2222 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2225 irmp_start_bit_detected
= 0; // and wait for next start bit
2226 irmp_tmp_command
= 0;
2227 irmp_pulse_time
= 0;
2228 irmp_pause_time
= 0;
2232 return (irmp_ir_detected
);
2237 // main function - for unix/linux + windows only!
2239 // Compile it under linux with:
2240 // cc irmp.c -o irmp
2242 // usage: ./irmp [-v|-s|-a|-l|-p] < file
2247 // -l list pulse/pauses
2251 print_timings (void)
2253 printf ("PROTOCOL START BIT NO. START BIT PULSE START BIT PAUSE\n");
2254 printf ("====================================================================================\n");
2255 printf ("SIRCS 1 %3d - %3d %3d - %3d\n",
2256 SIRCS_START_BIT_PULSE_LEN_MIN
, SIRCS_START_BIT_PULSE_LEN_MAX
, SIRCS_START_BIT_PAUSE_LEN_MIN
, SIRCS_START_BIT_PAUSE_LEN_MAX
);
2257 printf ("NEC 1 %3d - %3d %3d - %3d\n",
2258 NEC_START_BIT_PULSE_LEN_MIN
, NEC_START_BIT_PULSE_LEN_MAX
, NEC_START_BIT_PAUSE_LEN_MIN
, NEC_START_BIT_PAUSE_LEN_MAX
);
2259 printf ("NEC (rep) 1 %3d - %3d %3d - %3d\n",
2260 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
);
2261 printf ("SAMSUNG 1 %3d - %3d %3d - %3d\n",
2262 SAMSUNG_START_BIT_PULSE_LEN_MIN
, SAMSUNG_START_BIT_PULSE_LEN_MAX
, SAMSUNG_START_BIT_PAUSE_LEN_MIN
, SAMSUNG_START_BIT_PAUSE_LEN_MAX
);
2263 printf ("MATSUSHITA 1 %3d - %3d %3d - %3d\n",
2264 MATSUSHITA_START_BIT_PULSE_LEN_MIN
, MATSUSHITA_START_BIT_PULSE_LEN_MAX
, MATSUSHITA_START_BIT_PAUSE_LEN_MIN
, MATSUSHITA_START_BIT_PAUSE_LEN_MAX
);
2265 printf ("KASEIKYO 1 %3d - %3d %3d - %3d\n",
2266 KASEIKYO_START_BIT_PULSE_LEN_MIN
, KASEIKYO_START_BIT_PULSE_LEN_MAX
, KASEIKYO_START_BIT_PAUSE_LEN_MIN
, KASEIKYO_START_BIT_PAUSE_LEN_MAX
);
2267 printf ("RECS80 1 %3d - %3d %3d - %3d\n",
2268 RECS80_START_BIT_PULSE_LEN_MIN
, RECS80_START_BIT_PULSE_LEN_MAX
, RECS80_START_BIT_PAUSE_LEN_MIN
, RECS80_START_BIT_PAUSE_LEN_MAX
);
2269 printf ("RC5 1 %3d - %3d %3d - %3d\n",
2270 RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
, RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
);
2271 printf ("DENON 1 %3d - %3d %3d - %3d or %3d - %3d\n",
2272 DENON_PULSE_LEN_MIN
, DENON_PULSE_LEN_MAX
, DENON_1_PAUSE_LEN_MIN
, DENON_1_PAUSE_LEN_MAX
, DENON_0_PAUSE_LEN_MIN
, DENON_0_PAUSE_LEN_MAX
);
2273 printf ("RC6 1 %3d - %3d %3d - %3d\n",
2274 RC6_START_BIT_PULSE_LEN_MIN
, RC6_START_BIT_PULSE_LEN_MAX
, RC6_START_BIT_PAUSE_LEN_MIN
, RC6_START_BIT_PAUSE_LEN_MAX
);
2275 printf ("RECS80EXT 1 %3d - %3d %3d - %3d\n",
2276 RECS80EXT_START_BIT_PULSE_LEN_MIN
, RECS80EXT_START_BIT_PULSE_LEN_MAX
, RECS80EXT_START_BIT_PAUSE_LEN_MIN
, RECS80EXT_START_BIT_PAUSE_LEN_MAX
);
2277 printf ("NUBERT 1 %3d - %3d %3d - %3d\n",
2278 NUBERT_START_BIT_PULSE_LEN_MIN
, NUBERT_START_BIT_PULSE_LEN_MAX
, NUBERT_START_BIT_PAUSE_LEN_MIN
, NUBERT_START_BIT_PAUSE_LEN_MAX
);
2279 printf ("BANG_OLUFSEN 1 %3d - %3d %3d - %3d\n",
2280 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX
, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX
);
2281 printf ("BANG_OLUFSEN 2 %3d - %3d %3d - %3d\n",
2282 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX
, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX
);
2283 printf ("BANG_OLUFSEN 3 %3d - %3d %3d - %3d\n",
2284 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX
, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX
);
2285 printf ("BANG_OLUFSEN 4 %3d - %3d %3d - %3d\n",
2286 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX
, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX
);
2287 printf ("GRUNDIG/NOKIA 1 %3d - %3d %3d - %3d\n",
2288 GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN
, GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX
, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN
, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX
);
2289 printf ("SIEMENS 1 %3d - %3d %3d - %3d\n",
2290 SIEMENS_START_BIT_LEN_MIN
, SIEMENS_START_BIT_LEN_MAX
, SIEMENS_START_BIT_LEN_MIN
, SIEMENS_START_BIT_LEN_MAX
);
2291 printf ("FDC 1 %3d - %3d %3d - %3d\n",
2292 FDC_START_BIT_PULSE_LEN_MIN
, FDC_START_BIT_PULSE_LEN_MAX
, FDC_START_BIT_PAUSE_LEN_MIN
, FDC_START_BIT_PAUSE_LEN_MAX
);
2293 printf ("RCCAR 1 %3d - %3d %3d - %3d\n",
2294 RCCAR_START_BIT_PULSE_LEN_MIN
, RCCAR_START_BIT_PULSE_LEN_MAX
, RCCAR_START_BIT_PAUSE_LEN_MIN
, RCCAR_START_BIT_PAUSE_LEN_MAX
);
2298 print_spectrum (char * text
, int * buf
, int is_pulse
)
2311 puts ("-------------------------------------------------------------------------------");
2312 printf ("%s:\n", text
);
2314 for (i
= 0; i
< 256; i
++)
2316 if (buf
[i
] > max_value
)
2322 for (i
= 0; i
< 100; i
++)
2327 value
= (buf
[i
] * 60) / max_value
;
2329 for (j
= 0; j
< value
; j
++)
2333 printf (" %d\n", buf
[i
]);
2344 average
= (float) sum
/ (float) counter
;
2355 printf ("avg: %4.1f=%6.1f us, ", average
, (1000000. * average
) / (float) F_INTERRUPTS
);
2356 printf ("min: %2d=%6.1f us, ", min
, (1000000. * min
) / (float) F_INTERRUPTS
);
2357 printf ("max: %2d=%6.1f us, ", max
, (1000000. * max
) / (float) F_INTERRUPTS
);
2359 tolerance
= (max
- average
);
2361 if (average
- min
> tolerance
)
2363 tolerance
= average
- min
;
2366 tolerance
= tolerance
* 100 / average
;
2367 printf ("tol: %4.1f%%\n", tolerance
);
2378 main (int argc
, char ** argv
)
2381 int analyze
= FALSE
;
2388 int start_pulses
[256];
2389 int start_pauses
[256];
2393 int first_pulse
= TRUE
;
2394 int first_pause
= TRUE
;
2396 IRMP_DATA irmp_data
;
2400 if (! strcmp (argv
[1], "-v"))
2404 else if (! strcmp (argv
[1], "-l"))
2408 else if (! strcmp (argv
[1], "-a"))
2412 else if (! strcmp (argv
[1], "-s"))
2416 else if (! strcmp (argv
[1], "-p"))
2423 for (i
= 0; i
< 256; i
++)
2425 start_pulses
[i
] = 0;
2426 start_pauses
[i
] = 0;
2433 while ((ch
= getchar ()) != EOF
)
2435 if (ch
== '_' || ch
== '0')
2443 printf ("pause: %d\n", pause
);
2452 start_pauses
[pause
]++;
2454 first_pause
= FALSE
;
2470 else if (ch
== 0xaf || ch
== '-' || ch
== '1')
2476 printf ("pulse: %d ", pulse
);
2485 start_pulses
[pulse
]++;
2487 first_pulse
= FALSE
;
2503 else if (ch
== '\n')
2507 if (list
&& pause
> 0)
2509 printf ("pause: %d\n", pause
);
2515 for (i
= 0; i
< (int) ((8000.0 * F_INTERRUPTS
) / 10000); i
++) // newline: long pause of 800 msec
2527 while ((ch
= getchar()) != '\n' && ch
!= EOF
)
2534 puts ("-------------------------------------------------------------------");
2537 while ((ch
= getchar()) != '\n' && ch
!= EOF
)
2539 if (ch
!= '\r') // ignore CR in DOS/Windows files
2551 if (! analyze
&& ! list
)
2555 if (irmp_get_data (&irmp_data
))
2557 ANALYZE_ONLY_NORMAL_PUTCHAR (' ');
2558 printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n",
2559 irmp_data
.protocol
, irmp_data
.address
, irmp_data
.command
, irmp_data
.flags
);
2566 print_spectrum ("START PULSES", start_pulses
, TRUE
);
2567 print_spectrum ("START PAUSES", start_pauses
, FALSE
);
2568 print_spectrum ("PULSES", pulses
, TRUE
);
2569 print_spectrum ("PAUSES", pauses
, FALSE
);
2570 puts ("-------------------------------------------------------------------------------");