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