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