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