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.39 2010/06/10 10:09:47 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 #define IRMP_TIMEOUT_TIME 16500.0e-6 // timeout after 16.5 ms darkness
326 #define IRMP_TIMEOUT_LEN (uint8_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)
327 #define IRMP_KEY_REPETITION_LEN (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec
329 #define MIN_TOLERANCE_00 1.0 // -0%
330 #define MAX_TOLERANCE_00 1.0 // +0%
332 #define MIN_TOLERANCE_05 0.95 // -5%
333 #define MAX_TOLERANCE_05 1.05 // +5%
335 #define MIN_TOLERANCE_10 0.9 // -10%
336 #define MAX_TOLERANCE_10 1.1 // +10%
338 #define MIN_TOLERANCE_15 0.85 // -15%
339 #define MAX_TOLERANCE_15 1.15 // +15%
341 #define MIN_TOLERANCE_20 0.8 // -20%
342 #define MAX_TOLERANCE_20 1.2 // +20%
344 #define MIN_TOLERANCE_30 0.7 // -30%
345 #define MAX_TOLERANCE_30 1.3 // +30%
347 #define MIN_TOLERANCE_40 0.6 // -40%
348 #define MAX_TOLERANCE_40 1.4 // +40%
350 #define MIN_TOLERANCE_50 0.5 // -50%
351 #define MAX_TOLERANCE_50 1.5 // +50%
353 #define MIN_TOLERANCE_60 0.4 // -60%
354 #define MAX_TOLERANCE_60 1.6 // +60%
356 #define SIRCS_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
357 #define SIRCS_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
358 #define SIRCS_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
359 #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
360 #define SIRCS_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
361 #define SIRCS_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
362 #define SIRCS_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
363 #define SIRCS_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
364 #define SIRCS_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
365 #define SIRCS_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
367 #define NEC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
368 #define NEC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
369 #define NEC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
370 #define NEC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
371 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
372 #define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
373 #define NEC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
374 #define NEC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
375 #define NEC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
376 #define NEC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
377 #define NEC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
378 #define NEC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
380 #define SAMSUNG_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
381 #define SAMSUNG_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
382 #define SAMSUNG_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
383 #define SAMSUNG_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
384 #define SAMSUNG_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
385 #define SAMSUNG_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
386 #define SAMSUNG_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
387 #define SAMSUNG_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
388 #define SAMSUNG_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)
389 #define SAMSUNG_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)
391 #define MATSUSHITA_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
392 #define MATSUSHITA_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
393 #define MATSUSHITA_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
394 #define MATSUSHITA_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
395 #define MATSUSHITA_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
396 #define MATSUSHITA_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
397 #define MATSUSHITA_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
398 #define MATSUSHITA_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
399 #define MATSUSHITA_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)
400 #define MATSUSHITA_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)
402 #define KASEIKYO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
403 #define KASEIKYO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
404 #define KASEIKYO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
405 #define KASEIKYO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
406 #define KASEIKYO_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
407 #define KASEIKYO_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_60 + 0.5) + 1)
408 #define KASEIKYO_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
409 #define KASEIKYO_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
410 #define KASEIKYO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1)
411 #define KASEIKYO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1)
413 #define RECS80_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)
414 #define RECS80_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
415 #define RECS80_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
416 #define RECS80_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
417 #define RECS80_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
418 #define RECS80_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
419 #define RECS80_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
420 #define RECS80_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
421 #define RECS80_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
422 #define RECS80_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
424 #define RC5_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
425 #define RC5_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
426 #define RC5_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
427 #define RC5_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
429 #define DENON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
430 #define DENON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
431 #define DENON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
432 #define DENON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
433 #define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
434 #define DENON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
436 #define RC6_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
437 #define RC6_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
438 #define RC6_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
439 #define RC6_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
440 #define RC6_TOGGLE_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
441 #define RC6_TOGGLE_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
442 #define RC6_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
443 #define RC6_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
445 #define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1)
446 #define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_00 + 0.5) + 1)
447 #define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1)
448 #define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1)
449 #define RECS80EXT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
450 #define RECS80EXT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
451 #define RECS80EXT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
452 #define RECS80EXT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
453 #define RECS80EXT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
454 #define RECS80EXT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
456 #define NUBERT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
457 #define NUBERT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
458 #define NUBERT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
459 #define NUBERT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
460 #define NUBERT_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
461 #define NUBERT_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
462 #define NUBERT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
463 #define NUBERT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
464 #define NUBERT_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
465 #define NUBERT_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
466 #define NUBERT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
467 #define NUBERT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
469 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
470 #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
471 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
472 #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
473 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
474 #define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
475 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
476 #define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
477 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
478 #define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
479 #define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
480 #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)
481 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
482 #define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
483 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
484 #define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
485 #define BANG_OLUFSEN_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
486 #define BANG_OLUFSEN_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
487 #define BANG_OLUFSEN_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
488 #define BANG_OLUFSEN_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
489 #define BANG_OLUFSEN_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
490 #define BANG_OLUFSEN_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
491 #define BANG_OLUFSEN_R_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
492 #define BANG_OLUFSEN_R_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
493 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)
494 #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)
496 #define GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
497 #define GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
498 #define GRUNDIG_OR_NOKIA_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
499 #define GRUNDIG_OR_NOKIA_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
500 #define GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_PRE_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) + 1)
501 #define GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_PRE_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
503 #define SIEMENS_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) - 1)
504 #define SIEMENS_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) + 1)
505 #define SIEMENS_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) - 1)
506 #define SIEMENS_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) + 1)
508 #define FDC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
509 #define FDC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
510 #define FDC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
511 #define FDC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
512 #define FDC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
513 #define FDC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
514 #define FDC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
515 #define FDC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
516 #define FDC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
517 #define FDC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
518 #define FDC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)
519 #define FDC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)
521 #define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t!
524 #define DEBUG_PUTCHAR(a) { if (! silent) { putchar (a); } }
525 #define DEBUG_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } }
526 #define DEBUG_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } }
527 #define DEBUG_NEWLINE() { if (verbose) { putchar ('\n'); } }
529 static int time_counter
;
532 #define DEBUG_PUTCHAR(a)
533 #define DEBUG_ONLY_NORMAL_PUTCHAR(a)
534 #define DEBUG_PRINTF(...)
535 #define DEBUG_NEWLINE()
538 #if IRMP_LOGGING == 1
540 #include <util/setbaud.h>
544 #define UART0_UBRRH UBRR0H
545 #define UART0_UBRRL UBRR0L
546 #define UART0_UCSRA UCSR0A
547 #define UART0_UCSRB UCSR0B
548 #define UART0_UCSRC UCSR0C
549 #define UART0_UDRE_BIT_VALUE (1<<UDRE0)
550 #define UART0_UCSZ1_BIT_VALUE (1<<UCSZ01)
551 #define UART0_UCSZ0_BIT_VALUE (1<<UCSZ00)
553 #define UART0_URSEL_BIT_VALUE (1<<URSEL0)
555 #define UART0_URSEL_BIT_VALUE (0)
557 #define UART0_TXEN_BIT_VALUE (1<<TXEN0)
558 #define UART0_UDR UDR0
562 #define UART0_UBRRH UBRRH
563 #define UART0_UBRRL UBRRL
564 #define UART0_UCSRA UCSRA
565 #define UART0_UCSRB UCSRB
566 #define UART0_UCSRC UCSRC
567 #define UART0_UDRE_BIT_VALUE (1<<UDRE)
568 #define UART0_UCSZ1_BIT_VALUE (1<<UCSZ1)
569 #define UART0_UCSZ0_BIT_VALUE (1<<UCSZ0)
571 #define UART0_URSEL_BIT_VALUE (1<<URSEL)
573 #define UART0_URSEL_BIT_VALUE (0)
575 #define UART0_TXEN_BIT_VALUE (1<<TXEN)
576 #define UART0_UDR UDR
580 /*---------------------------------------------------------------------------------------------------------------------------------------------------
582 * @details Initializes UART
583 *---------------------------------------------------------------------------------------------------------------------------------------------------
586 irmp_uart_init (void)
588 UART0_UBRRH
= UBRRH_VALUE
; // set baud rate
589 UART0_UBRRL
= UBRRL_VALUE
;
592 UART0_UCSRA
= (1<<U2X
);
597 UART0_UCSRC
= UART0_UCSZ1_BIT_VALUE
| UART0_UCSZ0_BIT_VALUE
| UART0_URSEL_BIT_VALUE
;
598 UART0_UCSRB
|= UART0_TXEN_BIT_VALUE
; // enable UART TX
601 /*---------------------------------------------------------------------------------------------------------------------------------------------------
603 * @details Sends character
604 * @param ch character to be transmitted
605 *---------------------------------------------------------------------------------------------------------------------------------------------------
608 irmp_uart_putc (unsigned char ch
)
610 while (!(UART0_UCSRA
& UART0_UDRE_BIT_VALUE
))
618 /*---------------------------------------------------------------------------------------------------------------------------------------------------
620 *---------------------------------------------------------------------------------------------------------------------------------------------------
623 #define STARTCYCLES 2 // min count of zeros before start of logging
624 #define ENDBITS 1000 // number of sequenced highbits to detect end
625 #define DATALEN 700 // log buffer size
628 irmp_log (uint8_t val
)
630 static uint8_t buf
[DATALEN
]; // logging buffer
631 static uint16_t buf_idx
; // number of written bits
632 static uint8_t startcycles
; // current number of start-zeros
633 static uint16_t cnt
; // counts sequenced highbits - to detect end
635 if (! val
&& (startcycles
< STARTCYCLES
) && !buf_idx
) // prevent that single random zeros init logging
643 if (! val
|| (val
&& buf_idx
!= 0)) // start or continue logging on "0", "1" cannot init logging
645 if (buf_idx
< DATALEN
* 8) // index in range?
649 buf
[(buf_idx
/ 8)] |= (1<<(buf_idx
% 8)); // set bit
653 buf
[(buf_idx
/ 8)] &= ~(1<<(buf_idx
% 8)); // reset bit
660 { // if high received then look at log-stop condition
664 { // if stop condition is true, output on uart
667 for (i
= 0; i
< STARTCYCLES
; i
++)
669 irmp_uart_putc ('0'); // the ignored starting zeros
672 for (i
= 0; i
< (buf_idx
- ENDBITS
+ 20) / 8; i
++) // transform bitset into uart chars
677 for (j
= 0; j
< 8; j
++)
679 irmp_uart_putc ((d
& 1) + '0');
684 irmp_uart_putc ('\n');
697 #define irmp_log(val)
702 uint8_t protocol
; // ir protocol
703 uint8_t pulse_1_len_min
; // minimum length of pulse with bit value 1
704 uint8_t pulse_1_len_max
; // maximum length of pulse with bit value 1
705 uint8_t pause_1_len_min
; // minimum length of pause with bit value 1
706 uint8_t pause_1_len_max
; // maximum length of pause with bit value 1
707 uint8_t pulse_0_len_min
; // minimum length of pulse with bit value 0
708 uint8_t pulse_0_len_max
; // maximum length of pulse with bit value 0
709 uint8_t pause_0_len_min
; // minimum length of pause with bit value 0
710 uint8_t pause_0_len_max
; // maximum length of pause with bit value 0
711 uint8_t address_offset
; // address offset
712 uint8_t address_end
; // end of address
713 uint8_t command_offset
; // command offset
714 uint8_t command_end
; // end of command
715 uint8_t complete_len
; // complete length of frame
716 uint8_t stop_bit
; // flag: frame has stop bit
717 uint8_t lsb_first
; // flag: LSB first
720 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
722 static PROGMEM IRMP_PARAMETER sircs_param
=
724 IRMP_SIRCS_PROTOCOL
, // protocol: ir protocol
725 SIRCS_1_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
726 SIRCS_1_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
727 SIRCS_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
728 SIRCS_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
729 SIRCS_0_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
730 SIRCS_0_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
731 SIRCS_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
732 SIRCS_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
733 SIRCS_ADDRESS_OFFSET
, // address_offset: address offset
734 SIRCS_ADDRESS_OFFSET
+ SIRCS_ADDRESS_LEN
, // address_end: end of address
735 SIRCS_COMMAND_OFFSET
, // command_offset: command offset
736 SIRCS_COMMAND_OFFSET
+ SIRCS_COMMAND_LEN
, // command_end: end of command
737 SIRCS_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
738 SIRCS_STOP_BIT
, // stop_bit: flag: frame has stop bit
739 SIRCS_LSB
// lsb_first: flag: LSB first
744 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
746 static PROGMEM IRMP_PARAMETER nec_param
=
748 IRMP_NEC_PROTOCOL
, // protocol: ir protocol
749 NEC_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
750 NEC_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
751 NEC_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
752 NEC_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
753 NEC_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
754 NEC_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
755 NEC_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
756 NEC_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
757 NEC_ADDRESS_OFFSET
, // address_offset: address offset
758 NEC_ADDRESS_OFFSET
+ NEC_ADDRESS_LEN
, // address_end: end of address
759 NEC_COMMAND_OFFSET
, // command_offset: command offset
760 NEC_COMMAND_OFFSET
+ NEC_COMMAND_LEN
, // command_end: end of command
761 NEC_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
762 NEC_STOP_BIT
, // stop_bit: flag: frame has stop bit
763 NEC_LSB
// lsb_first: flag: LSB first
766 static PROGMEM IRMP_PARAMETER nec_rep_param
=
768 IRMP_NEC_PROTOCOL
, // protocol: ir protocol
769 NEC_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
770 NEC_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
771 NEC_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
772 NEC_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
773 NEC_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
774 NEC_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
775 NEC_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
776 NEC_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
777 0, // address_offset: address offset
778 0, // address_end: end of address
779 0, // command_offset: command offset
780 0, // command_end: end of command
781 0, // complete_len: complete length of frame
782 NEC_STOP_BIT
, // stop_bit: flag: frame has stop bit
783 NEC_LSB
// lsb_first: flag: LSB first
788 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
790 static PROGMEM IRMP_PARAMETER samsung_param
=
792 IRMP_SAMSUNG_PROTOCOL
, // protocol: ir protocol
793 SAMSUNG_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
794 SAMSUNG_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
795 SAMSUNG_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
796 SAMSUNG_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
797 SAMSUNG_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
798 SAMSUNG_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
799 SAMSUNG_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
800 SAMSUNG_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
801 SAMSUNG_ADDRESS_OFFSET
, // address_offset: address offset
802 SAMSUNG_ADDRESS_OFFSET
+ SAMSUNG_ADDRESS_LEN
, // address_end: end of address
803 SAMSUNG_COMMAND_OFFSET
, // command_offset: command offset
804 SAMSUNG_COMMAND_OFFSET
+ SAMSUNG_COMMAND_LEN
, // command_end: end of command
805 SAMSUNG_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
806 SAMSUNG_STOP_BIT
, // stop_bit: flag: frame has stop bit
807 SAMSUNG_LSB
// lsb_first: flag: LSB first
812 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
814 static PROGMEM IRMP_PARAMETER matsushita_param
=
816 IRMP_MATSUSHITA_PROTOCOL
, // protocol: ir protocol
817 MATSUSHITA_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
818 MATSUSHITA_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
819 MATSUSHITA_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
820 MATSUSHITA_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
821 MATSUSHITA_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
822 MATSUSHITA_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
823 MATSUSHITA_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
824 MATSUSHITA_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
825 MATSUSHITA_ADDRESS_OFFSET
, // address_offset: address offset
826 MATSUSHITA_ADDRESS_OFFSET
+ MATSUSHITA_ADDRESS_LEN
, // address_end: end of address
827 MATSUSHITA_COMMAND_OFFSET
, // command_offset: command offset
828 MATSUSHITA_COMMAND_OFFSET
+ MATSUSHITA_COMMAND_LEN
, // command_end: end of command
829 MATSUSHITA_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
830 MATSUSHITA_STOP_BIT
, // stop_bit: flag: frame has stop bit
831 MATSUSHITA_LSB
// lsb_first: flag: LSB first
836 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
838 static PROGMEM IRMP_PARAMETER kaseikyo_param
=
840 IRMP_KASEIKYO_PROTOCOL
, // protocol: ir protocol
841 KASEIKYO_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
842 KASEIKYO_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
843 KASEIKYO_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
844 KASEIKYO_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
845 KASEIKYO_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
846 KASEIKYO_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
847 KASEIKYO_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
848 KASEIKYO_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
849 KASEIKYO_ADDRESS_OFFSET
, // address_offset: address offset
850 KASEIKYO_ADDRESS_OFFSET
+ KASEIKYO_ADDRESS_LEN
, // address_end: end of address
851 KASEIKYO_COMMAND_OFFSET
, // command_offset: command offset
852 KASEIKYO_COMMAND_OFFSET
+ KASEIKYO_COMMAND_LEN
, // command_end: end of command
853 KASEIKYO_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
854 KASEIKYO_STOP_BIT
, // stop_bit: flag: frame has stop bit
855 KASEIKYO_LSB
// lsb_first: flag: LSB first
860 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
862 static PROGMEM IRMP_PARAMETER recs80_param
=
864 IRMP_RECS80_PROTOCOL
, // protocol: ir protocol
865 RECS80_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
866 RECS80_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
867 RECS80_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
868 RECS80_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
869 RECS80_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
870 RECS80_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
871 RECS80_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
872 RECS80_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
873 RECS80_ADDRESS_OFFSET
, // address_offset: address offset
874 RECS80_ADDRESS_OFFSET
+ RECS80_ADDRESS_LEN
, // address_end: end of address
875 RECS80_COMMAND_OFFSET
, // command_offset: command offset
876 RECS80_COMMAND_OFFSET
+ RECS80_COMMAND_LEN
, // command_end: end of command
877 RECS80_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
878 RECS80_STOP_BIT
, // stop_bit: flag: frame has stop bit
879 RECS80_LSB
// lsb_first: flag: LSB first
884 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
886 static PROGMEM IRMP_PARAMETER rc5_param
=
888 IRMP_RC5_PROTOCOL
, // protocol: ir protocol
889 RC5_BIT_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
890 RC5_BIT_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
891 RC5_BIT_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
892 RC5_BIT_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
893 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0
894 1, // pulse_0_len_max: maximum length of pulse with bit value 0
895 1, // pause_0_len_min: minimum length of pause with bit value 0
896 1, // pause_0_len_max: maximum length of pause with bit value 0
897 RC5_ADDRESS_OFFSET
, // address_offset: address offset
898 RC5_ADDRESS_OFFSET
+ RC5_ADDRESS_LEN
, // address_end: end of address
899 RC5_COMMAND_OFFSET
, // command_offset: command offset
900 RC5_COMMAND_OFFSET
+ RC5_COMMAND_LEN
, // command_end: end of command
901 RC5_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
902 RC5_STOP_BIT
, // stop_bit: flag: frame has stop bit
903 RC5_LSB
// lsb_first: flag: LSB first
908 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
910 static PROGMEM IRMP_PARAMETER denon_param
=
912 IRMP_DENON_PROTOCOL
, // protocol: ir protocol
913 DENON_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
914 DENON_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
915 DENON_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
916 DENON_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
917 DENON_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
918 DENON_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
919 DENON_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
920 DENON_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
921 DENON_ADDRESS_OFFSET
, // address_offset: address offset
922 DENON_ADDRESS_OFFSET
+ DENON_ADDRESS_LEN
, // address_end: end of address
923 DENON_COMMAND_OFFSET
, // command_offset: command offset
924 DENON_COMMAND_OFFSET
+ DENON_COMMAND_LEN
, // command_end: end of command
925 DENON_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
926 DENON_STOP_BIT
, // stop_bit: flag: frame has stop bit
927 DENON_LSB
// lsb_first: flag: LSB first
932 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
934 static PROGMEM IRMP_PARAMETER rc6_param
=
936 IRMP_RC6_PROTOCOL
, // protocol: ir protocol
937 RC6_BIT_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
938 RC6_BIT_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
939 RC6_BIT_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
940 RC6_BIT_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
941 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0
942 1, // pulse_0_len_max: maximum length of pulse with bit value 0
943 1, // pause_0_len_min: minimum length of pause with bit value 0
944 1, // pause_0_len_max: maximum length of pause with bit value 0
945 RC6_ADDRESS_OFFSET
, // address_offset: address offset
946 RC6_ADDRESS_OFFSET
+ RC6_ADDRESS_LEN
, // address_end: end of address
947 RC6_COMMAND_OFFSET
, // command_offset: command offset
948 RC6_COMMAND_OFFSET
+ RC6_COMMAND_LEN
, // command_end: end of command
949 RC6_COMPLETE_DATA_LEN_SHORT
, // complete_len: complete length of frame
950 RC6_STOP_BIT
, // stop_bit: flag: frame has stop bit
951 RC6_LSB
// lsb_first: flag: LSB first
956 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
958 static PROGMEM IRMP_PARAMETER recs80ext_param
=
960 IRMP_RECS80EXT_PROTOCOL
, // protocol: ir protocol
961 RECS80EXT_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
962 RECS80EXT_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
963 RECS80EXT_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
964 RECS80EXT_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
965 RECS80EXT_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
966 RECS80EXT_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
967 RECS80EXT_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
968 RECS80EXT_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
969 RECS80EXT_ADDRESS_OFFSET
, // address_offset: address offset
970 RECS80EXT_ADDRESS_OFFSET
+ RECS80EXT_ADDRESS_LEN
, // address_end: end of address
971 RECS80EXT_COMMAND_OFFSET
, // command_offset: command offset
972 RECS80EXT_COMMAND_OFFSET
+ RECS80EXT_COMMAND_LEN
, // command_end: end of command
973 RECS80EXT_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
974 RECS80EXT_STOP_BIT
, // stop_bit: flag: frame has stop bit
975 RECS80EXT_LSB
// lsb_first: flag: LSB first
980 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
982 static PROGMEM IRMP_PARAMETER nubert_param
=
984 IRMP_NUBERT_PROTOCOL
, // protocol: ir protocol
985 NUBERT_1_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
986 NUBERT_1_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
987 NUBERT_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
988 NUBERT_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
989 NUBERT_0_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
990 NUBERT_0_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
991 NUBERT_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
992 NUBERT_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
993 NUBERT_ADDRESS_OFFSET
, // address_offset: address offset
994 NUBERT_ADDRESS_OFFSET
+ NUBERT_ADDRESS_LEN
, // address_end: end of address
995 NUBERT_COMMAND_OFFSET
, // command_offset: command offset
996 NUBERT_COMMAND_OFFSET
+ NUBERT_COMMAND_LEN
, // command_end: end of command
997 NUBERT_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
998 NUBERT_STOP_BIT
, // stop_bit: flag: frame has stop bit
999 NUBERT_LSB
// lsb_first: flag: LSB first
1004 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1006 static PROGMEM IRMP_PARAMETER bang_olufsen_param
=
1008 IRMP_BANG_OLUFSEN_PROTOCOL
, // protocol: ir protocol
1009 BANG_OLUFSEN_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1010 BANG_OLUFSEN_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1011 BANG_OLUFSEN_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1012 BANG_OLUFSEN_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1013 BANG_OLUFSEN_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
1014 BANG_OLUFSEN_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
1015 BANG_OLUFSEN_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
1016 BANG_OLUFSEN_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
1017 BANG_OLUFSEN_ADDRESS_OFFSET
, // address_offset: address offset
1018 BANG_OLUFSEN_ADDRESS_OFFSET
+ BANG_OLUFSEN_ADDRESS_LEN
, // address_end: end of address
1019 BANG_OLUFSEN_COMMAND_OFFSET
, // command_offset: command offset
1020 BANG_OLUFSEN_COMMAND_OFFSET
+ BANG_OLUFSEN_COMMAND_LEN
, // command_end: end of command
1021 BANG_OLUFSEN_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
1022 BANG_OLUFSEN_STOP_BIT
, // stop_bit: flag: frame has stop bit
1023 BANG_OLUFSEN_LSB
// lsb_first: flag: LSB first
1028 #if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1030 static PROGMEM IRMP_PARAMETER grundig_param
=
1032 IRMP_GRUNDIG_PROTOCOL
, // protocol: ir protocol
1033 GRUNDIG_OR_NOKIA_BIT_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1034 GRUNDIG_OR_NOKIA_BIT_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1035 GRUNDIG_OR_NOKIA_BIT_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1036 GRUNDIG_OR_NOKIA_BIT_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1037 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0
1038 1, // pulse_0_len_max: maximum length of pulse with bit value 0
1039 1, // pause_0_len_min: minimum length of pause with bit value 0
1040 1, // pause_0_len_max: maximum length of pause with bit value 0
1041 GRUNDIG_ADDRESS_OFFSET
, // address_offset: address offset
1042 GRUNDIG_ADDRESS_OFFSET
+ GRUNDIG_ADDRESS_LEN
, // address_end: end of address
1043 GRUNDIG_COMMAND_OFFSET
, // command_offset: command offset
1044 GRUNDIG_COMMAND_OFFSET
+ GRUNDIG_COMMAND_LEN
+ 1, // command_end: end of command (USE 1 bit MORE to STORE NOKIA DATA!)
1045 NOKIA_COMPLETE_DATA_LEN
, // complete_len: complete length of frame, here: NOKIA instead of GRUNDIG!
1046 GRUNDIG_OR_NOKIA_STOP_BIT
, // stop_bit: flag: frame has stop bit
1047 GRUNDIG_OR_NOKIA_LSB
// lsb_first: flag: LSB first
1052 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1054 static PROGMEM IRMP_PARAMETER siemens_param
=
1056 IRMP_SIEMENS_PROTOCOL
, // protocol: ir protocol
1057 SIEMENS_BIT_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1058 SIEMENS_BIT_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1059 SIEMENS_BIT_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1060 SIEMENS_BIT_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1061 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0
1062 1, // pulse_0_len_max: maximum length of pulse with bit value 0
1063 1, // pause_0_len_min: minimum length of pause with bit value 0
1064 1, // pause_0_len_max: maximum length of pause with bit value 0
1065 SIEMENS_ADDRESS_OFFSET
, // address_offset: address offset
1066 SIEMENS_ADDRESS_OFFSET
+ SIEMENS_ADDRESS_LEN
, // address_end: end of address
1067 SIEMENS_COMMAND_OFFSET
, // command_offset: command offset
1068 SIEMENS_COMMAND_OFFSET
+ SIEMENS_COMMAND_LEN
, // command_end: end of command
1069 SIEMENS_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
1070 SIEMENS_STOP_BIT
, // stop_bit: flag: frame has stop bit
1071 SIEMENS_LSB
// lsb_first: flag: LSB first
1076 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
1078 static PROGMEM IRMP_PARAMETER fdc_param
=
1080 IRMP_FDC_PROTOCOL
, // protocol: ir protocol
1081 FDC_PULSE_LEN_MIN
, // pulse_1_len_min: minimum length of pulse with bit value 1
1082 FDC_PULSE_LEN_MAX
, // pulse_1_len_max: maximum length of pulse with bit value 1
1083 FDC_1_PAUSE_LEN_MIN
, // pause_1_len_min: minimum length of pause with bit value 1
1084 FDC_1_PAUSE_LEN_MAX
, // pause_1_len_max: maximum length of pause with bit value 1
1085 FDC_PULSE_LEN_MIN
, // pulse_0_len_min: minimum length of pulse with bit value 0
1086 FDC_PULSE_LEN_MAX
, // pulse_0_len_max: maximum length of pulse with bit value 0
1087 FDC_0_PAUSE_LEN_MIN
, // pause_0_len_min: minimum length of pause with bit value 0
1088 FDC_0_PAUSE_LEN_MAX
, // pause_0_len_max: maximum length of pause with bit value 0
1089 FDC_ADDRESS_OFFSET
, // address_offset: address offset
1090 FDC_ADDRESS_OFFSET
+ FDC_ADDRESS_LEN
, // address_end: end of address
1091 FDC_COMMAND_OFFSET
, // command_offset: command offset
1092 FDC_COMMAND_OFFSET
+ FDC_COMMAND_LEN
, // command_end: end of command
1093 FDC_COMPLETE_DATA_LEN
, // complete_len: complete length of frame
1094 FDC_STOP_BIT
, // stop_bit: flag: frame has stop bit
1095 FDC_LSB
// lsb_first: flag: LSB first
1100 static uint8_t irmp_bit
; // current bit position
1101 static IRMP_PARAMETER irmp_param
;
1103 static volatile uint8_t irmp_ir_detected
;
1104 static volatile uint8_t irmp_protocol
;
1105 static volatile uint16_t irmp_address
;
1106 static volatile uint16_t irmp_command
;
1107 static volatile uint16_t irmp_id
; // only used for SAMSUNG protocol
1108 static volatile uint8_t irmp_flags
;
1111 static uint8_t IRMP_PIN
;
1114 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1115 * Initialize IRMP decoder
1116 * @details Configures IRMP input pin
1117 *---------------------------------------------------------------------------------------------------------------------------------------------------
1123 #ifndef PIC_CCS_COMPILER
1124 IRMP_PORT
&= ~(1<<IRMP_BIT
); // deactivate pullup
1125 IRMP_DDR
&= ~(1<<IRMP_BIT
); // set pin to input
1126 #endif // PIC_CCS_COMPILER
1128 #if IRMP_LOGGING == 1
1133 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1135 * @details gets decoded IRMP data
1136 * @param pointer in order to store IRMP data
1137 * @return TRUE: successful, FALSE: failed
1138 *---------------------------------------------------------------------------------------------------------------------------------------------------
1141 irmp_get_data (IRMP_DATA
* irmp_data_p
)
1143 uint8_t rtc
= FALSE
;
1145 if (irmp_ir_detected
)
1147 switch (irmp_protocol
)
1149 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1150 case IRMP_SAMSUNG_PROTOCOL
:
1151 if ((irmp_command
>> 8) == (~irmp_command
& 0x00FF))
1153 irmp_command
&= 0xff;
1154 irmp_command
|= irmp_id
<< 8;
1159 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
1160 case IRMP_NEC_PROTOCOL
:
1161 if ((irmp_command
>> 8) == (~irmp_command
& 0x00FF))
1163 irmp_command
&= 0xff;
1166 else if ((irmp_command
& 0xFF00) == 0xD100)
1168 DEBUG_PRINTF ("Switching to APPLE protocol\n");
1169 irmp_protocol
= IRMP_APPLE_PROTOCOL
;
1170 irmp_command
&= 0xff;
1181 irmp_data_p
->protocol
= irmp_protocol
;
1182 irmp_data_p
->address
= irmp_address
;
1183 irmp_data_p
->command
= irmp_command
;
1184 irmp_data_p
->flags
= irmp_flags
;
1190 irmp_ir_detected
= FALSE
;
1196 // these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR()
1197 static uint16_t irmp_tmp_address
; // ir address
1198 static uint16_t irmp_tmp_command
; // ir command
1199 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1200 static uint16_t irmp_tmp_id
; // ir id (only SAMSUNG)
1203 static uint8_t irmp_bit
; // current bit position
1205 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1207 * @details store bit in temp address or temp command
1208 * @param value to store: 0 or 1
1209 *---------------------------------------------------------------------------------------------------------------------------------------------------
1212 irmp_store_bit (uint8_t value
)
1214 if (irmp_bit
>= irmp_param
.address_offset
&& irmp_bit
< irmp_param
.address_end
)
1216 if (irmp_param
.lsb_first
)
1218 irmp_tmp_address
|= (((uint16_t) (value
)) << (irmp_bit
- irmp_param
.address_offset
)); // CV wants cast
1222 irmp_tmp_address
<<= 1;
1223 irmp_tmp_address
|= value
;
1226 else if (irmp_bit
>= irmp_param
.command_offset
&& irmp_bit
< irmp_param
.command_end
)
1228 if (irmp_param
.lsb_first
)
1230 irmp_tmp_command
|= (((uint16_t) (value
)) << (irmp_bit
- irmp_param
.command_offset
)); // CV wants cast
1234 irmp_tmp_command
<<= 1;
1235 irmp_tmp_command
|= value
;
1238 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1239 else if (irmp_param
.protocol
== IRMP_SAMSUNG_PROTOCOL
&& irmp_bit
>= SAMSUNG_ID_OFFSET
&& irmp_bit
< SAMSUNG_ID_OFFSET
+ SAMSUNG_ID_LEN
)
1241 irmp_tmp_id
|= (((uint16_t) (value
)) << (irmp_bit
- SAMSUNG_ID_OFFSET
)); // store with LSB first
1247 /*---------------------------------------------------------------------------------------------------------------------------------------------------
1249 * @details ISR routine, called 10000 times per second
1250 *---------------------------------------------------------------------------------------------------------------------------------------------------
1255 static uint8_t irmp_start_bit_detected
; // flag: start bit detected
1256 static uint8_t wait_for_space
; // flag: wait for data bit space
1257 static uint8_t wait_for_start_space
; // flag: wait for start bit space
1258 static uint8_t irmp_pulse_time
; // count bit time for pulse
1259 static uint8_t irmp_pause_time
; // count bit time for pause
1260 static uint16_t last_irmp_address
= 0xFFFF; // save last irmp address to recognize key repetition
1261 static uint16_t last_irmp_command
= 0xFFFF; // save last irmp command to recognize key repetition
1262 static uint16_t repetition_counter
; // SIRCS repeats frame 2-5 times with 45 ms pause
1263 static uint8_t repetition_frame_number
;
1264 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1265 static uint16_t last_irmp_denon_command
; // save last irmp command to recognize DENON frame repetition
1267 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1268 static uint8_t rc5_cmd_bit6
; // bit 6 of RC5 command is the inverted 2nd start bit
1270 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_RC6_PROTOCOL == 1 || IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1271 static uint8_t last_pause
; // last pause value
1273 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_RC6_PROTOCOL == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || \
1274 IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1 || IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1275 static uint8_t last_value
; // last bit value
1277 uint8_t irmp_input
; // input value
1283 irmp_input
= input(IRMP_PIN
);
1285 irmp_log(irmp_input
); // log ir signal, if IRMP_LOGGING defined
1287 if (! irmp_ir_detected
) // ir code already detected?
1289 if (! irmp_start_bit_detected
) // start bit detected?
1291 if (! irmp_input
) // receiving burst?
1294 if (! irmp_pulse_time
)
1296 DEBUG_PRINTF("%8d [starting pulse]\n", time_counter
);
1299 irmp_pulse_time
++; // increment counter
1303 if (irmp_pulse_time
) // it's dark....
1304 { // set flags for counting the time of darkness...
1305 irmp_start_bit_detected
= 1;
1306 wait_for_start_space
= 1;
1308 irmp_tmp_command
= 0;
1309 irmp_tmp_address
= 0;
1311 irmp_pause_time
= 1; // 1st pause: set to 1, not to 0!
1312 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1313 rc5_cmd_bit6
= 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame!
1318 repetition_counter
++;
1324 if (wait_for_start_space
) // we have received start bit...
1325 { // ...and are counting the time of darkness
1326 if (irmp_input
) // still dark?
1328 irmp_pause_time
++; // increment counter
1330 if (irmp_pause_time
> IRMP_TIMEOUT_LEN
) // timeout?
1332 DEBUG_PRINTF ("error 1: pause after start bit pulse %d too long: %d\n", irmp_pulse_time
, irmp_pause_time
);
1333 DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
1334 irmp_start_bit_detected
= 0; // reset flags, let's wait for another start bit
1335 irmp_pulse_time
= 0;
1336 irmp_pause_time
= 0;
1340 { // receiving first data pulse!
1341 IRMP_PARAMETER
* irmp_param_p
= (IRMP_PARAMETER
*) 0;
1343 DEBUG_PRINTF ("start-bit: pulse = %d, pause = %d\n", irmp_pulse_time
, irmp_pause_time
);
1345 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1346 if (irmp_pulse_time
>= SIRCS_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= SIRCS_START_BIT_PULSE_LEN_MAX
&&
1347 irmp_pause_time
>= SIRCS_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= SIRCS_START_BIT_PAUSE_LEN_MAX
)
1349 DEBUG_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1350 SIRCS_START_BIT_PULSE_LEN_MIN
, SIRCS_START_BIT_PULSE_LEN_MAX
,
1351 SIRCS_START_BIT_PAUSE_LEN_MIN
, SIRCS_START_BIT_PAUSE_LEN_MAX
);
1352 irmp_param_p
= (IRMP_PARAMETER
*) (IRMP_PARAMETER
*) &sircs_param
;
1355 #endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1357 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
1358 if (irmp_pulse_time
>= NEC_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= NEC_START_BIT_PULSE_LEN_MAX
&&
1359 irmp_pause_time
>= NEC_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= NEC_START_BIT_PAUSE_LEN_MAX
)
1361 DEBUG_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1362 NEC_START_BIT_PULSE_LEN_MIN
, NEC_START_BIT_PULSE_LEN_MAX
,
1363 NEC_START_BIT_PAUSE_LEN_MIN
, NEC_START_BIT_PAUSE_LEN_MAX
);
1364 irmp_param_p
= (IRMP_PARAMETER
*) &nec_param
;
1366 else if (irmp_pulse_time
>= NEC_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= NEC_START_BIT_PULSE_LEN_MAX
&&
1367 irmp_pause_time
>= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX
)
1369 DEBUG_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1370 NEC_START_BIT_PULSE_LEN_MIN
, NEC_START_BIT_PULSE_LEN_MAX
,
1371 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN
, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX
);
1373 irmp_param_p
= (IRMP_PARAMETER
*) &nec_rep_param
;
1376 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
1378 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1379 if (irmp_pulse_time
>= SAMSUNG_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= SAMSUNG_START_BIT_PULSE_LEN_MAX
&&
1380 irmp_pause_time
>= SAMSUNG_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= SAMSUNG_START_BIT_PAUSE_LEN_MAX
)
1382 DEBUG_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1383 SAMSUNG_START_BIT_PULSE_LEN_MIN
, SAMSUNG_START_BIT_PULSE_LEN_MAX
,
1384 SAMSUNG_START_BIT_PAUSE_LEN_MIN
, SAMSUNG_START_BIT_PAUSE_LEN_MAX
);
1385 irmp_param_p
= (IRMP_PARAMETER
*) &samsung_param
;
1388 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
1390 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
1391 if (irmp_pulse_time
>= MATSUSHITA_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= MATSUSHITA_START_BIT_PULSE_LEN_MAX
&&
1392 irmp_pause_time
>= MATSUSHITA_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= MATSUSHITA_START_BIT_PAUSE_LEN_MAX
)
1393 { // it's MATSUSHITA
1394 DEBUG_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1395 MATSUSHITA_START_BIT_PULSE_LEN_MIN
, MATSUSHITA_START_BIT_PULSE_LEN_MAX
,
1396 MATSUSHITA_START_BIT_PAUSE_LEN_MIN
, MATSUSHITA_START_BIT_PAUSE_LEN_MAX
);
1397 irmp_param_p
= (IRMP_PARAMETER
*) &matsushita_param
;
1400 #endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
1402 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1403 if (irmp_pulse_time
>= KASEIKYO_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= KASEIKYO_START_BIT_PULSE_LEN_MAX
&&
1404 irmp_pause_time
>= KASEIKYO_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= KASEIKYO_START_BIT_PAUSE_LEN_MAX
)
1406 DEBUG_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1407 KASEIKYO_START_BIT_PULSE_LEN_MIN
, KASEIKYO_START_BIT_PULSE_LEN_MAX
,
1408 KASEIKYO_START_BIT_PAUSE_LEN_MIN
, KASEIKYO_START_BIT_PAUSE_LEN_MAX
);
1409 irmp_param_p
= (IRMP_PARAMETER
*) &kaseikyo_param
;
1412 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
1414 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
1415 if (irmp_pulse_time
>= RECS80_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RECS80_START_BIT_PULSE_LEN_MAX
&&
1416 irmp_pause_time
>= RECS80_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RECS80_START_BIT_PAUSE_LEN_MAX
)
1418 DEBUG_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1419 RECS80_START_BIT_PULSE_LEN_MIN
, RECS80_START_BIT_PULSE_LEN_MAX
,
1420 RECS80_START_BIT_PAUSE_LEN_MIN
, RECS80_START_BIT_PAUSE_LEN_MAX
);
1421 irmp_param_p
= (IRMP_PARAMETER
*) &recs80_param
;
1424 #endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1
1426 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1427 if (((irmp_pulse_time
>= RC5_START_BIT_LEN_MIN
&& irmp_pulse_time
<= RC5_START_BIT_LEN_MAX
) ||
1428 (irmp_pulse_time
>= 2 * RC5_START_BIT_LEN_MIN
&& irmp_pulse_time
<= 2 * RC5_START_BIT_LEN_MAX
)) &&
1429 ((irmp_pause_time
>= RC5_START_BIT_LEN_MIN
&& irmp_pause_time
<= RC5_START_BIT_LEN_MAX
) ||
1430 (irmp_pause_time
>= 2 * RC5_START_BIT_LEN_MIN
&& irmp_pause_time
<= 2 * RC5_START_BIT_LEN_MAX
)))
1432 DEBUG_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1433 RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
,
1434 RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
);
1435 irmp_param_p
= (IRMP_PARAMETER
*) &rc5_param
;
1436 last_pause
= irmp_pause_time
;
1438 if ((irmp_pulse_time
> RC5_START_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * RC5_START_BIT_LEN_MAX
) ||
1439 (irmp_pause_time
> RC5_START_BIT_LEN_MAX
&& irmp_pause_time
<= 2 * RC5_START_BIT_LEN_MAX
))
1442 rc5_cmd_bit6
= 1<<6;
1450 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1
1452 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1453 if ( (irmp_pulse_time
>= DENON_PULSE_LEN_MIN
&& irmp_pulse_time
<= DENON_PULSE_LEN_MAX
) &&
1454 ((irmp_pause_time
>= DENON_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= DENON_1_PAUSE_LEN_MAX
) ||
1455 (irmp_pause_time
>= DENON_0_PAUSE_LEN_MIN
&& irmp_pause_time
<= DENON_0_PAUSE_LEN_MAX
)))
1457 DEBUG_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
1458 DENON_PULSE_LEN_MIN
, DENON_PULSE_LEN_MAX
,
1459 DENON_1_PAUSE_LEN_MIN
, DENON_1_PAUSE_LEN_MAX
,
1460 DENON_0_PAUSE_LEN_MIN
, DENON_0_PAUSE_LEN_MAX
);
1461 irmp_param_p
= (IRMP_PARAMETER
*) &denon_param
;
1464 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
1466 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1467 if (irmp_pulse_time
>= RC6_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RC6_START_BIT_PULSE_LEN_MAX
&&
1468 irmp_pause_time
>= RC6_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RC6_START_BIT_PAUSE_LEN_MAX
)
1470 DEBUG_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1471 RC6_START_BIT_PULSE_LEN_MIN
, RC6_START_BIT_PULSE_LEN_MAX
,
1472 RC6_START_BIT_PAUSE_LEN_MIN
, RC6_START_BIT_PAUSE_LEN_MAX
);
1473 irmp_param_p
= (IRMP_PARAMETER
*) &rc6_param
;
1478 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
1480 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
1481 if (irmp_pulse_time
>= RECS80EXT_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= RECS80EXT_START_BIT_PULSE_LEN_MAX
&&
1482 irmp_pause_time
>= RECS80EXT_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= RECS80EXT_START_BIT_PAUSE_LEN_MAX
)
1484 DEBUG_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1485 RECS80EXT_START_BIT_PULSE_LEN_MIN
, RECS80EXT_START_BIT_PULSE_LEN_MAX
,
1486 RECS80EXT_START_BIT_PAUSE_LEN_MIN
, RECS80EXT_START_BIT_PAUSE_LEN_MAX
);
1487 irmp_param_p
= (IRMP_PARAMETER
*) &recs80ext_param
;
1490 #endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
1492 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1493 if (irmp_pulse_time
>= NUBERT_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= NUBERT_START_BIT_PULSE_LEN_MAX
&&
1494 irmp_pause_time
>= NUBERT_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= NUBERT_START_BIT_PAUSE_LEN_MAX
)
1496 DEBUG_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1497 NUBERT_START_BIT_PULSE_LEN_MIN
, NUBERT_START_BIT_PULSE_LEN_MAX
,
1498 NUBERT_START_BIT_PAUSE_LEN_MIN
, NUBERT_START_BIT_PAUSE_LEN_MAX
);
1499 irmp_param_p
= (IRMP_PARAMETER
*) &nubert_param
;
1502 #endif // IRMP_SUPPORT_NUBERT_PROTOCOL == 1
1504 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1505 if (irmp_pulse_time
>= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN
&& irmp_pulse_time
<= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX
&&
1506 irmp_pause_time
>= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX
)
1507 { // it's BANG_OLUFSEN
1508 DEBUG_PRINTF ("protocol = BANG_OLUFSEN\n");
1509 DEBUG_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1510 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX
,
1511 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX
);
1512 DEBUG_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1513 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX
,
1514 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX
);
1515 DEBUG_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1516 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX
,
1517 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX
);
1518 DEBUG_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1519 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX
,
1520 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN
, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX
);
1521 irmp_param_p
= (IRMP_PARAMETER
*) &bang_olufsen_param
;
1525 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1527 #if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1528 if (irmp_pulse_time
>= GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN
&& irmp_pulse_time
<= GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX
&&
1529 irmp_pause_time
>= GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN
&& irmp_pause_time
<= GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX
)
1531 DEBUG_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1532 GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN
, GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX
,
1533 GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN
, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX
);
1534 irmp_param_p
= (IRMP_PARAMETER
*) &grundig_param
;
1535 last_pause
= irmp_pause_time
;
1539 #endif // IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1541 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1542 if (((irmp_pulse_time
>= SIEMENS_START_BIT_LEN_MIN
&& irmp_pulse_time
<= SIEMENS_START_BIT_LEN_MAX
) ||
1543 (irmp_pulse_time
>= 2 * SIEMENS_START_BIT_LEN_MIN
&& irmp_pulse_time
<= 2 * SIEMENS_START_BIT_LEN_MAX
)) &&
1544 ((irmp_pause_time
>= SIEMENS_START_BIT_LEN_MIN
&& irmp_pause_time
<= SIEMENS_START_BIT_LEN_MAX
) ||
1545 (irmp_pause_time
>= 2 * SIEMENS_START_BIT_LEN_MIN
&& irmp_pause_time
<= 2 * SIEMENS_START_BIT_LEN_MAX
)))
1547 DEBUG_PRINTF ("protocol = SIEMENS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1548 SIEMENS_START_BIT_LEN_MIN
, SIEMENS_START_BIT_LEN_MAX
,
1549 SIEMENS_START_BIT_LEN_MIN
, SIEMENS_START_BIT_LEN_MAX
);
1550 irmp_param_p
= (IRMP_PARAMETER
*) &siemens_param
;
1551 last_pause
= irmp_pause_time
;
1555 #endif // IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1556 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
1557 if (irmp_pulse_time
>= FDC_START_BIT_PULSE_LEN_MIN
&& irmp_pulse_time
<= FDC_START_BIT_PULSE_LEN_MAX
&&
1558 irmp_pause_time
>= FDC_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= FDC_START_BIT_PAUSE_LEN_MAX
)
1560 DEBUG_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
1561 FDC_START_BIT_PULSE_LEN_MIN
, FDC_START_BIT_PULSE_LEN_MAX
,
1562 FDC_START_BIT_PAUSE_LEN_MIN
, FDC_START_BIT_PAUSE_LEN_MAX
);
1563 irmp_param_p
= (IRMP_PARAMETER
*) &fdc_param
;
1566 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
1569 DEBUG_PRINTF ("protocol = UNKNOWN\n");
1570 irmp_start_bit_detected
= 0; // wait for another start bit...
1573 if (irmp_start_bit_detected
)
1575 memcpy_P (&irmp_param
, irmp_param_p
, sizeof (IRMP_PARAMETER
));
1577 DEBUG_PRINTF ("pulse_1: %3d - %3d\n", irmp_param
.pulse_1_len_min
, irmp_param
.pulse_1_len_max
);
1578 DEBUG_PRINTF ("pause_1: %3d - %3d\n", irmp_param
.pause_1_len_min
, irmp_param
.pause_1_len_max
);
1580 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1581 if (irmp_param
.protocol
== IRMP_RC6_PROTOCOL
)
1583 DEBUG_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN
, RC6_TOGGLE_BIT_LEN_MAX
);
1586 DEBUG_PRINTF ("pulse_0: %3d - %3d\n", irmp_param
.pulse_0_len_min
, irmp_param
.pulse_0_len_max
);
1587 DEBUG_PRINTF ("pause_0: %3d - %3d\n", irmp_param
.pause_0_len_min
, irmp_param
.pause_0_len_max
);
1589 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
1590 if (irmp_param
.protocol
== IRMP_BANG_OLUFSEN_PROTOCOL
)
1592 DEBUG_PRINTF ("pulse_r: %3d - %3d\n", irmp_param
.pulse_0_len_min
, irmp_param
.pulse_0_len_max
);
1593 DEBUG_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN
, BANG_OLUFSEN_R_PAUSE_LEN_MAX
);
1597 DEBUG_PRINTF ("command_offset: %2d\n", irmp_param
.command_offset
);
1598 DEBUG_PRINTF ("command_len: %3d\n", irmp_param
.command_end
- irmp_param
.command_offset
);
1599 DEBUG_PRINTF ("complete_len: %3d\n", irmp_param
.complete_len
);
1600 DEBUG_PRINTF ("stop_bit: %3d\n", irmp_param
.stop_bit
);
1605 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1606 if (irmp_param
.protocol
== IRMP_RC5_PROTOCOL
)
1608 if (irmp_pause_time
> RC5_START_BIT_LEN_MAX
&& irmp_pause_time
<= 2 * RC5_START_BIT_LEN_MAX
)
1610 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1611 DEBUG_PUTCHAR ('1');
1615 else if (! last_value
)
1617 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1618 DEBUG_PUTCHAR ('0');
1624 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1
1626 #if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1627 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
|| irmp_param
.protocol
== IRMP_NOKIA_PROTOCOL
)
1629 if (irmp_pause_time
> GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX
&& irmp_pause_time
<= 2 * GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX
)
1631 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1632 DEBUG_PUTCHAR ('0');
1636 else if (! last_value
)
1638 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1639 DEBUG_PUTCHAR ('1');
1645 #endif // IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1647 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1648 if (irmp_param
.protocol
== IRMP_SIEMENS_PROTOCOL
)
1650 if (irmp_pause_time
> SIEMENS_START_BIT_LEN_MAX
&& irmp_pause_time
<= 2 * SIEMENS_START_BIT_LEN_MAX
)
1652 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1653 DEBUG_PUTCHAR ('0');
1657 else if (! last_value
)
1659 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1660 DEBUG_PUTCHAR ('1');
1666 #endif // IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1668 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
1669 if (irmp_param
.protocol
== IRMP_DENON_PROTOCOL
)
1671 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1673 if (irmp_pause_time
>= DENON_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= DENON_1_PAUSE_LEN_MAX
)
1674 { // pause timings correct for "1"?
1675 DEBUG_PUTCHAR ('1'); // yes, store 1
1679 else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)
1680 { // pause timings correct for "0"?
1681 DEBUG_PUTCHAR ('0'); // yes, store 0
1686 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
1688 irmp_pulse_time
= 1; // set counter to 1, not 0
1689 irmp_pause_time
= 0;
1690 wait_for_start_space
= 0;
1693 else if (wait_for_space
) // the data section....
1694 { // counting the time of darkness....
1695 uint8_t got_light
= FALSE
;
1697 if (irmp_input
) // still dark?
1699 if (irmp_bit
== irmp_param
.complete_len
&& irmp_param
.stop_bit
== 1)
1701 if (irmp_pulse_time
>= irmp_param
.pulse_0_len_min
&& irmp_pulse_time
<= irmp_param
.pulse_0_len_max
)
1704 if (irmp_param
.protocol
!= IRMP_RC5_PROTOCOL
&&
1705 irmp_param
.protocol
!= IRMP_RC6_PROTOCOL
&&
1706 irmp_param
.protocol
!= IRMP_GRUNDIG_PROTOCOL
&&
1707 irmp_param
.protocol
!= IRMP_NOKIA_PROTOCOL
&&
1708 irmp_param
.protocol
!= IRMP_SIEMENS_PROTOCOL
)
1710 DEBUG_PRINTF ("stop bit detected\n");
1713 irmp_param
.stop_bit
= 0;
1717 DEBUG_PRINTF ("stop bit timing wrong\n");
1719 irmp_start_bit_detected
= 0; // wait for another start bit...
1720 irmp_pulse_time
= 0;
1721 irmp_pause_time
= 0;
1726 irmp_pause_time
++; // increment counter
1728 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
1729 if (irmp_param
.protocol
== IRMP_SIRCS_PROTOCOL
&& // Sony has a variable number of bits:
1730 irmp_pause_time
> SIRCS_PAUSE_LEN_MAX
&& // minimum is 12
1731 irmp_bit
>= 12 - 1) // pause too long?
1732 { // yes, break and close this frame
1733 irmp_param
.complete_len
= irmp_bit
+ 1; // set new complete length
1734 got_light
= TRUE
; // this is a lie, but helps (generates stop bit)
1735 irmp_param
.command_end
= irmp_param
.command_offset
+ irmp_bit
+ 1; // correct command length
1736 irmp_pause_time
= SIRCS_PAUSE_LEN_MAX
- 1; // correct pause length
1740 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1741 if (irmp_param
.protocol
== IRMP_RC5_PROTOCOL
&&
1742 irmp_pause_time
> 2 * RC5_BIT_LEN_MAX
&& irmp_bit
>= RC5_COMPLETE_DATA_LEN
- 2 && !irmp_param
.stop_bit
)
1743 { // special rc5 decoder
1744 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1745 irmp_param
.stop_bit
= TRUE
; // set flag
1749 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1750 if (irmp_param
.protocol
== IRMP_RC6_PROTOCOL
&&
1751 irmp_pause_time
> 2 * RC6_BIT_LEN_MAX
&& irmp_bit
>= irmp_param
.complete_len
- 2 && !irmp_param
.stop_bit
)
1752 { // special rc6 decoder
1753 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1754 irmp_param
.stop_bit
= TRUE
; // set flag
1758 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
1759 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
&&
1760 irmp_pause_time
> 2 * GRUNDIG_OR_NOKIA_BIT_LEN_MAX
&& irmp_bit
>= GRUNDIG_COMPLETE_DATA_LEN
- 2 && !irmp_param
.stop_bit
)
1761 { // special Grundig/Nokia decoder
1762 irmp_param
.complete_len
= GRUNDIG_COMPLETE_DATA_LEN
; // correct complete len
1763 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1764 irmp_param
.stop_bit
= TRUE
; // set flag
1768 #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1
1769 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
&&
1770 irmp_bit
>= GRUNDIG_COMPLETE_DATA_LEN
)
1772 DEBUG_PRINTF ("Switching to NOKIA protocol\n");
1773 irmp_param
.protocol
= IRMP_NOKIA_PROTOCOL
; // change protocol
1774 irmp_param
.address_offset
= NOKIA_ADDRESS_OFFSET
;
1775 irmp_param
.address_end
= NOKIA_ADDRESS_OFFSET
+ NOKIA_ADDRESS_LEN
;
1776 irmp_param
.command_offset
= NOKIA_COMMAND_OFFSET
;
1777 irmp_param
.command_end
= NOKIA_COMMAND_OFFSET
+ NOKIA_COMMAND_LEN
;
1779 if (irmp_tmp_command
& 0x300)
1781 irmp_tmp_address
= (irmp_tmp_command
>> 8);
1782 irmp_tmp_command
&= 0xFF;
1787 #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1
1788 if (irmp_param
.protocol
== IRMP_NOKIA_PROTOCOL
&&
1789 irmp_pause_time
> 2 * GRUNDIG_OR_NOKIA_BIT_LEN_MAX
&& irmp_bit
>= NOKIA_COMPLETE_DATA_LEN
- 2 && !irmp_param
.stop_bit
)
1790 { // special Grundig/Nokia decoder
1791 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1792 irmp_param
.stop_bit
= TRUE
; // set flag
1796 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1797 if (irmp_param
.protocol
== IRMP_SIEMENS_PROTOCOL
&&
1798 irmp_pause_time
> 2 * SIEMENS_BIT_LEN_MAX
&& irmp_bit
>= SIEMENS_COMPLETE_DATA_LEN
- 2 && !irmp_param
.stop_bit
)
1799 { // special rc5 decoder
1800 got_light
= TRUE
; // this is a lie, but generates a stop bit ;-)
1801 irmp_param
.stop_bit
= TRUE
; // set flag
1805 if (irmp_pause_time
> IRMP_TIMEOUT_LEN
) // timeout?
1807 if (irmp_bit
== irmp_param
.complete_len
- 1 && irmp_param
.stop_bit
== 0)
1813 DEBUG_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time
, irmp_bit
);
1814 DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
1816 irmp_start_bit_detected
= 0; // wait for another start bit...
1817 irmp_pulse_time
= 0;
1818 irmp_pause_time
= 0;
1830 DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter
, irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
1832 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
1833 if (irmp_param
.protocol
== IRMP_RC5_PROTOCOL
) // special rc5 decoder
1835 if (irmp_pulse_time
> RC5_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * RC5_BIT_LEN_MAX
)
1837 DEBUG_PUTCHAR ('1');
1839 DEBUG_PUTCHAR ('0');
1845 else // if (irmp_pulse_time >= RC5_BIT_LEN_MIN && irmp_pulse_time <= RC5_BIT_LEN_MAX)
1849 if (last_pause
> RC5_BIT_LEN_MAX
&& last_pause
<= 2 * RC5_BIT_LEN_MAX
)
1851 rc5_value
= last_value
? 0 : 1;
1852 last_value
= rc5_value
;
1856 rc5_value
= last_value
;
1859 DEBUG_PUTCHAR (rc5_value
+ '0');
1861 irmp_store_bit (rc5_value
);
1864 last_pause
= irmp_pause_time
;
1870 #if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1
1871 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
|| // special Grundig decoder
1872 irmp_param
.protocol
== IRMP_NOKIA_PROTOCOL
) // special Nokia decoder
1874 if (irmp_pulse_time
> GRUNDIG_OR_NOKIA_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * GRUNDIG_OR_NOKIA_BIT_LEN_MAX
)
1876 DEBUG_PUTCHAR ('0');
1878 DEBUG_PUTCHAR ('1');
1884 else // if (irmp_pulse_time >= GRUNDIG_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_OR_NOKIA_BIT_LEN_MAX)
1886 uint8_t grundig_value
;
1888 if (last_pause
> GRUNDIG_OR_NOKIA_BIT_LEN_MAX
&& last_pause
<= 2 * GRUNDIG_OR_NOKIA_BIT_LEN_MAX
)
1890 grundig_value
= last_value
? 0 : 1;
1891 last_value
= grundig_value
;
1895 grundig_value
= last_value
;
1898 DEBUG_PUTCHAR (grundig_value
+ '0');
1900 irmp_store_bit (grundig_value
);
1903 last_pause
= irmp_pause_time
;
1909 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
1910 if (irmp_param
.protocol
== IRMP_RC6_PROTOCOL
) // special rc6 decoder
1913 { // handle toggle bit, which is 2 times longer than other bits
1917 if (irmp_pulse_time
> RC6_TOGGLE_BIT_LEN_MAX
&& irmp_pause_time
> RC6_TOGGLE_BIT_LEN_MAX
)
1919 DEBUG_PUTCHAR ('1');
1923 DEBUG_PUTCHAR ('0');
1930 if (irmp_pulse_time
> RC6_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * RC6_BIT_LEN_MAX
)
1932 DEBUG_PUTCHAR ('0');
1934 DEBUG_PUTCHAR ('1');
1939 else // if (irmp_pulse_time >= RC6_BIT_LEN_MIN && irmp_pulse_time <= RC6_BIT_LEN_MAX)
1943 if (last_pause
> RC6_BIT_LEN_MAX
&& last_pause
<= 2 * RC6_BIT_LEN_MAX
)
1945 rc5_value
= last_value
? 0 : 1;
1946 last_value
= rc5_value
;
1950 rc5_value
= last_value
;
1953 if (irmp_bit
== 1 && rc5_value
== 0)
1955 irmp_param
.complete_len
= RC6_COMPLETE_DATA_LEN_LONG
;
1958 DEBUG_PUTCHAR (rc5_value
+ '0');
1960 irmp_store_bit (rc5_value
);
1963 last_pause
= irmp_pause_time
;
1970 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
1972 #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1
1973 if (irmp_param
.protocol
== IRMP_SIEMENS_PROTOCOL
) // special siemens decoder
1975 if (irmp_pulse_time
> SIEMENS_BIT_LEN_MAX
&& irmp_pulse_time
<= 2 * SIEMENS_BIT_LEN_MAX
)
1977 DEBUG_PUTCHAR ('0');
1979 DEBUG_PUTCHAR ('1');
1985 else // if (irmp_pulse_time >= SIEMENS_BIT_LEN_MIN && irmp_pulse_time <= SIEMENS_BIT_LEN_MAX)
1987 uint8_t siemens_value
;
1989 if (last_pause
> SIEMENS_BIT_LEN_MAX
&& last_pause
<= 2 * SIEMENS_BIT_LEN_MAX
)
1991 siemens_value
= last_value
? 0 : 1;
1992 last_value
= siemens_value
;
1996 siemens_value
= last_value
;
1999 DEBUG_PUTCHAR (siemens_value
+ '0');
2001 irmp_store_bit (siemens_value
);
2004 last_pause
= irmp_pause_time
;
2010 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2011 if (irmp_param
.protocol
== IRMP_SAMSUNG_PROTOCOL
&& irmp_bit
== 16) // Samsung: 16th bit
2013 if (irmp_pulse_time
>= SAMSUNG_PULSE_LEN_MIN
&& irmp_pulse_time
<= SAMSUNG_PULSE_LEN_MAX
&&
2014 irmp_pause_time
>= SAMSUNG_START_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= SAMSUNG_START_BIT_PAUSE_LEN_MAX
)
2016 DEBUG_PRINTF ("SYNC\n");
2021 else if (irmp_pulse_time
>= SAMSUNG_PULSE_LEN_MIN
&& irmp_pulse_time
<= SAMSUNG_PULSE_LEN_MAX
)
2023 irmp_param
.protocol
= IRMP_SAMSUNG32_PROTOCOL
;
2024 irmp_param
.command_offset
= SAMSUNG32_COMMAND_OFFSET
;
2025 irmp_param
.command_end
= SAMSUNG32_COMMAND_OFFSET
+ SAMSUNG32_COMMAND_LEN
;
2026 irmp_param
.complete_len
= SAMSUNG32_COMPLETE_DATA_LEN
;
2028 if (irmp_pause_time
>= SAMSUNG_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= SAMSUNG_1_PAUSE_LEN_MAX
)
2030 DEBUG_PUTCHAR ('1');
2037 DEBUG_PUTCHAR ('0');
2043 DEBUG_PRINTF ("Switching to SAMSUNG32 protocol\n");
2046 { // timing incorrect!
2047 DEBUG_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
2048 DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
2049 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2050 irmp_pause_time
= 0;
2054 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL
2056 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
2057 if (irmp_param
.protocol
== IRMP_BANG_OLUFSEN_PROTOCOL
)
2059 if (irmp_pulse_time
>= BANG_OLUFSEN_PULSE_LEN_MIN
&& irmp_pulse_time
<= BANG_OLUFSEN_PULSE_LEN_MAX
)
2061 if (irmp_bit
== 1) // Bang & Olufsen: 3rd bit
2063 if (irmp_pause_time
>= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX
)
2065 DEBUG_PRINTF ("3rd start bit\n");
2071 { // timing incorrect!
2072 DEBUG_PRINTF ("error 3a B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
2073 DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
2074 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2075 irmp_pause_time
= 0;
2078 else if (irmp_bit
== 19) // Bang & Olufsen: trailer bit
2080 if (irmp_pause_time
>= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX
)
2082 DEBUG_PRINTF ("trailer bit\n");
2088 { // timing incorrect!
2089 DEBUG_PRINTF ("error 3b B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
2090 DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
2091 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2092 irmp_pause_time
= 0;
2097 if (irmp_pause_time
>= BANG_OLUFSEN_1_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_1_PAUSE_LEN_MAX
)
2098 { // pulse & pause timings correct for "1"?
2099 DEBUG_PUTCHAR ('1');
2105 else if (irmp_pause_time
>= BANG_OLUFSEN_0_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_0_PAUSE_LEN_MAX
)
2106 { // pulse & pause timings correct for "0"?
2107 DEBUG_PUTCHAR ('0');
2113 else if (irmp_pause_time
>= BANG_OLUFSEN_R_PAUSE_LEN_MIN
&& irmp_pause_time
<= BANG_OLUFSEN_R_PAUSE_LEN_MAX
)
2115 DEBUG_PUTCHAR (last_value
+ '0');
2117 irmp_store_bit (last_value
);
2121 { // timing incorrect!
2122 DEBUG_PRINTF ("error 3c B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
2123 DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
2124 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2125 irmp_pause_time
= 0;
2130 { // timing incorrect!
2131 DEBUG_PRINTF ("error 3d B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
2132 DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
2133 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2134 irmp_pause_time
= 0;
2138 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL
2140 if (irmp_pulse_time
>= irmp_param
.pulse_1_len_min
&& irmp_pulse_time
<= irmp_param
.pulse_1_len_max
&&
2141 irmp_pause_time
>= irmp_param
.pause_1_len_min
&& irmp_pause_time
<= irmp_param
.pause_1_len_max
)
2142 { // pulse & pause timings correct for "1"?
2143 DEBUG_PUTCHAR ('1');
2148 else if (irmp_pulse_time
>= irmp_param
.pulse_0_len_min
&& irmp_pulse_time
<= irmp_param
.pulse_0_len_max
&&
2149 irmp_pause_time
>= irmp_param
.pause_0_len_min
&& irmp_pause_time
<= irmp_param
.pause_0_len_max
)
2150 { // pulse & pause timings correct for "0"?
2151 DEBUG_PUTCHAR ('0');
2157 { // timing incorrect!
2158 DEBUG_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit
, irmp_pulse_time
, irmp_pause_time
);
2159 DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
2160 irmp_start_bit_detected
= 0; // reset flags and wait for next start bit
2161 irmp_pause_time
= 0;
2164 irmp_pulse_time
= 1; // set counter to 1, not 0
2168 { // counting the pulse length ...
2169 if (! irmp_input
) // still light?
2171 irmp_pulse_time
++; // increment counter
2175 wait_for_space
= 1; // let's count the time (see above)
2176 irmp_pause_time
= 1; // set pause counter to 1, not 0
2180 if (irmp_bit
== irmp_param
.complete_len
&& irmp_param
.stop_bit
== 0) // enough bits received?
2182 if (last_irmp_command
== irmp_tmp_command
&& repetition_counter
< AUTO_FRAME_REPETITION_LEN
)
2184 repetition_frame_number
++;
2188 repetition_frame_number
= 0;
2191 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
2192 // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame
2193 if (irmp_param
.protocol
== IRMP_SIRCS_PROTOCOL
&& (repetition_frame_number
== 1 || repetition_frame_number
== 2))
2195 DEBUG_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
2196 repetition_frame_number
+ 1, repetition_counter
, AUTO_FRAME_REPETITION_LEN
);
2197 repetition_counter
= 0;
2202 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2203 // if SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
2204 if (irmp_param
.protocol
== IRMP_SAMSUNG32_PROTOCOL
&& (repetition_frame_number
& 0x01))
2206 DEBUG_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
2207 repetition_frame_number
+ 1, repetition_counter
, AUTO_FRAME_REPETITION_LEN
);
2208 repetition_counter
= 0;
2213 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
2214 // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
2215 if (irmp_param
.protocol
== IRMP_NUBERT_PROTOCOL
&& (repetition_frame_number
& 0x01))
2217 DEBUG_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
2218 repetition_frame_number
+ 1, repetition_counter
, AUTO_FRAME_REPETITION_LEN
);
2219 repetition_counter
= 0;
2225 DEBUG_PRINTF ("code detected, length = %d\n", irmp_bit
);
2226 irmp_ir_detected
= TRUE
;
2228 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
2229 if (irmp_param
.protocol
== IRMP_DENON_PROTOCOL
)
2230 { // check for repetition frame
2231 if ((~irmp_tmp_command
& 0x3FF) == last_irmp_denon_command
) // command bits must be inverted
2233 irmp_tmp_command
= last_irmp_denon_command
; // use command received before!
2235 irmp_protocol
= irmp_param
.protocol
; // store protocol
2236 irmp_address
= irmp_tmp_address
; // store address
2237 irmp_command
= irmp_tmp_command
; // store command
2241 DEBUG_PRINTF ("waiting for inverted command repetition\n");
2242 irmp_ir_detected
= FALSE
;
2243 last_irmp_denon_command
= irmp_tmp_command
;
2247 #endif // IRMP_SUPPORT_DENON_PROTOCOL
2249 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
2250 if (irmp_param
.protocol
== IRMP_GRUNDIG_PROTOCOL
&& irmp_tmp_command
== 0x01ff)
2251 { // Grundig start frame?
2252 DEBUG_PRINTF ("Detected GRUNDIG start frame, ignoring it\n");
2253 irmp_ir_detected
= FALSE
;
2256 #endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL
2258 #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1
2259 if (irmp_param
.protocol
== IRMP_NOKIA_PROTOCOL
&& irmp_tmp_address
== 0x00ff && irmp_tmp_command
== 0x00fe)
2260 { // Nokia start frame?
2261 DEBUG_PRINTF ("Detected NOKIA start frame, ignoring it\n");
2262 irmp_ir_detected
= FALSE
;
2265 #endif // IRMP_SUPPORT_NOKIA_PROTOCOL
2267 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2268 if (irmp_param
.protocol
== IRMP_NEC_PROTOCOL
&& irmp_bit
== 0) // repetition frame
2270 irmp_tmp_address
= last_irmp_address
; // address is last address
2271 irmp_tmp_command
= last_irmp_command
; // command is last command
2272 irmp_flags
|= IRMP_FLAG_REPETITION
;
2274 #endif // IRMP_SUPPORT_NEC_PROTOCOL
2275 irmp_protocol
= irmp_param
.protocol
;
2276 irmp_address
= irmp_tmp_address
; // store address
2277 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2278 last_irmp_address
= irmp_tmp_address
; // store as last address, too
2281 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
2282 irmp_tmp_command
|= rc5_cmd_bit6
; // store bit 6
2284 irmp_command
= irmp_tmp_command
; // store command
2286 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2287 irmp_id
= irmp_tmp_id
;
2292 if (irmp_ir_detected
)
2294 if (last_irmp_command
== irmp_command
&&
2295 last_irmp_address
== irmp_address
&&
2296 repetition_counter
< IRMP_KEY_REPETITION_LEN
)
2298 irmp_flags
|= IRMP_FLAG_REPETITION
;
2301 last_irmp_address
= irmp_tmp_address
; // store as last address, too
2302 last_irmp_command
= irmp_tmp_command
; // store as last command, too
2304 repetition_counter
= 0;
2308 DEBUG_ONLY_NORMAL_PUTCHAR ('\n');
2311 irmp_start_bit_detected
= 0; // and wait for next start bit
2312 irmp_tmp_command
= 0;
2313 irmp_pulse_time
= 0;
2314 irmp_pause_time
= 0;
2318 return (irmp_ir_detected
);
2323 // main function - for unix/linux + windows only!
2325 // Compile it under linux with:
2326 // cc irmp.c -o irmp
2328 // usage: ./irmp [-v|-s|-a|-p] < file
2331 print_timings (void)
2333 printf ("PROTOCOL START BIT NO. START BIT PULSE START BIT PAUSE\n");
2334 printf ("====================================================================================\n");
2335 printf ("SIRCS 1 %3d - %3d %3d - %3d\n",
2336 SIRCS_START_BIT_PULSE_LEN_MIN
, SIRCS_START_BIT_PULSE_LEN_MAX
, SIRCS_START_BIT_PAUSE_LEN_MIN
, SIRCS_START_BIT_PAUSE_LEN_MAX
);
2337 printf ("NEC 1 %3d - %3d %3d - %3d\n",
2338 NEC_START_BIT_PULSE_LEN_MIN
, NEC_START_BIT_PULSE_LEN_MAX
, NEC_START_BIT_PAUSE_LEN_MIN
, NEC_START_BIT_PAUSE_LEN_MAX
);
2339 printf ("NEC (rep) 1 %3d - %3d %3d - %3d\n",
2340 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
);
2341 printf ("SAMSUNG 1 %3d - %3d %3d - %3d\n",
2342 SAMSUNG_START_BIT_PULSE_LEN_MIN
, SAMSUNG_START_BIT_PULSE_LEN_MAX
, SAMSUNG_START_BIT_PAUSE_LEN_MIN
, SAMSUNG_START_BIT_PAUSE_LEN_MAX
);
2343 printf ("MATSUSHITA 1 %3d - %3d %3d - %3d\n",
2344 MATSUSHITA_START_BIT_PULSE_LEN_MIN
, MATSUSHITA_START_BIT_PULSE_LEN_MAX
, MATSUSHITA_START_BIT_PAUSE_LEN_MIN
, MATSUSHITA_START_BIT_PAUSE_LEN_MAX
);
2345 printf ("KASEIKYO 1 %3d - %3d %3d - %3d\n",
2346 KASEIKYO_START_BIT_PULSE_LEN_MIN
, KASEIKYO_START_BIT_PULSE_LEN_MAX
, KASEIKYO_START_BIT_PAUSE_LEN_MIN
, KASEIKYO_START_BIT_PAUSE_LEN_MAX
);
2347 printf ("RECS80 1 %3d - %3d %3d - %3d\n",
2348 RECS80_START_BIT_PULSE_LEN_MIN
, RECS80_START_BIT_PULSE_LEN_MAX
, RECS80_START_BIT_PAUSE_LEN_MIN
, RECS80_START_BIT_PAUSE_LEN_MAX
);
2349 printf ("RC5 1 %3d - %3d %3d - %3d\n",
2350 RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
, RC5_START_BIT_LEN_MIN
, RC5_START_BIT_LEN_MAX
);
2351 printf ("DENON 1 %3d - %3d %3d - %3d or %3d - %3d\n",
2352 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
);
2353 printf ("RC6 1 %3d - %3d %3d - %3d\n",
2354 RC6_START_BIT_PULSE_LEN_MIN
, RC6_START_BIT_PULSE_LEN_MAX
, RC6_START_BIT_PAUSE_LEN_MIN
, RC6_START_BIT_PAUSE_LEN_MAX
);
2355 printf ("RECS80EXT 1 %3d - %3d %3d - %3d\n",
2356 RECS80EXT_START_BIT_PULSE_LEN_MIN
, RECS80EXT_START_BIT_PULSE_LEN_MAX
, RECS80EXT_START_BIT_PAUSE_LEN_MIN
, RECS80EXT_START_BIT_PAUSE_LEN_MAX
);
2357 printf ("NUBERT 1 %3d - %3d %3d - %3d\n",
2358 NUBERT_START_BIT_PULSE_LEN_MIN
, NUBERT_START_BIT_PULSE_LEN_MAX
, NUBERT_START_BIT_PAUSE_LEN_MIN
, NUBERT_START_BIT_PAUSE_LEN_MAX
);
2359 printf ("BANG_OLUFSEN 1 %3d - %3d %3d - %3d\n",
2360 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
);
2361 printf ("BANG_OLUFSEN 2 %3d - %3d %3d - %3d\n",
2362 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
);
2363 printf ("BANG_OLUFSEN 3 %3d - %3d %3d - %3d\n",
2364 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
);
2365 printf ("BANG_OLUFSEN 4 %3d - %3d %3d - %3d\n",
2366 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
);
2367 printf ("GRUNDIG/NOKIA 1 %3d - %3d %3d - %3d\n",
2368 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
);
2369 printf ("SIEMENS 1 %3d - %3d %3d - %3d\n",
2370 SIEMENS_START_BIT_LEN_MIN
, SIEMENS_START_BIT_LEN_MAX
, SIEMENS_START_BIT_LEN_MIN
, SIEMENS_START_BIT_LEN_MAX
);
2371 printf ("FDC 1 %3d - %3d %3d - %3d\n",
2372 FDC_START_BIT_PULSE_LEN_MIN
, FDC_START_BIT_PULSE_LEN_MAX
, FDC_START_BIT_PAUSE_LEN_MIN
, FDC_START_BIT_PAUSE_LEN_MAX
);
2376 main (int argc
, char ** argv
)
2379 int analyze
= FALSE
;
2385 int min_pulse_long
= 100000;
2386 int max_pulse_long
= 0;
2387 int sum_pulses_long
= 0;
2388 int n_pulses_long
= 0;
2390 int min_pulse_short
= 100000;
2391 int max_pulse_short
= 0;
2392 int sum_pulses_short
= 0;
2393 int n_pulses_short
= 0;
2395 int min_pause_long
= 100000;
2396 int max_pause_long
= 0;
2397 int sum_pauses_long
= 0;
2398 int n_pauses_long
= 0;
2400 int min_pause_short
= 100000;
2401 int max_pause_short
= 0;
2402 int sum_pauses_short
= 0;
2403 int n_pauses_short
= 0;
2405 int min_start_pulse
= 100000;
2406 int max_start_pulse
= 0;
2407 int sum_start_pulses
= 0;
2408 int n_start_pulses
= 0;
2410 int min_start_pause
= 100000;
2411 int max_start_pause
= 0;
2412 int sum_start_pauses
= 0;
2413 int n_start_pauses
= 0;
2415 int first_pulse
= TRUE
;
2416 int first_pause
= TRUE
;
2418 IRMP_DATA irmp_data
;
2422 if (! strcmp (argv
[1], "-v"))
2426 else if (! strcmp (argv
[1], "-a"))
2430 else if (! strcmp (argv
[1], "-s"))
2434 else if (! strcmp (argv
[1], "-p"))
2443 while ((ch
= getchar ()) != EOF
)
2445 if (ch
== '_' || ch
== '0')
2449 if (analyze
&& pause
> 0)
2451 printf ("pause: %d\n", pause
);
2455 if (min_start_pause
> pause
)
2457 min_start_pause
= pause
;
2459 if (max_start_pause
< pause
)
2461 max_start_pause
= pause
;
2464 sum_start_pauses
+= pause
;
2465 first_pause
= FALSE
;
2471 if (pause
> 100) // perhaps repetition frame follows
2478 if (min_pause_long
> pause
)
2480 min_pause_long
= pause
;
2482 if (max_pause_long
< pause
)
2484 max_pause_long
= pause
;
2487 sum_pauses_long
+= pause
;
2492 if (min_pause_short
> pause
)
2494 min_pause_short
= pause
;
2496 if (max_pause_short
< pause
)
2498 max_pause_short
= pause
;
2501 sum_pauses_short
+= pause
;
2510 else if (ch
== 0xaf || ch
== '-' || ch
== '1')
2516 printf ("pulse: %d ", pulse
);
2520 if (min_start_pulse
> pulse
)
2522 min_start_pulse
= pulse
;
2524 if (max_start_pulse
< pulse
)
2526 max_start_pulse
= pulse
;
2529 sum_start_pulses
+= pulse
;
2530 first_pulse
= FALSE
;
2536 if (min_pulse_long
> pulse
)
2538 min_pulse_long
= pulse
;
2540 if (max_pulse_long
< pulse
)
2542 max_pulse_long
= pulse
;
2545 sum_pulses_long
+= pulse
;
2549 if (min_pulse_short
> pulse
)
2551 min_pulse_short
= pulse
;
2553 if (max_pulse_short
< pulse
)
2555 max_pulse_short
= pulse
;
2558 sum_pulses_short
+= pulse
;
2567 else if (ch
== '\n')
2571 if (analyze
&& pause
> 0)
2573 printf ("pause: %d\n", pause
);
2579 for (i
= 0; i
< 8000; i
++) // newline: long pause of 800 msec
2589 puts ("-------------------------------------------------------------------");
2592 while ((ch
= getchar()) != '\n' && ch
!= EOF
)
2594 if (ch
!= '\r') // ignore CR in DOS/Windows files
2609 if (irmp_get_data (&irmp_data
))
2611 DEBUG_ONLY_NORMAL_PUTCHAR (' ');
2612 printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n",
2613 irmp_data
.protocol
, irmp_data
.address
, irmp_data
.command
, irmp_data
.flags
);
2619 printf ("\nSTATITSTICS:\n");
2620 printf ("---------------------------------\n");
2621 printf ("number of start pulses: %d\n", n_start_pulses
);
2622 printf ("minimum start pulse length: %d usec\n", (1000000 * min_start_pulse
) / F_INTERRUPTS
);
2623 printf ("maximum start pulse length: %d usec\n", (1000000 * max_start_pulse
) / F_INTERRUPTS
);
2624 if (n_start_pulses
> 0)
2626 printf ("average start pulse length: %d usec\n", ((1000000 * sum_start_pulses
) / n_start_pulses
) / F_INTERRUPTS
);
2629 printf ("number of start pauses: %d\n", n_start_pauses
);
2630 if (n_start_pauses
> 0)
2632 printf ("minimum start pause length: %d usec\n", (1000000 * min_start_pause
) / F_INTERRUPTS
);
2633 printf ("maximum start pause length: %d usec\n", (1000000 * max_start_pause
) / F_INTERRUPTS
);
2634 printf ("average start pause length: %d usec\n", ((1000000 * sum_start_pauses
) / n_start_pauses
) / F_INTERRUPTS
);
2637 printf ("number of long pulses: %d\n", n_pulses_long
);
2638 if (n_pulses_long
> 0)
2640 printf ("minimum long pulse length: %d usec\n", (1000000 * min_pulse_long
) / F_INTERRUPTS
);
2641 printf ("maximum long pulse length: %d usec\n", (1000000 * max_pulse_long
) / F_INTERRUPTS
);
2642 printf ("average long pulse length: %d usec\n", ((1000000 * sum_pulses_long
) / n_pulses_long
) / F_INTERRUPTS
);
2645 printf ("number of short pulses: %d\n", n_pulses_short
);
2646 if (n_pulses_short
> 0)
2648 printf ("minimum short pulse length: %d usec\n", (1000000 * min_pulse_short
) / F_INTERRUPTS
);
2649 printf ("maximum short pulse length: %d usec\n", (1000000 * max_pulse_short
) / F_INTERRUPTS
);
2650 printf ("average short pulse length: %d usec\n", ((1000000 * sum_pulses_short
) / n_pulses_short
) / F_INTERRUPTS
);
2654 printf ("number of long pauses: %d\n", n_pauses_long
);
2655 if (n_pauses_long
> 0)
2657 printf ("minimum long pause length: %d usec\n", (1000000 * min_pause_long
) / F_INTERRUPTS
);
2658 printf ("maximum long pause length: %d usec\n", (1000000 * max_pause_long
) / F_INTERRUPTS
);
2659 printf ("average long pause length: %d usec\n", ((1000000 * sum_pauses_long
) / n_pauses_long
) / F_INTERRUPTS
);
2662 printf ("number of short pauses: %d\n", n_pauses_short
);
2663 if (n_pauses_short
> 0)
2665 printf ("minimum short pause length: %d usec\n", (1000000 * min_pause_short
) / F_INTERRUPTS
);
2666 printf ("maximum short pause length: %d usec\n", (1000000 * max_pause_short
) / F_INTERRUPTS
);
2667 printf ("average short pause length: %d usec\n", ((1000000 * sum_pauses_short
) / n_pauses_short
) / F_INTERRUPTS
);