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