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