]> cloudbase.mooo.com Git - irmp.git/blob - irmp.c
Version 3.0: corrected ESP8266 port, added MBED port, added several main example...
[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.184 2016/01/12 11:53:34 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 baud rate, 8 data bits, 1 stop bit, no parity, no 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 baud rate, 8 data bits, 1 stop bit, no parity, no 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 INT level (receive)
852 USARTC1.CTRLB = USART_TXEN_bm | USART_RXEN_bm; // activated RX and TX
853 USARTC1.CTRLC = USART_CHSIZE_8BIT_gc; // 8 Bit
854 PORTC.DIR |= (1<<7); // TXD is output
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 #if defined(__MBED__)
2026 // DigitalIn inputPin(IRMP_PIN, PullUp); // this requires mbed.h and source to be compiled as cpp
2027 gpio_t gpioIRin; // use low level c function instead
2028 #endif
2029
2030
2031 #ifdef ANALYZE
2032 #define input(x) (x)
2033 static uint_fast8_t IRMP_PIN;
2034 static uint_fast8_t radio;
2035 #endif
2036
2037 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2038 * Initialize IRMP decoder
2039 * @details Configures IRMP input pin
2040 *---------------------------------------------------------------------------------------------------------------------------------------------------
2041 */
2042 #ifndef ANALYZE
2043 void
2044 irmp_init (void)
2045 {
2046 #if defined(PIC_CCS) || defined(PIC_C18) // PIC: do nothing
2047 #elif defined (ARM_STM32) // STM32
2048 GPIO_InitTypeDef GPIO_InitStructure;
2049
2050 /* GPIOx clock enable */
2051 # if defined (ARM_STM32L1XX)
2052 RCC_AHBPeriphClockCmd(IRMP_PORT_RCC, ENABLE);
2053 # elif defined (ARM_STM32F10X)
2054 RCC_APB2PeriphClockCmd(IRMP_PORT_RCC, ENABLE);
2055 # elif defined (ARM_STM32F4XX)
2056 RCC_AHB1PeriphClockCmd(IRMP_PORT_RCC, ENABLE);
2057 # endif
2058
2059 /* GPIO Configuration */
2060 GPIO_InitStructure.GPIO_Pin = IRMP_BIT;
2061 # if defined (ARM_STM32L1XX) || defined (ARM_STM32F4XX)
2062 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
2063 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
2064 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
2065 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
2066 # elif defined (ARM_STM32F10X)
2067 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
2068 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
2069 # endif
2070 GPIO_Init(IRMP_PORT, &GPIO_InitStructure);
2071
2072 #elif defined(STELLARIS_ARM_CORTEX_M4)
2073 // Enable the GPIO port
2074 ROM_SysCtlPeripheralEnable(IRMP_PORT_PERIPH);
2075
2076 // Set as an input
2077 ROM_GPIODirModeSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_DIR_MODE_IN);
2078 ROM_GPIOPadConfigSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
2079
2080 #elif defined(__SDCC_stm8) // STM8
2081 IRMP_GPIO_STRUCT->DDR &= ~(1<<IRMP_BIT); // pin is input
2082 IRMP_GPIO_STRUCT->CR1 |= (1<<IRMP_BIT); // activate pullup
2083
2084 #elif defined (TEENSY_ARM_CORTEX_M4) // TEENSY
2085 pinMode(IRMP_PIN, INPUT);
2086
2087 #elif defined(__xtensa__) // ESP8266
2088 // select pin function
2089 # if (IRMP_BIT_NUMBER == 12)
2090 PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
2091 // doesn't work for me:
2092 // # elif (IRMP_BIT_NUMBER == 13)
2093 // PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U , FUNC_GPIO13);
2094 # else
2095 # warning Please add PIN_FUNC_SELECT when necessary.
2096 # endif
2097 GPIO_DIS_OUTPUT(IRMP_BIT_NUMBER);
2098
2099 #elif defined(__MBED__)
2100 gpio_init_in_ex(&gpioIRin, IRMP_PIN, IRMP_PINMODE); // initialize input for IR diode
2101
2102 #else // AVR
2103 IRMP_PORT &= ~(1<<IRMP_BIT); // deactivate pullup
2104 IRMP_DDR &= ~(1<<IRMP_BIT); // set pin to input
2105 #endif
2106
2107 #if IRMP_LOGGING == 1
2108 irmp_uart_init ();
2109 #endif
2110 }
2111 #endif
2112 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2113 * Get IRMP data
2114 * @details gets decoded IRMP data
2115 * @param pointer in order to store IRMP data
2116 * @return TRUE: successful, FALSE: failed
2117 *---------------------------------------------------------------------------------------------------------------------------------------------------
2118 */
2119 uint_fast8_t
2120 irmp_get_data (IRMP_DATA * irmp_data_p)
2121 {
2122 uint_fast8_t rtc = FALSE;
2123
2124 if (irmp_ir_detected)
2125 {
2126 switch (irmp_protocol)
2127 {
2128 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2129 case IRMP_SAMSUNG_PROTOCOL:
2130 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))
2131 {
2132 irmp_command &= 0xff;
2133 irmp_command |= irmp_id << 8;
2134 rtc = TRUE;
2135 }
2136 break;
2137
2138 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1
2139 case IRMP_SAMSUNG48_PROTOCOL:
2140 irmp_command = (irmp_command & 0x00FF) | ((irmp_id & 0x00FF) << 8);
2141 rtc = TRUE;
2142 break;
2143 #endif
2144 #endif
2145
2146 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2147 case IRMP_NEC_PROTOCOL:
2148 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))
2149 {
2150 irmp_command &= 0xff;
2151 rtc = TRUE;
2152 }
2153 else if (irmp_address == 0x87EE)
2154 {
2155 #ifdef ANALYZE
2156 ANALYZE_PRINTF ("Switching to APPLE protocol\n");
2157 #endif // ANALYZE
2158 irmp_protocol = IRMP_APPLE_PROTOCOL;
2159 irmp_address = (irmp_command & 0xFF00) >> 8;
2160 irmp_command &= 0x00FF;
2161 rtc = TRUE;
2162 }
2163 break;
2164 #endif
2165 #if IRMP_SUPPORT_BOSE_PROTOCOL == 1
2166 case IRMP_BOSE_PROTOCOL:
2167 if ((irmp_command >> 8) == (~irmp_command & 0x00FF))
2168 {
2169 irmp_command &= 0xff;
2170 rtc = TRUE;
2171 }
2172 break;
2173 #endif
2174 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
2175 case IRMP_SIEMENS_PROTOCOL:
2176 case IRMP_RUWIDO_PROTOCOL:
2177 if (((irmp_command >> 1) & 0x0001) == (~irmp_command & 0x0001))
2178 {
2179 irmp_command >>= 1;
2180 rtc = TRUE;
2181 }
2182 break;
2183 #endif
2184 #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
2185 case IRMP_KATHREIN_PROTOCOL:
2186 if (irmp_command != 0x0000)
2187 {
2188 rtc = TRUE;
2189 }
2190 break;
2191 #endif
2192 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
2193 case IRMP_RC5_PROTOCOL:
2194 irmp_address &= ~0x20; // clear toggle bit
2195 rtc = TRUE;
2196 break;
2197 #endif
2198 #if IRMP_SUPPORT_S100_PROTOCOL == 1
2199 case IRMP_S100_PROTOCOL:
2200 irmp_address &= ~0x20; // clear toggle bit
2201 rtc = TRUE;
2202 break;
2203 #endif
2204 #if IRMP_SUPPORT_IR60_PROTOCOL == 1
2205 case IRMP_IR60_PROTOCOL:
2206 if (irmp_command != 0x007d) // 0x007d (== 62<<1 + 1) is start instruction frame
2207 {
2208 rtc = TRUE;
2209 }
2210 else
2211 {
2212 #ifdef ANALYZE
2213 ANALYZE_PRINTF("Info IR60: got start instruction frame\n");
2214 #endif // ANALYZE
2215 }
2216 break;
2217 #endif
2218 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
2219 case IRMP_RCCAR_PROTOCOL:
2220 // frame in irmp_data:
2221 // Bit 12 11 10 9 8 7 6 5 4 3 2 1 0
2222 // V D7 D6 D5 D4 D3 D2 D1 D0 A1 A0 C1 C0 // 10 9 8 7 6 5 4 3 2 1 0
2223 irmp_address = (irmp_command & 0x000C) >> 2; // addr: 0 0 0 0 0 0 0 0 0 A1 A0
2224 irmp_command = ((irmp_command & 0x1000) >> 2) | // V-Bit: V 0 0 0 0 0 0 0 0 0 0
2225 ((irmp_command & 0x0003) << 8) | // C-Bits: 0 C1 C0 0 0 0 0 0 0 0 0
2226 ((irmp_command & 0x0FF0) >> 4); // D-Bits: D7 D6 D5 D4 D3 D2 D1 D0
2227 rtc = TRUE; // Summe: V C1 C0 D7 D6 D5 D4 D3 D2 D1 D0
2228 break;
2229 #endif
2230
2231 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 // squeeze code to 8 bit, upper bit indicates release-key
2232 case IRMP_NETBOX_PROTOCOL:
2233 if (irmp_command & 0x1000) // last bit set?
2234 {
2235 if ((irmp_command & 0x1f) == 0x15) // key pressed: 101 01 (LSB)
2236 {
2237 irmp_command >>= 5;
2238 irmp_command &= 0x7F;
2239 rtc = TRUE;
2240 }
2241 else if ((irmp_command & 0x1f) == 0x10) // key released: 000 01 (LSB)
2242 {
2243 irmp_command >>= 5;
2244 irmp_command |= 0x80;
2245 rtc = TRUE;
2246 }
2247 else
2248 {
2249 #ifdef ANALYZE
2250 ANALYZE_PRINTF("error NETBOX: bit6/7 must be 0/1\n");
2251 #endif // ANALYZE
2252 }
2253 }
2254 else
2255 {
2256 #ifdef ANALYZE
2257 ANALYZE_PRINTF("error NETBOX: last bit not set\n");
2258 #endif // ANALYZE
2259 }
2260 break;
2261 #endif
2262 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1
2263 case IRMP_LEGO_PROTOCOL:
2264 {
2265 uint_fast8_t crc = 0x0F ^ ((irmp_command & 0xF000) >> 12) ^ ((irmp_command & 0x0F00) >> 8) ^ ((irmp_command & 0x00F0) >> 4);
2266
2267 if ((irmp_command & 0x000F) == crc)
2268 {
2269 irmp_command >>= 4;
2270 rtc = TRUE;
2271 }
2272 else
2273 {
2274 #ifdef ANALYZE
2275 ANALYZE_PRINTF ("CRC error in LEGO protocol\n");
2276 #endif // ANALYZE
2277 // rtc = TRUE; // don't accept codes with CRC errors
2278 }
2279 break;
2280 }
2281 #endif
2282
2283 default:
2284 {
2285 rtc = TRUE;
2286 break;
2287 }
2288 }
2289
2290 if (rtc)
2291 {
2292 irmp_data_p->protocol = irmp_protocol;
2293 irmp_data_p->address = irmp_address;
2294 irmp_data_p->command = irmp_command;
2295 irmp_data_p->flags = irmp_flags;
2296 irmp_command = 0;
2297 irmp_address = 0;
2298 irmp_flags = 0;
2299 }
2300
2301 irmp_ir_detected = FALSE;
2302 }
2303
2304 return rtc;
2305 }
2306
2307 #if IRMP_USE_CALLBACK == 1
2308 void
2309 irmp_set_callback_ptr (void (*cb)(uint_fast8_t))
2310 {
2311 irmp_callback_ptr = cb;
2312 }
2313 #endif // IRMP_USE_CALLBACK == 1
2314
2315 // these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR()
2316 static uint_fast16_t irmp_tmp_address; // ir address
2317 static uint_fast16_t irmp_tmp_command; // ir command
2318
2319 #if (IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)) || IRMP_SUPPORT_NEC42_PROTOCOL == 1
2320 static uint_fast16_t irmp_tmp_address2; // ir address
2321 static uint_fast16_t irmp_tmp_command2; // ir command
2322 #endif
2323
2324 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
2325 static uint_fast16_t irmp_lgair_address; // ir address
2326 static uint_fast16_t irmp_lgair_command; // ir command
2327 #endif
2328
2329 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2330 static uint_fast16_t irmp_tmp_id; // ir id (only SAMSUNG)
2331 #endif
2332 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2333 static uint8_t xor_check[6]; // check kaseikyo "parity" bits
2334 static uint_fast8_t genre2; // save genre2 bits here, later copied to MSB in flags
2335 #endif
2336
2337 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
2338 static uint_fast8_t parity; // number of '1' of the first 14 bits, check if even.
2339 #endif
2340
2341 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2342 * store bit
2343 * @details store bit in temp address or temp command
2344 * @param value to store: 0 or 1
2345 *---------------------------------------------------------------------------------------------------------------------------------------------------
2346 */
2347 // verhindert, dass irmp_store_bit() inline compiliert wird:
2348 // static void irmp_store_bit (uint_fast8_t) __attribute__ ((noinline));
2349
2350 static void
2351 irmp_store_bit (uint_fast8_t value)
2352 {
2353 #if IRMP_SUPPORT_ACP24_PROTOCOL == 1
2354 if (irmp_param.protocol == IRMP_ACP24_PROTOCOL) // squeeze 64 bits into 16 bits:
2355 {
2356 if (value)
2357 {
2358 // ACP24-Frame:
2359 // 1 2 3 4 5 6
2360 // 0123456789012345678901234567890123456789012345678901234567890123456789
2361 // N VVMMM ? ??? t vmA x y TTTT
2362 //
2363 // irmp_data_p->command:
2364 //
2365 // 5432109876543210
2366 // NAVVvMMMmtxyTTTT
2367
2368 switch (irmp_bit)
2369 {
2370 case 0: irmp_tmp_command |= (1<<15); break; // N
2371 case 2: irmp_tmp_command |= (1<<13); break; // V
2372 case 3: irmp_tmp_command |= (1<<12); break; // V
2373 case 4: irmp_tmp_command |= (1<<10); break; // M
2374 case 5: irmp_tmp_command |= (1<< 9); break; // M
2375 case 6: irmp_tmp_command |= (1<< 8); break; // M
2376 case 20: irmp_tmp_command |= (1<< 6); break; // t
2377 case 22: irmp_tmp_command |= (1<<11); break; // v
2378 case 23: irmp_tmp_command |= (1<< 7); break; // m
2379 case 24: irmp_tmp_command |= (1<<14); break; // A
2380 case 26: irmp_tmp_command |= (1<< 5); break; // x
2381 case 44: irmp_tmp_command |= (1<< 4); break; // y
2382 case 66: irmp_tmp_command |= (1<< 3); break; // T
2383 case 67: irmp_tmp_command |= (1<< 2); break; // T
2384 case 68: irmp_tmp_command |= (1<< 1); break; // T
2385 case 69: irmp_tmp_command |= (1<< 0); break; // T
2386 }
2387 }
2388 }
2389 else
2390 #endif // IRMP_SUPPORT_ACP24_PROTOCOL
2391
2392 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
2393 if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL)
2394 {
2395 if (irmp_bit < 14)
2396 {
2397 if (value)
2398 {
2399 parity++;
2400 }
2401 }
2402 else if (irmp_bit == 14)
2403 {
2404 if (value) // value == 1: even parity
2405 {
2406 if (parity & 0x01)
2407 {
2408 parity = PARITY_CHECK_FAILED;
2409 }
2410 else
2411 {
2412 parity = PARITY_CHECK_OK;
2413 }
2414 }
2415 else
2416 {
2417 if (parity & 0x01) // value == 0: odd parity
2418 {
2419 parity = PARITY_CHECK_OK;
2420 }
2421 else
2422 {
2423 parity = PARITY_CHECK_FAILED;
2424 }
2425 }
2426 }
2427 }
2428 else
2429 #endif
2430 {
2431 ;
2432 }
2433
2434 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
2435 if (irmp_bit == 0 && irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL)
2436 {
2437 first_bit = value;
2438 }
2439 else
2440 #endif
2441
2442 if (irmp_bit >= irmp_param.address_offset && irmp_bit < irmp_param.address_end)
2443 {
2444 if (irmp_param.lsb_first)
2445 {
2446 irmp_tmp_address |= (((uint_fast16_t) (value)) << (irmp_bit - irmp_param.address_offset)); // CV wants cast
2447 }
2448 else
2449 {
2450 irmp_tmp_address <<= 1;
2451 irmp_tmp_address |= value;
2452 }
2453 }
2454 else if (irmp_bit >= irmp_param.command_offset && irmp_bit < irmp_param.command_end)
2455 {
2456 if (irmp_param.lsb_first)
2457 {
2458 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1
2459 if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit >= 32)
2460 {
2461 irmp_tmp_id |= (((uint_fast16_t) (value)) << (irmp_bit - 32)); // CV wants cast
2462 }
2463 else
2464 #endif
2465 {
2466 irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast
2467 }
2468 }
2469 else
2470 {
2471 irmp_tmp_command <<= 1;
2472 irmp_tmp_command |= value;
2473 }
2474 }
2475
2476 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
2477 if (irmp_param.protocol == IRMP_NEC_PROTOCOL || irmp_param.protocol == IRMP_NEC42_PROTOCOL)
2478 {
2479 if (irmp_bit < 8)
2480 {
2481 irmp_lgair_address <<= 1; // LGAIR uses MSB
2482 irmp_lgair_address |= value;
2483 }
2484 else if (irmp_bit < 24)
2485 {
2486 irmp_lgair_command <<= 1; // LGAIR uses MSB
2487 irmp_lgair_command |= value;
2488 }
2489 }
2490 // NO else!
2491 #endif
2492
2493 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
2494 if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit >= 13 && irmp_bit < 26)
2495 {
2496 irmp_tmp_address2 |= (((uint_fast16_t) (value)) << (irmp_bit - 13)); // CV wants cast
2497 }
2498 else
2499 #endif
2500
2501 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2502 if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit >= SAMSUNG_ID_OFFSET && irmp_bit < SAMSUNG_ID_OFFSET + SAMSUNG_ID_LEN)
2503 {
2504 irmp_tmp_id |= (((uint_fast16_t) (value)) << (irmp_bit - SAMSUNG_ID_OFFSET)); // store with LSB first
2505 }
2506 else
2507 #endif
2508
2509 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2510 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)
2511 {
2512 if (irmp_bit >= 20 && irmp_bit < 24)
2513 {
2514 irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first
2515 }
2516 else if (irmp_bit >= 24 && irmp_bit < 28)
2517 {
2518 genre2 |= (((uint_fast8_t) (value)) << (irmp_bit - 20)); // store 4 system bits (genre 2) in upper nibble with LSB first
2519 }
2520
2521 if (irmp_bit < KASEIKYO_COMPLETE_DATA_LEN)
2522 {
2523 if (value)
2524 {
2525 xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8);
2526 }
2527 else
2528 {
2529 xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8));
2530 }
2531 }
2532 }
2533 else
2534 #endif
2535 {
2536 ;
2537 }
2538
2539 irmp_bit++;
2540 }
2541
2542 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2543 * store bit
2544 * @details store bit in temp address or temp command
2545 * @param value to store: 0 or 1
2546 *---------------------------------------------------------------------------------------------------------------------------------------------------
2547 */
2548 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2549 static void
2550 irmp_store_bit2 (uint_fast8_t value)
2551 {
2552 uint_fast8_t irmp_bit2;
2553
2554 if (irmp_param.protocol)
2555 {
2556 irmp_bit2 = irmp_bit - 2;
2557 }
2558 else
2559 {
2560 irmp_bit2 = irmp_bit - 1;
2561 }
2562
2563 if (irmp_bit2 >= irmp_param2.address_offset && irmp_bit2 < irmp_param2.address_end)
2564 {
2565 irmp_tmp_address2 |= (((uint_fast16_t) (value)) << (irmp_bit2 - irmp_param2.address_offset)); // CV wants cast
2566 }
2567 else if (irmp_bit2 >= irmp_param2.command_offset && irmp_bit2 < irmp_param2.command_end)
2568 {
2569 irmp_tmp_command2 |= (((uint_fast16_t) (value)) << (irmp_bit2 - irmp_param2.command_offset)); // CV wants cast
2570 }
2571 }
2572 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2573
2574 /*---------------------------------------------------------------------------------------------------------------------------------------------------
2575 * ISR routine
2576 * @details ISR routine, called 10000 times per second
2577 *---------------------------------------------------------------------------------------------------------------------------------------------------
2578 */
2579 uint_fast8_t
2580 irmp_ISR (void)
2581 {
2582 static uint_fast8_t irmp_start_bit_detected; // flag: start bit detected
2583 static uint_fast8_t wait_for_space; // flag: wait for data bit space
2584 static uint_fast8_t wait_for_start_space; // flag: wait for start bit space
2585 static uint_fast8_t irmp_pulse_time; // count bit time for pulse
2586 static PAUSE_LEN irmp_pause_time; // count bit time for pause
2587 static uint_fast16_t last_irmp_address = 0xFFFF; // save last irmp address to recognize key repetition
2588 static uint_fast16_t last_irmp_command = 0xFFFF; // save last irmp command to recognize key repetition
2589 static uint_fast16_t key_repetition_len; // SIRCS repeats frame 2-5 times with 45 ms pause
2590 static uint_fast8_t repetition_frame_number;
2591 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
2592 static uint_fast16_t last_irmp_denon_command; // save last irmp command to recognize DENON frame repetition
2593 static uint_fast16_t denon_repetition_len = 0xFFFF; // denon repetition len of 2nd auto generated frame
2594 #endif
2595 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_S100_PROTOCOL == 1
2596 static uint_fast8_t rc5_cmd_bit6; // bit 6 of RC5 command is the inverted 2nd start bit
2597 #endif
2598 #if IRMP_SUPPORT_MANCHESTER == 1
2599 static PAUSE_LEN last_pause; // last pause value
2600 #endif
2601 #if IRMP_SUPPORT_MANCHESTER == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
2602 static uint_fast8_t last_value; // last bit value
2603 #endif
2604 uint_fast8_t irmp_input; // input value
2605
2606 #ifdef ANALYZE
2607 time_counter++;
2608 #endif // ANALYZE
2609
2610 #if defined(__SDCC_stm8)
2611 irmp_input = input(IRMP_GPIO_STRUCT->IDR)
2612 #elif defined(__MBED__)
2613 //irmp_input = inputPin;
2614 irmp_input = gpio_read (&gpioIRin);
2615 #else
2616 irmp_input = input(IRMP_PIN);
2617 #endif
2618
2619 #if IRMP_USE_CALLBACK == 1
2620 if (irmp_callback_ptr)
2621 {
2622 static uint_fast8_t last_inverted_input;
2623
2624 if (last_inverted_input != !irmp_input)
2625 {
2626 (*irmp_callback_ptr) (! irmp_input);
2627 last_inverted_input = !irmp_input;
2628 }
2629 }
2630 #endif // IRMP_USE_CALLBACK == 1
2631
2632 irmp_log(irmp_input); // log ir signal, if IRMP_LOGGING defined
2633
2634 if (! irmp_ir_detected) // ir code already detected?
2635 { // no...
2636 if (! irmp_start_bit_detected) // start bit detected?
2637 { // no...
2638 if (! irmp_input) // receiving burst?
2639 { // yes...
2640 // irmp_busy_flag = TRUE;
2641 #ifdef ANALYZE
2642 if (! irmp_pulse_time)
2643 {
2644 ANALYZE_PRINTF("%8.3fms [starting pulse]\n", (double) (time_counter * 1000) / F_INTERRUPTS);
2645 }
2646 #endif // ANALYZE
2647 irmp_pulse_time++; // increment counter
2648 }
2649 else
2650 { // no...
2651 if (irmp_pulse_time) // it's dark....
2652 { // set flags for counting the time of darkness...
2653 irmp_start_bit_detected = 1;
2654 wait_for_start_space = 1;
2655 wait_for_space = 0;
2656 irmp_tmp_command = 0;
2657 irmp_tmp_address = 0;
2658 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2659 genre2 = 0;
2660 #endif
2661 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2662 irmp_tmp_id = 0;
2663 #endif
2664
2665 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1
2666 irmp_tmp_command2 = 0;
2667 irmp_tmp_address2 = 0;
2668 #endif
2669 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
2670 irmp_lgair_command = 0;
2671 irmp_lgair_address = 0;
2672 #endif
2673 irmp_bit = 0xff;
2674 irmp_pause_time = 1; // 1st pause: set to 1, not to 0!
2675 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_S100_PROTOCOL == 1
2676 rc5_cmd_bit6 = 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame!
2677 #endif
2678 }
2679 else
2680 {
2681 if (key_repetition_len < 0xFFFF) // avoid overflow of counter
2682 {
2683 key_repetition_len++;
2684
2685 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
2686 if (denon_repetition_len < 0xFFFF) // avoid overflow of counter
2687 {
2688 denon_repetition_len++;
2689
2690 if (denon_repetition_len >= DENON_AUTO_REPETITION_PAUSE_LEN && last_irmp_denon_command != 0)
2691 {
2692 #ifdef ANALYZE
2693 ANALYZE_PRINTF ("%8.3fms warning: did not receive inverted command repetition\n",
2694 (double) (time_counter * 1000) / F_INTERRUPTS);
2695 #endif // ANALYZE
2696 last_irmp_denon_command = 0;
2697 denon_repetition_len = 0xFFFF;
2698 }
2699 }
2700 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
2701 }
2702 }
2703 }
2704 }
2705 else
2706 {
2707 if (wait_for_start_space) // we have received start bit...
2708 { // ...and are counting the time of darkness
2709 if (irmp_input) // still dark?
2710 { // yes
2711 irmp_pause_time++; // increment counter
2712
2713 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1
2714 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) ||
2715 irmp_pause_time > IRMP_TIMEOUT_NIKON_LEN)
2716 #else
2717 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?
2718 #endif
2719 { // yes...
2720 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2721 if (irmp_protocol == IRMP_JVC_PROTOCOL) // don't show eror if JVC protocol, irmp_pulse_time has been set below!
2722 {
2723 ;
2724 }
2725 else
2726 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2727 {
2728 #ifdef ANALYZE
2729 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);
2730 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
2731 #endif // ANALYZE
2732 }
2733
2734 irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit
2735 irmp_pulse_time = 0;
2736 irmp_pause_time = 0;
2737 }
2738 }
2739 else
2740 { // receiving first data pulse!
2741 IRMP_PARAMETER * irmp_param_p;
2742 irmp_param_p = (IRMP_PARAMETER *) 0;
2743
2744 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
2745 irmp_param2.protocol = 0;
2746 #endif
2747
2748 #ifdef ANALYZE
2749 ANALYZE_PRINTF ("%8.3fms [start-bit: pulse = %2d, pause = %2d]\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time);
2750 #endif // ANALYZE
2751
2752 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
2753 if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX &&
2754 irmp_pause_time >= SIRCS_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIRCS_START_BIT_PAUSE_LEN_MAX)
2755 { // it's SIRCS
2756 #ifdef ANALYZE
2757 ANALYZE_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2758 SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX,
2759 SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX);
2760 #endif // ANALYZE
2761 irmp_param_p = (IRMP_PARAMETER *) &sircs_param;
2762 }
2763 else
2764 #endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1
2765
2766 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2767 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame
2768 irmp_pulse_time >= JVC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= JVC_START_BIT_PULSE_LEN_MAX &&
2769 irmp_pause_time >= JVC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= JVC_REPEAT_START_BIT_PAUSE_LEN_MAX)
2770 {
2771 #ifdef ANALYZE
2772 ANALYZE_PRINTF ("protocol = NEC or JVC (type 1) repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2773 JVC_START_BIT_PULSE_LEN_MIN, JVC_START_BIT_PULSE_LEN_MAX,
2774 JVC_REPEAT_START_BIT_PAUSE_LEN_MIN, JVC_REPEAT_START_BIT_PAUSE_LEN_MAX);
2775 #endif // ANALYZE
2776 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
2777 }
2778 else
2779 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2780
2781 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
2782 if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&
2783 irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)
2784 {
2785 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
2786 #ifdef ANALYZE
2787 ANALYZE_PRINTF ("protocol = NEC42, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2788 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
2789 NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);
2790 #endif // ANALYZE
2791 irmp_param_p = (IRMP_PARAMETER *) &nec42_param;
2792 #else
2793 #ifdef ANALYZE
2794 ANALYZE_PRINTF ("protocol = NEC, 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_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);
2797 #endif // ANALYZE
2798 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
2799 #endif
2800 }
2801 else if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&
2802 irmp_pause_time >= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX)
2803 { // it's NEC
2804 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2805 if (irmp_protocol == IRMP_JVC_PROTOCOL) // last protocol was JVC, awaiting repeat frame
2806 { // some jvc remote controls use nec repetition frame for jvc repetition frame
2807 #ifdef ANALYZE
2808 ANALYZE_PRINTF ("protocol = JVC repeat frame type 2, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2809 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
2810 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);
2811 #endif // ANALYZE
2812 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
2813 }
2814 else
2815 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2816 {
2817 #ifdef ANALYZE
2818 ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2819 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
2820 NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);
2821 #endif // ANALYZE
2822
2823 irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param;
2824 }
2825 }
2826 else
2827
2828 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
2829 if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame
2830 irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&
2831 irmp_pause_time >= NEC_0_PAUSE_LEN_MIN && irmp_pause_time <= NEC_0_PAUSE_LEN_MAX)
2832 { // it's JVC repetition type 3
2833 #ifdef ANALYZE
2834 ANALYZE_PRINTF ("protocol = JVC repeat frame type 3, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2835 NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,
2836 NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX);
2837 #endif // ANALYZE
2838 irmp_param_p = (IRMP_PARAMETER *) &nec_param;
2839 }
2840 else
2841 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
2842
2843 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
2844
2845 #if IRMP_SUPPORT_TELEFUNKEN_PROTOCOL == 1
2846 if (irmp_pulse_time >= TELEFUNKEN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= TELEFUNKEN_START_BIT_PULSE_LEN_MAX &&
2847 irmp_pause_time >= TELEFUNKEN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= TELEFUNKEN_START_BIT_PAUSE_LEN_MAX)
2848 {
2849 #ifdef ANALYZE
2850 ANALYZE_PRINTF ("protocol = TELEFUNKEN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2851 TELEFUNKEN_START_BIT_PULSE_LEN_MIN, TELEFUNKEN_START_BIT_PULSE_LEN_MAX,
2852 TELEFUNKEN_START_BIT_PAUSE_LEN_MIN, TELEFUNKEN_START_BIT_PAUSE_LEN_MAX);
2853 #endif // ANALYZE
2854 irmp_param_p = (IRMP_PARAMETER *) &telefunken_param;
2855 }
2856 else
2857 #endif // IRMP_SUPPORT_TELEFUNKEN_PROTOCOL == 1
2858
2859 #if IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
2860 if (irmp_pulse_time >= ROOMBA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_START_BIT_PULSE_LEN_MAX &&
2861 irmp_pause_time >= ROOMBA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ROOMBA_START_BIT_PAUSE_LEN_MAX)
2862 {
2863 #ifdef ANALYZE
2864 ANALYZE_PRINTF ("protocol = ROOMBA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2865 ROOMBA_START_BIT_PULSE_LEN_MIN, ROOMBA_START_BIT_PULSE_LEN_MAX,
2866 ROOMBA_START_BIT_PAUSE_LEN_MIN, ROOMBA_START_BIT_PAUSE_LEN_MAX);
2867 #endif // ANALYZE
2868 irmp_param_p = (IRMP_PARAMETER *) &roomba_param;
2869 }
2870 else
2871 #endif // IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
2872
2873 #if IRMP_SUPPORT_ACP24_PROTOCOL == 1
2874 if (irmp_pulse_time >= ACP24_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ACP24_START_BIT_PULSE_LEN_MAX &&
2875 irmp_pause_time >= ACP24_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ACP24_START_BIT_PAUSE_LEN_MAX)
2876 {
2877 #ifdef ANALYZE
2878 ANALYZE_PRINTF ("protocol = ACP24, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2879 ACP24_START_BIT_PULSE_LEN_MIN, ACP24_START_BIT_PULSE_LEN_MAX,
2880 ACP24_START_BIT_PAUSE_LEN_MIN, ACP24_START_BIT_PAUSE_LEN_MAX);
2881 #endif // ANALYZE
2882 irmp_param_p = (IRMP_PARAMETER *) &acp24_param;
2883 }
2884 else
2885 #endif // IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
2886
2887 #if IRMP_SUPPORT_PENTAX_PROTOCOL == 1
2888 if (irmp_pulse_time >= PENTAX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= PENTAX_START_BIT_PULSE_LEN_MAX &&
2889 irmp_pause_time >= PENTAX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= PENTAX_START_BIT_PAUSE_LEN_MAX)
2890 {
2891 #ifdef ANALYZE
2892 ANALYZE_PRINTF ("protocol = PENTAX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2893 PENTAX_START_BIT_PULSE_LEN_MIN, PENTAX_START_BIT_PULSE_LEN_MAX,
2894 PENTAX_START_BIT_PAUSE_LEN_MIN, PENTAX_START_BIT_PAUSE_LEN_MAX);
2895 #endif // ANALYZE
2896 irmp_param_p = (IRMP_PARAMETER *) &pentax_param;
2897 }
2898 else
2899 #endif // IRMP_SUPPORT_PENTAX_PROTOCOL == 1
2900
2901 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1
2902 if (irmp_pulse_time >= NIKON_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NIKON_START_BIT_PULSE_LEN_MAX &&
2903 irmp_pause_time >= NIKON_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NIKON_START_BIT_PAUSE_LEN_MAX)
2904 {
2905 #ifdef ANALYZE
2906 ANALYZE_PRINTF ("protocol = NIKON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2907 NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX,
2908 NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX);
2909 #endif // ANALYZE
2910 irmp_param_p = (IRMP_PARAMETER *) &nikon_param;
2911 }
2912 else
2913 #endif // IRMP_SUPPORT_NIKON_PROTOCOL == 1
2914
2915 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2916 if (irmp_pulse_time >= SAMSUNG_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_START_BIT_PULSE_LEN_MAX &&
2917 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)
2918 { // it's SAMSUNG
2919 #ifdef ANALYZE
2920 ANALYZE_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2921 SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX,
2922 SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX);
2923 #endif // ANALYZE
2924 irmp_param_p = (IRMP_PARAMETER *) &samsung_param;
2925 }
2926 else
2927 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
2928
2929 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
2930 if (irmp_pulse_time >= MATSUSHITA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MATSUSHITA_START_BIT_PULSE_LEN_MAX &&
2931 irmp_pause_time >= MATSUSHITA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MATSUSHITA_START_BIT_PAUSE_LEN_MAX)
2932 { // it's MATSUSHITA
2933 #ifdef ANALYZE
2934 ANALYZE_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2935 MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX,
2936 MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX);
2937 #endif // ANALYZE
2938 irmp_param_p = (IRMP_PARAMETER *) &matsushita_param;
2939 }
2940 else
2941 #endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1
2942
2943 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2944 if (irmp_pulse_time >= KASEIKYO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KASEIKYO_START_BIT_PULSE_LEN_MAX &&
2945 irmp_pause_time >= KASEIKYO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KASEIKYO_START_BIT_PAUSE_LEN_MAX)
2946 { // it's KASEIKYO
2947 #ifdef ANALYZE
2948 ANALYZE_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2949 KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX,
2950 KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX);
2951 #endif // ANALYZE
2952 irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param;
2953 }
2954 else
2955 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
2956
2957 #if IRMP_SUPPORT_PANASONIC_PROTOCOL == 1
2958 if (irmp_pulse_time >= PANASONIC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= PANASONIC_START_BIT_PULSE_LEN_MAX &&
2959 irmp_pause_time >= PANASONIC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= PANASONIC_START_BIT_PAUSE_LEN_MAX)
2960 { // it's PANASONIC
2961 #ifdef ANALYZE
2962 ANALYZE_PRINTF ("protocol = PANASONIC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2963 PANASONIC_START_BIT_PULSE_LEN_MIN, PANASONIC_START_BIT_PULSE_LEN_MAX,
2964 PANASONIC_START_BIT_PAUSE_LEN_MIN, PANASONIC_START_BIT_PAUSE_LEN_MAX);
2965 #endif // ANALYZE
2966 irmp_param_p = (IRMP_PARAMETER *) &panasonic_param;
2967 }
2968 else
2969 #endif // IRMP_SUPPORT_PANASONIC_PROTOCOL == 1
2970
2971 #if IRMP_SUPPORT_RADIO1_PROTOCOL == 1
2972 if (irmp_pulse_time >= RADIO1_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RADIO1_START_BIT_PULSE_LEN_MAX &&
2973 irmp_pause_time >= RADIO1_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RADIO1_START_BIT_PAUSE_LEN_MAX)
2974 {
2975 #ifdef ANALYZE
2976 ANALYZE_PRINTF ("protocol = RADIO1, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2977 RADIO1_START_BIT_PULSE_LEN_MIN, RADIO1_START_BIT_PULSE_LEN_MAX,
2978 RADIO1_START_BIT_PAUSE_LEN_MIN, RADIO1_START_BIT_PAUSE_LEN_MAX);
2979 #endif // ANALYZE
2980 irmp_param_p = (IRMP_PARAMETER *) &radio1_param;
2981 }
2982 else
2983 #endif // IRMP_SUPPORT_RRADIO1_PROTOCOL == 1
2984
2985 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1
2986 if (irmp_pulse_time >= RECS80_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80_START_BIT_PULSE_LEN_MAX &&
2987 irmp_pause_time >= RECS80_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80_START_BIT_PAUSE_LEN_MAX)
2988 { // it's RECS80
2989 #ifdef ANALYZE
2990 ANALYZE_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
2991 RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX,
2992 RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX);
2993 #endif // ANALYZE
2994 irmp_param_p = (IRMP_PARAMETER *) &recs80_param;
2995 }
2996 else
2997 #endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1
2998
2999 #if IRMP_SUPPORT_S100_PROTOCOL == 1
3000 if (((irmp_pulse_time >= S100_START_BIT_LEN_MIN && irmp_pulse_time <= S100_START_BIT_LEN_MAX) ||
3001 (irmp_pulse_time >= 2 * S100_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * S100_START_BIT_LEN_MAX)) &&
3002 ((irmp_pause_time >= S100_START_BIT_LEN_MIN && irmp_pause_time <= S100_START_BIT_LEN_MAX) ||
3003 (irmp_pause_time >= 2 * S100_START_BIT_LEN_MIN && irmp_pause_time <= 2 * S100_START_BIT_LEN_MAX)))
3004 { // it's S100
3005 #ifdef ANALYZE
3006 ANALYZE_PRINTF ("protocol = S100, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n",
3007 S100_START_BIT_LEN_MIN, S100_START_BIT_LEN_MAX,
3008 2 * S100_START_BIT_LEN_MIN, 2 * S100_START_BIT_LEN_MAX,
3009 S100_START_BIT_LEN_MIN, S100_START_BIT_LEN_MAX,
3010 2 * S100_START_BIT_LEN_MIN, 2 * S100_START_BIT_LEN_MAX);
3011 #endif // ANALYZE
3012
3013 irmp_param_p = (IRMP_PARAMETER *) &s100_param;
3014 last_pause = irmp_pause_time;
3015
3016 if ((irmp_pulse_time > S100_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * S100_START_BIT_LEN_MAX) ||
3017 (irmp_pause_time > S100_START_BIT_LEN_MAX && irmp_pause_time <= 2 * S100_START_BIT_LEN_MAX))
3018 {
3019 last_value = 0;
3020 rc5_cmd_bit6 = 1<<6;
3021 }
3022 else
3023 {
3024 last_value = 1;
3025 }
3026 }
3027 else
3028 #endif // IRMP_SUPPORT_S100_PROTOCOL == 1
3029
3030 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
3031 if (((irmp_pulse_time >= RC5_START_BIT_LEN_MIN && irmp_pulse_time <= RC5_START_BIT_LEN_MAX) ||
3032 (irmp_pulse_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX)) &&
3033 ((irmp_pause_time >= RC5_START_BIT_LEN_MIN && irmp_pause_time <= RC5_START_BIT_LEN_MAX) ||
3034 (irmp_pause_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)))
3035 { // it's RC5
3036 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
3037 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&
3038 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)
3039 {
3040 #ifdef ANALYZE
3041 ANALYZE_PRINTF ("protocol = RC5 or FDC\n");
3042 ANALYZE_PRINTF ("FDC start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3043 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,
3044 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);
3045 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3046 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
3047 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);
3048 #endif // ANALYZE
3049 memcpy_P (&irmp_param2, &fdc_param, sizeof (IRMP_PARAMETER));
3050 }
3051 else
3052 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
3053
3054 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
3055 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&
3056 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)
3057 {
3058 #ifdef ANALYZE
3059 ANALYZE_PRINTF ("protocol = RC5 or RCCAR\n");
3060 ANALYZE_PRINTF ("RCCAR start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3061 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,
3062 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);
3063 ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3064 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
3065 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);
3066 #endif // ANALYZE
3067 memcpy_P (&irmp_param2, &rccar_param, sizeof (IRMP_PARAMETER));
3068 }
3069 else
3070 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
3071 {
3072 #ifdef ANALYZE
3073 ANALYZE_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n",
3074 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
3075 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX,
3076 RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,
3077 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX);
3078 #endif // ANALYZE
3079 }
3080
3081 irmp_param_p = (IRMP_PARAMETER *) &rc5_param;
3082 last_pause = irmp_pause_time;
3083
3084 if ((irmp_pulse_time > RC5_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX) ||
3085 (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX))
3086 {
3087 last_value = 0;
3088 rc5_cmd_bit6 = 1<<6;
3089 }
3090 else
3091 {
3092 last_value = 1;
3093 }
3094 }
3095 else
3096 #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1
3097
3098 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
3099 if ( (irmp_pulse_time >= DENON_PULSE_LEN_MIN && irmp_pulse_time <= DENON_PULSE_LEN_MAX) &&
3100 ((irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) ||
3101 (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)))
3102 { // it's DENON
3103 #ifdef ANALYZE
3104 ANALYZE_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
3105 DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX,
3106 DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX,
3107 DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX);
3108 #endif // ANALYZE
3109 irmp_param_p = (IRMP_PARAMETER *) &denon_param;
3110 }
3111 else
3112 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
3113
3114 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1
3115 if ( (irmp_pulse_time >= THOMSON_PULSE_LEN_MIN && irmp_pulse_time <= THOMSON_PULSE_LEN_MAX) &&
3116 ((irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX) ||
3117 (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)))
3118 { // it's THOMSON
3119 #ifdef ANALYZE
3120 ANALYZE_PRINTF ("protocol = THOMSON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
3121 THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX,
3122 THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX,
3123 THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX);
3124 #endif // ANALYZE
3125 irmp_param_p = (IRMP_PARAMETER *) &thomson_param;
3126 }
3127 else
3128 #endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1
3129
3130 #if IRMP_SUPPORT_BOSE_PROTOCOL == 1
3131 if (irmp_pulse_time >= BOSE_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= BOSE_START_BIT_PULSE_LEN_MAX &&
3132 irmp_pause_time >= BOSE_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BOSE_START_BIT_PAUSE_LEN_MAX)
3133 {
3134 #ifdef ANALYZE
3135 ANALYZE_PRINTF ("protocol = BOSE, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3136 BOSE_START_BIT_PULSE_LEN_MIN, BOSE_START_BIT_PULSE_LEN_MAX,
3137 BOSE_START_BIT_PAUSE_LEN_MIN, BOSE_START_BIT_PAUSE_LEN_MAX);
3138 #endif // ANALYZE
3139 irmp_param_p = (IRMP_PARAMETER *) &bose_param;
3140 }
3141 else
3142 #endif // IRMP_SUPPORT_BOSE_PROTOCOL == 1
3143
3144 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
3145 if (irmp_pulse_time >= RC6_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RC6_START_BIT_PULSE_LEN_MAX &&
3146 irmp_pause_time >= RC6_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RC6_START_BIT_PAUSE_LEN_MAX)
3147 { // it's RC6
3148 #ifdef ANALYZE
3149 ANALYZE_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3150 RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX,
3151 RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX);
3152 #endif // ANALYZE
3153 irmp_param_p = (IRMP_PARAMETER *) &rc6_param;
3154 last_pause = 0;
3155 last_value = 1;
3156 }
3157 else
3158 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
3159
3160 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
3161 if (irmp_pulse_time >= RECS80EXT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80EXT_START_BIT_PULSE_LEN_MAX &&
3162 irmp_pause_time >= RECS80EXT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80EXT_START_BIT_PAUSE_LEN_MAX)
3163 { // it's RECS80EXT
3164 #ifdef ANALYZE
3165 ANALYZE_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3166 RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX,
3167 RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX);
3168 #endif // ANALYZE
3169 irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param;
3170 }
3171 else
3172 #endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1
3173
3174 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
3175 if (irmp_pulse_time >= NUBERT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NUBERT_START_BIT_PULSE_LEN_MAX &&
3176 irmp_pause_time >= NUBERT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NUBERT_START_BIT_PAUSE_LEN_MAX)
3177 { // it's NUBERT
3178 #ifdef ANALYZE
3179 ANALYZE_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3180 NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX,
3181 NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX);
3182 #endif // ANALYZE
3183 irmp_param_p = (IRMP_PARAMETER *) &nubert_param;
3184 }
3185 else
3186 #endif // IRMP_SUPPORT_NUBERT_PROTOCOL == 1
3187
3188 #if IRMP_SUPPORT_FAN_PROTOCOL == 1
3189 if (irmp_pulse_time >= FAN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FAN_START_BIT_PULSE_LEN_MAX &&
3190 irmp_pause_time >= FAN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FAN_START_BIT_PAUSE_LEN_MAX)
3191 { // it's FAN
3192 #ifdef ANALYZE
3193 ANALYZE_PRINTF ("protocol = FAN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3194 FAN_START_BIT_PULSE_LEN_MIN, FAN_START_BIT_PULSE_LEN_MAX,
3195 FAN_START_BIT_PAUSE_LEN_MIN, FAN_START_BIT_PAUSE_LEN_MAX);
3196 #endif // ANALYZE
3197 irmp_param_p = (IRMP_PARAMETER *) &fan_param;
3198 }
3199 else
3200 #endif // IRMP_SUPPORT_FAN_PROTOCOL == 1
3201
3202 #if IRMP_SUPPORT_SPEAKER_PROTOCOL == 1
3203 if (irmp_pulse_time >= SPEAKER_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SPEAKER_START_BIT_PULSE_LEN_MAX &&
3204 irmp_pause_time >= SPEAKER_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SPEAKER_START_BIT_PAUSE_LEN_MAX)
3205 { // it's SPEAKER
3206 #ifdef ANALYZE
3207 ANALYZE_PRINTF ("protocol = SPEAKER, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3208 SPEAKER_START_BIT_PULSE_LEN_MIN, SPEAKER_START_BIT_PULSE_LEN_MAX,
3209 SPEAKER_START_BIT_PAUSE_LEN_MIN, SPEAKER_START_BIT_PAUSE_LEN_MAX);
3210 #endif // ANALYZE
3211 irmp_param_p = (IRMP_PARAMETER *) &speaker_param;
3212 }
3213 else
3214 #endif // IRMP_SUPPORT_SPEAKER_PROTOCOL == 1
3215
3216 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
3217 if (irmp_pulse_time >= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX &&
3218 irmp_pause_time >= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX)
3219 { // it's BANG_OLUFSEN
3220 #ifdef ANALYZE
3221 ANALYZE_PRINTF ("protocol = BANG_OLUFSEN\n");
3222 ANALYZE_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3223 BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,
3224 BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);
3225 ANALYZE_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3226 BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,
3227 BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);
3228 ANALYZE_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3229 BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,
3230 BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);
3231 ANALYZE_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3232 BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX,
3233 BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX);
3234 #endif // ANALYZE
3235 irmp_param_p = (IRMP_PARAMETER *) &bang_olufsen_param;
3236 last_value = 0;
3237 }
3238 else
3239 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
3240
3241 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
3242 if (irmp_pulse_time >= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX &&
3243 irmp_pause_time >= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX)
3244 { // it's GRUNDIG
3245 #ifdef ANALYZE
3246 ANALYZE_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3247 GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX,
3248 GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX);
3249 #endif // ANALYZE
3250 irmp_param_p = (IRMP_PARAMETER *) &grundig_param;
3251 last_pause = irmp_pause_time;
3252 last_value = 1;
3253 }
3254 else
3255 #endif // IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
3256
3257 #if IRMP_SUPPORT_MERLIN_PROTOCOL == 1 // check MERLIN before RUWIDO!
3258 if (irmp_pulse_time >= MERLIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MERLIN_START_BIT_PULSE_LEN_MAX &&
3259 irmp_pause_time >= MERLIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MERLIN_START_BIT_PAUSE_LEN_MAX)
3260 { // it's MERLIN
3261 #ifdef ANALYZE
3262 ANALYZE_PRINTF ("protocol = MERLIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3263 MERLIN_START_BIT_PULSE_LEN_MIN, MERLIN_START_BIT_PULSE_LEN_MAX,
3264 MERLIN_START_BIT_PAUSE_LEN_MIN, MERLIN_START_BIT_PAUSE_LEN_MAX);
3265 #endif // ANALYZE
3266 irmp_param_p = (IRMP_PARAMETER *) &merlin_param;
3267 last_pause = 0;
3268 last_value = 1;
3269 }
3270 else
3271 #endif // IRMP_SUPPORT_MERLIN_PROTOCOL == 1
3272
3273 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
3274 if (((irmp_pulse_time >= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX) ||
3275 (irmp_pulse_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX)) &&
3276 ((irmp_pause_time >= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX) ||
3277 (irmp_pause_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX)))
3278 { // it's RUWIDO or SIEMENS
3279 #ifdef ANALYZE
3280 ANALYZE_PRINTF ("protocol = RUWIDO, start bit timings: pulse: %3d - %3d or %3d - %3d, pause: %3d - %3d or %3d - %3d\n",
3281 SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,
3282 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX,
3283 SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX,
3284 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX);
3285 #endif // ANALYZE
3286 irmp_param_p = (IRMP_PARAMETER *) &ruwido_param;
3287 last_pause = irmp_pause_time;
3288 last_value = 1;
3289 }
3290 else
3291 #endif // IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
3292
3293 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
3294 if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&
3295 irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)
3296 {
3297 #ifdef ANALYZE
3298 ANALYZE_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3299 FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,
3300 FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);
3301 #endif // ANALYZE
3302 irmp_param_p = (IRMP_PARAMETER *) &fdc_param;
3303 }
3304 else
3305 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
3306
3307 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1
3308 if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&
3309 irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)
3310 {
3311 #ifdef ANALYZE
3312 ANALYZE_PRINTF ("protocol = RCCAR, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3313 RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,
3314 RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);
3315 #endif // ANALYZE
3316 irmp_param_p = (IRMP_PARAMETER *) &rccar_param;
3317 }
3318 else
3319 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
3320
3321 #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
3322 if (irmp_pulse_time >= KATHREIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_START_BIT_PULSE_LEN_MAX &&
3323 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)
3324 { // it's KATHREIN
3325 #ifdef ANALYZE
3326 ANALYZE_PRINTF ("protocol = KATHREIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3327 KATHREIN_START_BIT_PULSE_LEN_MIN, KATHREIN_START_BIT_PULSE_LEN_MAX,
3328 KATHREIN_START_BIT_PAUSE_LEN_MIN, KATHREIN_START_BIT_PAUSE_LEN_MAX);
3329 #endif // ANALYZE
3330 irmp_param_p = (IRMP_PARAMETER *) &kathrein_param;
3331 }
3332 else
3333 #endif // IRMP_SUPPORT_KATHREIN_PROTOCOL == 1
3334
3335 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1
3336 if (irmp_pulse_time >= NETBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NETBOX_START_BIT_PULSE_LEN_MAX &&
3337 irmp_pause_time >= NETBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NETBOX_START_BIT_PAUSE_LEN_MAX)
3338 { // it's NETBOX
3339 #ifdef ANALYZE
3340 ANALYZE_PRINTF ("protocol = NETBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3341 NETBOX_START_BIT_PULSE_LEN_MIN, NETBOX_START_BIT_PULSE_LEN_MAX,
3342 NETBOX_START_BIT_PAUSE_LEN_MIN, NETBOX_START_BIT_PAUSE_LEN_MAX);
3343 #endif // ANALYZE
3344 irmp_param_p = (IRMP_PARAMETER *) &netbox_param;
3345 }
3346 else
3347 #endif // IRMP_SUPPORT_NETBOX_PROTOCOL == 1
3348
3349 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1
3350 if (irmp_pulse_time >= LEGO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= LEGO_START_BIT_PULSE_LEN_MAX &&
3351 irmp_pause_time >= LEGO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= LEGO_START_BIT_PAUSE_LEN_MAX)
3352 {
3353 #ifdef ANALYZE
3354 ANALYZE_PRINTF ("protocol = LEGO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3355 LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX,
3356 LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX);
3357 #endif // ANALYZE
3358 irmp_param_p = (IRMP_PARAMETER *) &lego_param;
3359 }
3360 else
3361 #endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1
3362
3363 #if IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1
3364 if (irmp_pulse_time >= A1TVBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= A1TVBOX_START_BIT_PULSE_LEN_MAX &&
3365 irmp_pause_time >= A1TVBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= A1TVBOX_START_BIT_PAUSE_LEN_MAX)
3366 { // it's A1TVBOX
3367 #ifdef ANALYZE
3368 ANALYZE_PRINTF ("protocol = A1TVBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3369 A1TVBOX_START_BIT_PULSE_LEN_MIN, A1TVBOX_START_BIT_PULSE_LEN_MAX,
3370 A1TVBOX_START_BIT_PAUSE_LEN_MIN, A1TVBOX_START_BIT_PAUSE_LEN_MAX);
3371 #endif // ANALYZE
3372 irmp_param_p = (IRMP_PARAMETER *) &a1tvbox_param;
3373 last_pause = 0;
3374 last_value = 1;
3375 }
3376 else
3377 #endif // IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1
3378
3379 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
3380 if (irmp_pulse_time >= ORTEK_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ORTEK_START_BIT_PULSE_LEN_MAX &&
3381 irmp_pause_time >= ORTEK_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ORTEK_START_BIT_PAUSE_LEN_MAX)
3382 { // it's ORTEK (Hama)
3383 #ifdef ANALYZE
3384 ANALYZE_PRINTF ("protocol = ORTEK, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3385 ORTEK_START_BIT_PULSE_LEN_MIN, ORTEK_START_BIT_PULSE_LEN_MAX,
3386 ORTEK_START_BIT_PAUSE_LEN_MIN, ORTEK_START_BIT_PAUSE_LEN_MAX);
3387 #endif // ANALYZE
3388 irmp_param_p = (IRMP_PARAMETER *) &ortek_param;
3389 last_pause = 0;
3390 last_value = 1;
3391 parity = 0;
3392 }
3393 else
3394 #endif // IRMP_SUPPORT_ORTEK_PROTOCOL == 1
3395
3396 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1
3397 if (irmp_pulse_time >= RCMM32_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCMM32_START_BIT_PULSE_LEN_MAX &&
3398 irmp_pause_time >= RCMM32_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_START_BIT_PAUSE_LEN_MAX)
3399 { // it's RCMM
3400 #ifdef ANALYZE
3401 ANALYZE_PRINTF ("protocol = RCMM, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
3402 RCMM32_START_BIT_PULSE_LEN_MIN, RCMM32_START_BIT_PULSE_LEN_MAX,
3403 RCMM32_START_BIT_PAUSE_LEN_MIN, RCMM32_START_BIT_PAUSE_LEN_MAX);
3404 #endif // ANALYZE
3405 irmp_param_p = (IRMP_PARAMETER *) &rcmm_param;
3406 }
3407 else
3408 #endif // IRMP_SUPPORT_RCMM_PROTOCOL == 1
3409 {
3410 #ifdef ANALYZE
3411 ANALYZE_PRINTF ("protocol = UNKNOWN\n");
3412 #endif // ANALYZE
3413 irmp_start_bit_detected = 0; // wait for another start bit...
3414 }
3415
3416 if (irmp_start_bit_detected)
3417 {
3418 memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER));
3419
3420 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))
3421 {
3422 #ifdef ANALYZE
3423 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max);
3424 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max);
3425 #endif // ANALYZE
3426 }
3427 else
3428 {
3429 #ifdef ANALYZE
3430 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max,
3431 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max);
3432 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max,
3433 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max);
3434 #endif // ANALYZE
3435 }
3436
3437 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
3438 if (irmp_param2.protocol)
3439 {
3440 #ifdef ANALYZE
3441 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param2.pulse_0_len_min, irmp_param2.pulse_0_len_max);
3442 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param2.pause_0_len_min, irmp_param2.pause_0_len_max);
3443 ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param2.pulse_1_len_min, irmp_param2.pulse_1_len_max);
3444 ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param2.pause_1_len_min, irmp_param2.pause_1_len_max);
3445 #endif // ANALYZE
3446 }
3447 #endif
3448
3449
3450 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
3451 if (irmp_param.protocol == IRMP_RC6_PROTOCOL)
3452 {
3453 #ifdef ANALYZE
3454 ANALYZE_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX);
3455 #endif // ANALYZE
3456 }
3457 #endif
3458
3459 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))
3460 {
3461 #ifdef ANALYZE
3462 ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);
3463 ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max);
3464 #endif // ANALYZE
3465 }
3466 else
3467 {
3468 #ifdef ANALYZE
3469 ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max,
3470 2 * irmp_param.pulse_0_len_min, 2 * irmp_param.pulse_0_len_max);
3471 ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max,
3472 2 * irmp_param.pause_0_len_min, 2 * irmp_param.pause_0_len_max);
3473 #endif // ANALYZE
3474 }
3475
3476 #ifdef ANALYZE
3477 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
3478 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)
3479 {
3480 ANALYZE_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);
3481 ANALYZE_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX);
3482 }
3483 #endif
3484
3485 ANALYZE_PRINTF ("command_offset: %2d\n", irmp_param.command_offset);
3486 ANALYZE_PRINTF ("command_len: %3d\n", irmp_param.command_end - irmp_param.command_offset);
3487 ANALYZE_PRINTF ("complete_len: %3d\n", irmp_param.complete_len);
3488 ANALYZE_PRINTF ("stop_bit: %3d\n", irmp_param.stop_bit);
3489 #endif // ANALYZE
3490 }
3491
3492 irmp_bit = 0;
3493
3494 #if IRMP_SUPPORT_MANCHESTER == 1
3495 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&
3496 irmp_param.protocol != IRMP_RUWIDO_PROTOCOL && // Manchester, but not RUWIDO
3497 irmp_param.protocol != IRMP_RC6_PROTOCOL) // Manchester, but not RC6
3498 {
3499 if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max)
3500 {
3501 #ifdef ANALYZE
3502 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
3503 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');
3504 ANALYZE_NEWLINE ();
3505 #endif // ANALYZE
3506 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1);
3507 }
3508 else if (! last_value) // && irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)
3509 {
3510 #ifdef ANALYZE
3511 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
3512 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');
3513 ANALYZE_NEWLINE ();
3514 #endif // ANALYZE
3515 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0);
3516 }
3517 }
3518 else
3519 #endif // IRMP_SUPPORT_MANCHESTER == 1
3520
3521 #if IRMP_SUPPORT_SERIAL == 1
3522 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)
3523 {
3524 ; // do nothing
3525 }
3526 else
3527 #endif // IRMP_SUPPORT_SERIAL == 1
3528
3529
3530 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
3531 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)
3532 {
3533 #ifdef ANALYZE
3534 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
3535 #endif // ANALYZE
3536
3537 if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX)
3538 { // pause timings correct for "1"?
3539 #ifdef ANALYZE
3540 ANALYZE_PUTCHAR ('1'); // yes, store 1
3541 ANALYZE_NEWLINE ();
3542 #endif // ANALYZE
3543 irmp_store_bit (1);
3544 }
3545 else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)
3546 { // pause timings correct for "0"?
3547 #ifdef ANALYZE
3548 ANALYZE_PUTCHAR ('0'); // yes, store 0
3549 ANALYZE_NEWLINE ();
3550 #endif // ANALYZE
3551 irmp_store_bit (0);
3552 }
3553 }
3554 else
3555 #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1
3556 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1
3557 if (irmp_param.protocol == IRMP_THOMSON_PROTOCOL)
3558 {
3559 #ifdef ANALYZE
3560 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
3561 #endif // ANALYZE
3562
3563 if (irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX)
3564 { // pause timings correct for "1"?
3565 #ifdef ANALYZE
3566 ANALYZE_PUTCHAR ('1'); // yes, store 1
3567 ANALYZE_NEWLINE ();
3568 #endif // ANALYZE
3569 irmp_store_bit (1);
3570 }
3571 else // if (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX)
3572 { // pause timings correct for "0"?
3573 #ifdef ANALYZE
3574 ANALYZE_PUTCHAR ('0'); // yes, store 0
3575 ANALYZE_NEWLINE ();
3576 #endif // ANALYZE
3577 irmp_store_bit (0);
3578 }
3579 }
3580 else
3581 #endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1
3582 {
3583 ; // else do nothing
3584 }
3585
3586 irmp_pulse_time = 1; // set counter to 1, not 0
3587 irmp_pause_time = 0;
3588 wait_for_start_space = 0;
3589 }
3590 }
3591 else if (wait_for_space) // the data section....
3592 { // counting the time of darkness....
3593 uint_fast8_t got_light = FALSE;
3594
3595 if (irmp_input) // still dark?
3596 { // yes...
3597 if (irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 1)
3598 {
3599 if (
3600 #if IRMP_SUPPORT_MANCHESTER == 1
3601 (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) ||
3602 #endif
3603 #if IRMP_SUPPORT_SERIAL == 1
3604 (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) ||
3605 #endif
3606 (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max))
3607 {
3608 #ifdef ANALYZE
3609 if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))
3610 {
3611 ANALYZE_PRINTF ("stop bit detected\n");
3612 }
3613 #endif // ANALYZE
3614 irmp_param.stop_bit = 0;
3615 }
3616 else
3617 {
3618 #ifdef ANALYZE
3619 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",
3620 irmp_bit, irmp_pulse_time, irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);
3621 #endif // ANALYZE
3622 irmp_start_bit_detected = 0; // wait for another start bit...
3623 irmp_pulse_time = 0;
3624 irmp_pause_time = 0;
3625 }
3626 }
3627 else
3628 {
3629 irmp_pause_time++; // increment counter
3630
3631 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
3632 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && // Sony has a variable number of bits:
3633 irmp_pause_time > SIRCS_PAUSE_LEN_MAX && // minimum is 12
3634 irmp_bit >= 12 - 1) // pause too long?
3635 { // yes, break and close this frame
3636 irmp_param.complete_len = irmp_bit + 1; // set new complete length
3637 got_light = TRUE; // this is a lie, but helps (generates stop bit)
3638 irmp_tmp_address |= (irmp_bit - SIRCS_MINIMUM_DATA_LEN + 1) << 8; // new: store number of additional bits in upper byte of address!
3639 irmp_param.command_end = irmp_param.command_offset + irmp_bit + 1; // correct command length
3640 irmp_pause_time = SIRCS_PAUSE_LEN_MAX - 1; // correct pause length
3641 }
3642 else
3643 #endif
3644 #if IRMP_SUPPORT_FAN_PROTOCOL == 1
3645 if (irmp_param.protocol == IRMP_FAN_PROTOCOL && // FAN has no stop bit.
3646 irmp_bit >= FAN_COMPLETE_DATA_LEN - 1) // last bit in frame
3647 { // yes, break and close this frame
3648 if (irmp_pulse_time <= FAN_0_PULSE_LEN_MAX && irmp_pause_time >= FAN_0_PAUSE_LEN_MIN)
3649 {
3650 #ifdef ANALYZE
3651 ANALYZE_PRINTF ("Generating virtual stop bit\n");
3652 #endif // ANALYZE
3653 got_light = TRUE; // this is a lie, but helps (generates stop bit)
3654 }
3655 else if (irmp_pulse_time >= FAN_1_PULSE_LEN_MIN && irmp_pause_time >= FAN_1_PAUSE_LEN_MIN)
3656 {
3657 #ifdef ANALYZE
3658 ANALYZE_PRINTF ("Generating virtual stop bit\n");
3659 #endif // ANALYZE
3660 got_light = TRUE; // this is a lie, but helps (generates stop bit)
3661 }
3662 }
3663 else
3664 #endif
3665 #if IRMP_SUPPORT_SERIAL == 1
3666 // NETBOX generates no stop bit, here is the timeout condition:
3667 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) && irmp_param.protocol == IRMP_NETBOX_PROTOCOL &&
3668 irmp_pause_time >= NETBOX_PULSE_LEN * (NETBOX_COMPLETE_DATA_LEN - irmp_bit))
3669 {
3670 got_light = TRUE; // this is a lie, but helps (generates stop bit)
3671 }
3672 else
3673 #endif
3674 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1
3675 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit)
3676 {
3677 if (irmp_pause_time > IR60_TIMEOUT_LEN && (irmp_bit == 5 || irmp_bit == 6))
3678 {
3679 #ifdef ANALYZE
3680 ANALYZE_PRINTF ("Switching to IR60 protocol\n");
3681 #endif // ANALYZE
3682 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
3683 irmp_param.stop_bit = TRUE; // set flag
3684
3685 irmp_param.protocol = IRMP_IR60_PROTOCOL; // change protocol
3686 irmp_param.complete_len = IR60_COMPLETE_DATA_LEN; // correct complete len
3687 irmp_param.address_offset = IR60_ADDRESS_OFFSET;
3688 irmp_param.address_end = IR60_ADDRESS_OFFSET + IR60_ADDRESS_LEN;
3689 irmp_param.command_offset = IR60_COMMAND_OFFSET;
3690 irmp_param.command_end = IR60_COMMAND_OFFSET + IR60_COMMAND_LEN;
3691
3692 irmp_tmp_command <<= 1;
3693 irmp_tmp_command |= first_bit;
3694 }
3695 else if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2)
3696 { // special manchester decoder
3697 irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len
3698 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
3699 irmp_param.stop_bit = TRUE; // set flag
3700 }
3701 else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN)
3702 {
3703 #ifdef ANALYZE
3704 ANALYZE_PRINTF ("Switching to NOKIA protocol, irmp_bit = %d\n", irmp_bit);
3705 #endif // ANALYZE
3706 irmp_param.protocol = IRMP_NOKIA_PROTOCOL; // change protocol
3707 irmp_param.address_offset = NOKIA_ADDRESS_OFFSET;
3708 irmp_param.address_end = NOKIA_ADDRESS_OFFSET + NOKIA_ADDRESS_LEN;
3709 irmp_param.command_offset = NOKIA_COMMAND_OFFSET;
3710 irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN;
3711
3712 if (irmp_tmp_command & 0x300)
3713 {
3714 irmp_tmp_address = (irmp_tmp_command >> 8);
3715 irmp_tmp_command &= 0xFF;
3716 }
3717 }
3718 }
3719 else
3720 #endif
3721 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1
3722 if (irmp_param.protocol == IRMP_RUWIDO_PROTOCOL && !irmp_param.stop_bit)
3723 {
3724 if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= RUWIDO_COMPLETE_DATA_LEN - 2)
3725 { // special manchester decoder
3726 irmp_param.complete_len = RUWIDO_COMPLETE_DATA_LEN; // correct complete len
3727 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
3728 irmp_param.stop_bit = TRUE; // set flag
3729 }
3730 else if (irmp_bit >= RUWIDO_COMPLETE_DATA_LEN)
3731 {
3732 #ifdef ANALYZE
3733 ANALYZE_PRINTF ("Switching to SIEMENS protocol\n");
3734 #endif // ANALYZE
3735 irmp_param.protocol = IRMP_SIEMENS_PROTOCOL; // change protocol
3736 irmp_param.address_offset = SIEMENS_ADDRESS_OFFSET;
3737 irmp_param.address_end = SIEMENS_ADDRESS_OFFSET + SIEMENS_ADDRESS_LEN;
3738 irmp_param.command_offset = SIEMENS_COMMAND_OFFSET;
3739 irmp_param.command_end = SIEMENS_COMMAND_OFFSET + SIEMENS_COMMAND_LEN;
3740
3741 // 76543210
3742 // RUWIDO: AAAAAAAAACCCCCCCp
3743 // SIEMENS: AAAAAAAAAAACCCCCCCCCCp
3744 irmp_tmp_address <<= 2;
3745 irmp_tmp_address |= (irmp_tmp_command >> 6);
3746 irmp_tmp_command &= 0x003F;
3747 // irmp_tmp_command <<= 4;
3748 irmp_tmp_command |= last_value;
3749 }
3750 }
3751 else
3752 #endif
3753 #if IRMP_SUPPORT_ROOMBA_PROTOCOL == 1
3754 if (irmp_param.protocol == IRMP_ROOMBA_PROTOCOL && // Roomba has no stop bit
3755 irmp_bit >= ROOMBA_COMPLETE_DATA_LEN - 1) // it's the last data bit...
3756 { // break and close this frame
3757 if (irmp_pulse_time >= ROOMBA_1_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_1_PULSE_LEN_MAX)
3758 {
3759 irmp_pause_time = ROOMBA_1_PAUSE_LEN_EXACT;
3760 }
3761 else if (irmp_pulse_time >= ROOMBA_0_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_0_PULSE_LEN_MAX)
3762 {
3763 irmp_pause_time = ROOMBA_0_PAUSE_LEN;
3764 }
3765
3766 got_light = TRUE; // this is a lie, but helps (generates stop bit)
3767 }
3768 else
3769 #endif
3770 #if IRMP_SUPPORT_MANCHESTER == 1
3771 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&
3772 irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit)
3773 { // special manchester decoder
3774 got_light = TRUE; // this is a lie, but generates a stop bit ;-)
3775 irmp_param.stop_bit = TRUE; // set flag
3776 }
3777 else
3778 #endif // IRMP_SUPPORT_MANCHESTER == 1
3779 if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?
3780 { // yes...
3781 if (irmp_bit == irmp_param.complete_len - 1 && irmp_param.stop_bit == 0)
3782 {
3783 irmp_bit++;
3784 }
3785 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
3786 else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit
3787 {
3788 #ifdef ANALYZE
3789 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);
3790 #endif // ANALYZE
3791 irmp_param.stop_bit = TRUE; // set flag
3792 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol
3793 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
3794 irmp_tmp_command = (irmp_tmp_address >> 4); // set command: upper 12 bits are command bits
3795 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits
3796 irmp_start_bit_detected = 1; // tricky: don't wait for another start bit...
3797 }
3798 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
3799 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
3800 else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 28 || irmp_bit == 29)) // it was a LGAIR stop bit
3801 {
3802 #ifdef ANALYZE
3803 ANALYZE_PRINTF ("Switching to LGAIR protocol, irmp_bit = %d\n", irmp_bit);
3804 #endif // ANALYZE
3805 irmp_param.stop_bit = TRUE; // set flag
3806 irmp_param.protocol = IRMP_LGAIR_PROTOCOL; // switch protocol
3807 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
3808 irmp_tmp_command = irmp_lgair_command; // set command: upper 8 bits are command bits
3809 irmp_tmp_address = irmp_lgair_address; // lower 4 bits are address bits
3810 irmp_start_bit_detected = 1; // tricky: don't wait for another start bit...
3811 }
3812 #endif // IRMP_SUPPORT_LGAIR_PROTOCOL == 1
3813
3814 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
3815 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
3816 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 32) // it was a NEC stop bit
3817 {
3818 #ifdef ANALYZE
3819 ANALYZE_PRINTF ("Switching to NEC protocol\n");
3820 #endif // ANALYZE
3821 irmp_param.stop_bit = TRUE; // set flag
3822 irmp_param.protocol = IRMP_NEC_PROTOCOL; // switch protocol
3823 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
3824
3825 // 0123456789ABC0123456789ABC0123456701234567
3826 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc
3827 // NEC: AAAAAAAAaaaaaaaaCCCCCCCCcccccccc
3828 irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 13; // fm 2012-02-13: 12 -> 13
3829 irmp_tmp_command = (irmp_tmp_address2 >> 3) | (irmp_tmp_command << 10);
3830 }
3831 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1
3832 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1
3833 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 28) // it was a NEC stop bit
3834 {
3835 #ifdef ANALYZE
3836 ANALYZE_PRINTF ("Switching to LGAIR protocol\n");
3837 #endif // ANALYZE
3838 irmp_param.stop_bit = TRUE; // set flag
3839 irmp_param.protocol = IRMP_LGAIR_PROTOCOL; // switch protocol
3840 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
3841 irmp_tmp_address = irmp_lgair_address;
3842 irmp_tmp_command = irmp_lgair_command;
3843 }
3844 #endif // IRMP_SUPPORT_LGAIR_PROTOCOL == 1
3845 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
3846 else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit
3847 {
3848 #ifdef ANALYZE
3849 ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit);
3850 #endif // ANALYZE
3851 irmp_param.stop_bit = TRUE; // set flag
3852 irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol
3853 irmp_param.complete_len = irmp_bit; // patch length: 16 or 17
3854
3855 // 0123456789ABC0123456789ABC0123456701234567
3856 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc
3857 // JVC: AAAACCCCCCCCCCCC
3858 irmp_tmp_command = (irmp_tmp_address >> 4) | (irmp_tmp_address2 << 9); // set command: upper 12 bits are command bits
3859 irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits
3860 }
3861 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
3862 #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1
3863
3864 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1
3865 else if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit == 32) // it was a SAMSUNG32 stop bit
3866 {
3867 #ifdef ANALYZE
3868 ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n");
3869 #endif // ANALYZE
3870 irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL;
3871 irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET;
3872 irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN;
3873 irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN;
3874 }
3875 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
3876
3877 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1
3878 else if (irmp_param.protocol == IRMP_RCMM32_PROTOCOL && (irmp_bit == 12 || irmp_bit == 24)) // it was a RCMM stop bit
3879 {
3880 if (irmp_bit == 12)
3881 {
3882 irmp_tmp_command = (irmp_tmp_address & 0xFF); // set command: lower 8 bits are command bits
3883 irmp_tmp_address >>= 8; // upper 4 bits are address bits
3884
3885 #ifdef ANALYZE
3886 ANALYZE_PRINTF ("Switching to RCMM12 protocol, irmp_bit = %d\n", irmp_bit);
3887 #endif // ANALYZE
3888 irmp_param.protocol = IRMP_RCMM12_PROTOCOL; // switch protocol
3889 }
3890 else // if ((irmp_bit == 24)
3891 {
3892 #ifdef ANALYZE
3893 ANALYZE_PRINTF ("Switching to RCMM24 protocol, irmp_bit = %d\n", irmp_bit);
3894 #endif // ANALYZE
3895 irmp_param.protocol = IRMP_RCMM24_PROTOCOL; // switch protocol
3896 }
3897 irmp_param.stop_bit = TRUE; // set flag
3898 irmp_param.complete_len = irmp_bit; // patch length
3899 }
3900 #endif // IRMP_SUPPORT_RCMM_PROTOCOL == 1
3901
3902 #if IRMP_SUPPORT_TECHNICS_PROTOCOL == 1
3903 else if (irmp_param.protocol == IRMP_MATSUSHITA_PROTOCOL && irmp_bit == 22) // it was a TECHNICS stop bit
3904 {
3905 #ifdef ANALYZE
3906 ANALYZE_PRINTF ("Switching to TECHNICS protocol, irmp_bit = %d\n", irmp_bit);
3907 #endif // ANALYZE
3908 // Situation:
3909 // The first 12 bits have been stored in irmp_tmp_command (LSB first)
3910 // The following 10 bits have been stored in irmp_tmp_address (LSB first)
3911 // The code of TECHNICS is:
3912 // cccccccccccCCCCCCCCCCC (11 times c and 11 times C)
3913 // ccccccccccccaaaaaaaaaa
3914 // where C is inverted value of c
3915
3916 irmp_tmp_address <<= 1;
3917 if (irmp_tmp_command & (1<<11))
3918 {
3919 irmp_tmp_address |= 1;
3920 irmp_tmp_command &= ~(1<<11);
3921 }
3922
3923 if (irmp_tmp_command == ((~irmp_tmp_address) & 0x07FF))
3924 {
3925 irmp_tmp_address = 0;
3926
3927 irmp_param.protocol = IRMP_TECHNICS_PROTOCOL; // switch protocol
3928 irmp_param.complete_len = irmp_bit; // patch length
3929 }
3930 else
3931 {
3932 #ifdef ANALYZE
3933 ANALYZE_PRINTF ("error 8: TECHNICS frame error\n");
3934 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
3935 #endif // ANALYZE
3936 irmp_start_bit_detected = 0; // wait for another start bit...
3937 irmp_pulse_time = 0;
3938 irmp_pause_time = 0;
3939 }
3940 }
3941 #endif // IRMP_SUPPORT_TECHNICS_PROTOCOL == 1
3942 else
3943 {
3944 #ifdef ANALYZE
3945 ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit);
3946 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
3947 #endif // ANALYZE
3948 irmp_start_bit_detected = 0; // wait for another start bit...
3949 irmp_pulse_time = 0;
3950 irmp_pause_time = 0;
3951 }
3952 }
3953 }
3954 }
3955 else
3956 { // got light now!
3957 got_light = TRUE;
3958 }
3959
3960 if (got_light)
3961 {
3962 #ifdef ANALYZE
3963 ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time);
3964 #endif // ANALYZE
3965
3966 #if IRMP_SUPPORT_MANCHESTER == 1
3967 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester
3968 {
3969 #if 1
3970 if (irmp_pulse_time > irmp_param.pulse_1_len_max /* && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max */)
3971 #else // better, but some IR-RCs use asymmetric timings :-/
3972 if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max &&
3973 irmp_pause_time <= 2 * irmp_param.pause_1_len_max)
3974 #endif
3975 {
3976 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
3977 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit
3978 {
3979 #ifdef ANALYZE
3980 ANALYZE_PUTCHAR ('T');
3981 #endif // ANALYZE
3982 if (irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode 6A
3983 {
3984 irmp_store_bit (1);
3985 last_value = 1;
3986 }
3987 else // RC6 mode 0
3988 {
3989 irmp_store_bit (0);
3990 last_value = 0;
3991 }
3992 #ifdef ANALYZE
3993 ANALYZE_NEWLINE ();
3994 #endif // ANALYZE
3995 }
3996 else
3997 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
3998 {
3999 #ifdef ANALYZE
4000 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');
4001 #endif // ANALYZE
4002 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 );
4003
4004 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
4005 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit
4006 {
4007 #ifdef ANALYZE
4008 ANALYZE_PUTCHAR ('T');
4009 #endif // ANALYZE
4010 irmp_store_bit (1);
4011
4012 if (irmp_pause_time > 2 * irmp_param.pause_1_len_max)
4013 {
4014 last_value = 0;
4015 }
4016 else
4017 {
4018 last_value = 1;
4019 }
4020 #ifdef ANALYZE
4021 ANALYZE_NEWLINE ();
4022 #endif // ANALYZE
4023 }
4024 else
4025 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
4026 {
4027 #ifdef ANALYZE
4028 ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');
4029 #endif // ANALYZE
4030 irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 );
4031 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
4032 if (! irmp_param2.protocol)
4033 #endif
4034 {
4035 #ifdef ANALYZE
4036 ANALYZE_NEWLINE ();
4037 #endif // ANALYZE
4038 }
4039 last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0;
4040 }
4041 }
4042 }
4043 else if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max
4044 /* && irmp_pause_time <= 2 * irmp_param.pause_1_len_max */)
4045 {
4046 uint_fast8_t manchester_value;
4047
4048 if (last_pause > irmp_param.pause_1_len_max && last_pause <= 2 * irmp_param.pause_1_len_max)
4049 {
4050 manchester_value = last_value ? 0 : 1;
4051 last_value = manchester_value;
4052 }
4053 else
4054 {
4055 manchester_value = last_value;
4056 }
4057
4058 #ifdef ANALYZE
4059 ANALYZE_PUTCHAR (manchester_value + '0');
4060 #endif // ANALYZE
4061
4062 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)
4063 if (! irmp_param2.protocol)
4064 #endif
4065 {
4066 #ifdef ANALYZE
4067 ANALYZE_NEWLINE ();
4068 #endif // ANALYZE
4069 }
4070
4071 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
4072 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 1) // RC6 mode != 0 ???
4073 {
4074 #ifdef ANALYZE
4075 ANALYZE_PRINTF ("Switching to RC6A protocol\n");
4076 #endif // ANALYZE
4077 irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG;
4078 irmp_param.address_offset = 5;
4079 irmp_param.address_end = irmp_param.address_offset + 15;
4080 irmp_param.command_offset = irmp_param.address_end + 1; // skip 1 system bit, changes like a toggle bit
4081 irmp_param.command_end = irmp_param.command_offset + 16 - 1;
4082 irmp_tmp_address = 0;
4083 }
4084 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
4085
4086 irmp_store_bit (manchester_value);
4087 }
4088 else
4089 {
4090 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1
4091 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL &&
4092 irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX &&
4093 ((irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) ||
4094 (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)))
4095 {
4096 #ifdef ANALYZE
4097 ANALYZE_PUTCHAR ('?');
4098 #endif // ANALYZE
4099 irmp_param.protocol = 0; // switch to FDC, see below
4100 }
4101 else
4102 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
4103 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1
4104 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL &&
4105 irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX &&
4106 ((irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) ||
4107 (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)))
4108 {
4109 #ifdef ANALYZE
4110 ANALYZE_PUTCHAR ('?');
4111 #endif // ANALYZE
4112 irmp_param.protocol = 0; // switch to RCCAR, see below
4113 }
4114 else
4115 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
4116 {
4117 #ifdef ANALYZE
4118 ANALYZE_PUTCHAR ('?');
4119 ANALYZE_NEWLINE ();
4120 ANALYZE_PRINTF ("error 3 manchester: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4121 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4122 #endif // ANALYZE
4123 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4124 irmp_pause_time = 0;
4125 }
4126 }
4127
4128 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1
4129 if (irmp_param2.protocol == IRMP_FDC_PROTOCOL && irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX)
4130 {
4131 if (irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX)
4132 {
4133 #ifdef ANALYZE
4134 ANALYZE_PRINTF (" 1 (FDC)\n");
4135 #endif // ANALYZE
4136 irmp_store_bit2 (1);
4137 }
4138 else if (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX)
4139 {
4140 #ifdef ANALYZE
4141 ANALYZE_PRINTF (" 0 (FDC)\n");
4142 #endif // ANALYZE
4143 irmp_store_bit2 (0);
4144 }
4145
4146 if (! irmp_param.protocol)
4147 {
4148 #ifdef ANALYZE
4149 ANALYZE_PRINTF ("Switching to FDC protocol\n");
4150 #endif // ANALYZE
4151 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));
4152 irmp_param2.protocol = 0;
4153 irmp_tmp_address = irmp_tmp_address2;
4154 irmp_tmp_command = irmp_tmp_command2;
4155 }
4156 }
4157 #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1
4158 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1
4159 if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL && irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX)
4160 {
4161 if (irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX)
4162 {
4163 #ifdef ANALYZE
4164 ANALYZE_PRINTF (" 1 (RCCAR)\n");
4165 #endif // ANALYZE
4166 irmp_store_bit2 (1);
4167 }
4168 else if (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX)
4169 {
4170 #ifdef ANALYZE
4171 ANALYZE_PRINTF (" 0 (RCCAR)\n");
4172 #endif // ANALYZE
4173 irmp_store_bit2 (0);
4174 }
4175
4176 if (! irmp_param.protocol)
4177 {
4178 #ifdef ANALYZE
4179 ANALYZE_PRINTF ("Switching to RCCAR protocol\n");
4180 #endif // ANALYZE
4181 memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER));
4182 irmp_param2.protocol = 0;
4183 irmp_tmp_address = irmp_tmp_address2;
4184 irmp_tmp_command = irmp_tmp_command2;
4185 }
4186 }
4187 #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1
4188
4189 last_pause = irmp_pause_time;
4190 wait_for_space = 0;
4191 }
4192 else
4193 #endif // IRMP_SUPPORT_MANCHESTER == 1
4194
4195 #if IRMP_SUPPORT_SERIAL == 1
4196 if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL)
4197 {
4198 while (irmp_bit < irmp_param.complete_len && irmp_pulse_time > irmp_param.pulse_1_len_max)
4199 {
4200 #ifdef ANALYZE
4201 ANALYZE_PUTCHAR ('1');
4202 #endif // ANALYZE
4203 irmp_store_bit (1);
4204
4205 if (irmp_pulse_time >= irmp_param.pulse_1_len_min)
4206 {
4207 irmp_pulse_time -= irmp_param.pulse_1_len_min;
4208 }
4209 else
4210 {
4211 irmp_pulse_time = 0;
4212 }
4213 }
4214
4215 while (irmp_bit < irmp_param.complete_len && irmp_pause_time > irmp_param.pause_1_len_max)
4216 {
4217 #ifdef ANALYZE
4218 ANALYZE_PUTCHAR ('0');
4219 #endif // ANALYZE
4220 irmp_store_bit (0);
4221
4222 if (irmp_pause_time >= irmp_param.pause_1_len_min)
4223 {
4224 irmp_pause_time -= irmp_param.pause_1_len_min;
4225 }
4226 else
4227 {
4228 irmp_pause_time = 0;
4229 }
4230 }
4231 #ifdef ANALYZE
4232 ANALYZE_NEWLINE ();
4233 #endif // ANALYZE
4234 wait_for_space = 0;
4235 }
4236 else
4237 #endif // IRMP_SUPPORT_SERIAL == 1
4238
4239 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
4240 if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit == 16) // Samsung: 16th bit
4241 {
4242 if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX &&
4243 irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)
4244 {
4245 #ifdef ANALYZE
4246 ANALYZE_PRINTF ("SYNC\n");
4247 #endif // ANALYZE
4248 wait_for_space = 0;
4249 irmp_bit++;
4250 }
4251 else if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX)
4252 {
4253 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1
4254 #ifdef ANALYZE
4255 ANALYZE_PRINTF ("Switching to SAMSUNG48 protocol ");
4256 #endif // ANALYZE
4257 irmp_param.protocol = IRMP_SAMSUNG48_PROTOCOL;
4258 irmp_param.command_offset = SAMSUNG48_COMMAND_OFFSET;
4259 irmp_param.command_end = SAMSUNG48_COMMAND_OFFSET + SAMSUNG48_COMMAND_LEN;
4260 irmp_param.complete_len = SAMSUNG48_COMPLETE_DATA_LEN;
4261 #else
4262 #ifdef ANALYZE
4263 ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol ");
4264 #endif // ANALYZE
4265 irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL;
4266 irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET;
4267 irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN;
4268 irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN;
4269 #endif
4270 if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX)
4271 {
4272 #ifdef ANALYZE
4273 ANALYZE_PUTCHAR ('1');
4274 ANALYZE_NEWLINE ();
4275 #endif // ANALYZE
4276 irmp_store_bit (1);
4277 wait_for_space = 0;
4278 }
4279 else
4280 {
4281 #ifdef ANALYZE
4282 ANALYZE_PUTCHAR ('0');
4283 ANALYZE_NEWLINE ();
4284 #endif // ANALYZE
4285 irmp_store_bit (0);
4286 wait_for_space = 0;
4287 }
4288 }
4289 else
4290 { // timing incorrect!
4291 #ifdef ANALYZE
4292 ANALYZE_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4293 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4294 #endif // ANALYZE
4295 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4296 irmp_pause_time = 0;
4297 }
4298 }
4299 else
4300 #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL
4301
4302 #if IRMP_SUPPORT_NEC16_PROTOCOL
4303 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1
4304 if (irmp_param.protocol == IRMP_NEC42_PROTOCOL &&
4305 #else // IRMP_SUPPORT_NEC_PROTOCOL instead
4306 if (irmp_param.protocol == IRMP_NEC_PROTOCOL &&
4307 #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1
4308 irmp_bit == 8 && irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)
4309 {
4310 #ifdef ANALYZE
4311 ANALYZE_PRINTF ("Switching to NEC16 protocol\n");
4312 #endif // ANALYZE
4313 irmp_param.protocol = IRMP_NEC16_PROTOCOL;
4314 irmp_param.address_offset = NEC16_ADDRESS_OFFSET;
4315 irmp_param.address_end = NEC16_ADDRESS_OFFSET + NEC16_ADDRESS_LEN;
4316 irmp_param.command_offset = NEC16_COMMAND_OFFSET;
4317 irmp_param.command_end = NEC16_COMMAND_OFFSET + NEC16_COMMAND_LEN;
4318 irmp_param.complete_len = NEC16_COMPLETE_DATA_LEN;
4319 wait_for_space = 0;
4320 }
4321 else
4322 #endif // IRMP_SUPPORT_NEC16_PROTOCOL
4323
4324 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1
4325 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)
4326 {
4327 if (irmp_pulse_time >= BANG_OLUFSEN_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_PULSE_LEN_MAX)
4328 {
4329 if (irmp_bit == 1) // Bang & Olufsen: 3rd bit
4330 {
4331 if (irmp_pause_time >= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX)
4332 {
4333 #ifdef ANALYZE
4334 ANALYZE_PRINTF ("3rd start bit\n");
4335 #endif // ANALYZE
4336 wait_for_space = 0;
4337 irmp_bit++;
4338 }
4339 else
4340 { // timing incorrect!
4341 #ifdef ANALYZE
4342 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);
4343 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4344 #endif // ANALYZE
4345 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4346 irmp_pause_time = 0;
4347 }
4348 }
4349 else if (irmp_bit == 19) // Bang & Olufsen: trailer bit
4350 {
4351 if (irmp_pause_time >= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX)
4352 {
4353 #ifdef ANALYZE
4354 ANALYZE_PRINTF ("trailer bit\n");
4355 #endif // ANALYZE
4356 wait_for_space = 0;
4357 irmp_bit++;
4358 }
4359 else
4360 { // timing incorrect!
4361 #ifdef ANALYZE
4362 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);
4363 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4364 #endif // ANALYZE
4365 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4366 irmp_pause_time = 0;
4367 }
4368 }
4369 else
4370 {
4371 if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX)
4372 { // pulse & pause timings correct for "1"?
4373 #ifdef ANALYZE
4374 ANALYZE_PUTCHAR ('1');
4375 ANALYZE_NEWLINE ();
4376 #endif // ANALYZE
4377 irmp_store_bit (1);
4378 last_value = 1;
4379 wait_for_space = 0;
4380 }
4381 else if (irmp_pause_time >= BANG_OLUFSEN_0_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_0_PAUSE_LEN_MAX)
4382 { // pulse & pause timings correct for "0"?
4383 #ifdef ANALYZE
4384 ANALYZE_PUTCHAR ('0');
4385 ANALYZE_NEWLINE ();
4386 #endif // ANALYZE
4387 irmp_store_bit (0);
4388 last_value = 0;
4389 wait_for_space = 0;
4390 }
4391 else if (irmp_pause_time >= BANG_OLUFSEN_R_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_R_PAUSE_LEN_MAX)
4392 {
4393 #ifdef ANALYZE
4394 ANALYZE_PUTCHAR (last_value + '0');
4395 ANALYZE_NEWLINE ();
4396 #endif // ANALYZE
4397 irmp_store_bit (last_value);
4398 wait_for_space = 0;
4399 }
4400 else
4401 { // timing incorrect!
4402 #ifdef ANALYZE
4403 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);
4404 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4405 #endif // ANALYZE
4406 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4407 irmp_pause_time = 0;
4408 }
4409 }
4410 }
4411 else
4412 { // timing incorrect!
4413 #ifdef ANALYZE
4414 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);
4415 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4416 #endif // ANALYZE
4417 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4418 irmp_pause_time = 0;
4419 }
4420 }
4421 else
4422 #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL
4423
4424 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1
4425 if (irmp_param.protocol == IRMP_RCMM32_PROTOCOL)
4426 {
4427 if (irmp_pause_time >= RCMM32_BIT_00_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_00_PAUSE_LEN_MAX)
4428 {
4429 #ifdef ANALYZE
4430 ANALYZE_PUTCHAR ('0');
4431 ANALYZE_PUTCHAR ('0');
4432 #endif // ANALYZE
4433 irmp_store_bit (0);
4434 irmp_store_bit (0);
4435 }
4436 else if (irmp_pause_time >= RCMM32_BIT_01_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_01_PAUSE_LEN_MAX)
4437 {
4438 #ifdef ANALYZE
4439 ANALYZE_PUTCHAR ('0');
4440 ANALYZE_PUTCHAR ('1');
4441 #endif // ANALYZE
4442 irmp_store_bit (0);
4443 irmp_store_bit (1);
4444 }
4445 else if (irmp_pause_time >= RCMM32_BIT_10_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_10_PAUSE_LEN_MAX)
4446 {
4447 #ifdef ANALYZE
4448 ANALYZE_PUTCHAR ('1');
4449 ANALYZE_PUTCHAR ('0');
4450 #endif // ANALYZE
4451 irmp_store_bit (1);
4452 irmp_store_bit (0);
4453 }
4454 else if (irmp_pause_time >= RCMM32_BIT_11_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_11_PAUSE_LEN_MAX)
4455 {
4456 #ifdef ANALYZE
4457 ANALYZE_PUTCHAR ('1');
4458 ANALYZE_PUTCHAR ('1');
4459 #endif // ANALYZE
4460 irmp_store_bit (1);
4461 irmp_store_bit (1);
4462 }
4463 #ifdef ANALYZE
4464 ANALYZE_PRINTF ("\n");
4465 #endif // ANALYZE
4466 wait_for_space = 0;
4467 }
4468 else
4469 #endif
4470
4471 if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max &&
4472 irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)
4473 { // pulse & pause timings correct for "1"?
4474 #ifdef ANALYZE
4475 ANALYZE_PUTCHAR ('1');
4476 ANALYZE_NEWLINE ();
4477 #endif // ANALYZE
4478 irmp_store_bit (1);
4479 wait_for_space = 0;
4480 }
4481 else if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max &&
4482 irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max)
4483 { // pulse & pause timings correct for "0"?
4484 #ifdef ANALYZE
4485 ANALYZE_PUTCHAR ('0');
4486 ANALYZE_NEWLINE ();
4487 #endif // ANALYZE
4488 irmp_store_bit (0);
4489 wait_for_space = 0;
4490 }
4491 else
4492 #if IRMP_SUPPORT_KATHREIN_PROTOCOL
4493
4494 if (irmp_param.protocol == IRMP_KATHREIN_PROTOCOL &&
4495 irmp_pulse_time >= KATHREIN_1_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_1_PULSE_LEN_MAX &&
4496 (((irmp_bit == 8 || irmp_bit == 6) &&
4497 irmp_pause_time >= KATHREIN_SYNC_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_SYNC_BIT_PAUSE_LEN_MAX) ||
4498 (irmp_bit == 12 &&
4499 irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX)))
4500
4501 {
4502 if (irmp_bit == 8)
4503 {
4504 irmp_bit++;
4505 #ifdef ANALYZE
4506 ANALYZE_PUTCHAR ('S');
4507 ANALYZE_NEWLINE ();
4508 #endif // ANALYZE
4509 irmp_tmp_command <<= 1;
4510 }
4511 else
4512 {
4513 #ifdef ANALYZE
4514 ANALYZE_PUTCHAR ('S');
4515 ANALYZE_NEWLINE ();
4516 #endif // ANALYZE
4517 irmp_store_bit (1);
4518 }
4519 wait_for_space = 0;
4520 }
4521 else
4522 #endif // IRMP_SUPPORT_KATHREIN_PROTOCOL
4523 { // timing incorrect!
4524 #ifdef ANALYZE
4525 ANALYZE_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);
4526 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4527 #endif // ANALYZE
4528 irmp_start_bit_detected = 0; // reset flags and wait for next start bit
4529 irmp_pause_time = 0;
4530 }
4531
4532 irmp_pulse_time = 1; // set counter to 1, not 0
4533 }
4534 }
4535 else
4536 { // counting the pulse length ...
4537 if (! irmp_input) // still light?
4538 { // yes...
4539 irmp_pulse_time++; // increment counter
4540 }
4541 else
4542 { // now it's dark!
4543 wait_for_space = 1; // let's count the time (see above)
4544 irmp_pause_time = 1; // set pause counter to 1, not 0
4545 }
4546 }
4547
4548 if (irmp_start_bit_detected && irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0) // enough bits received?
4549 {
4550 if (last_irmp_command == irmp_tmp_command && key_repetition_len < AUTO_FRAME_REPETITION_LEN)
4551 {
4552 repetition_frame_number++;
4553 }
4554 else
4555 {
4556 repetition_frame_number = 0;
4557 }
4558
4559 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1
4560 // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame
4561 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2))
4562 {
4563 #ifdef ANALYZE
4564 ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4565 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4566 #endif // ANALYZE
4567 key_repetition_len = 0;
4568 }
4569 else
4570 #endif
4571
4572 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
4573 // if ORTEK protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame
4574 if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL && repetition_frame_number == 1)
4575 {
4576 #ifdef ANALYZE
4577 ANALYZE_PRINTF ("code skipped: ORTEK auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4578 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4579 #endif // ANALYZE
4580 key_repetition_len = 0;
4581 }
4582 else
4583 #endif
4584
4585 #if 0 && IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 // fm 2015-12-02: don't ignore every 2nd frame
4586 // if KASEIKYO protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame
4587 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && repetition_frame_number == 1)
4588 {
4589 #ifdef ANALYZE
4590 ANALYZE_PRINTF ("code skipped: KASEIKYO auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4591 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4592 #endif // ANALYZE
4593 key_repetition_len = 0;
4594 }
4595 else
4596 #endif
4597
4598 #if 0 && IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 // fm 2015-12-02: don't ignore every 2nd frame
4599 // if SAMSUNG32 or SAMSUNG48 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
4600 if ((irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL || irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL) && (repetition_frame_number & 0x01))
4601 {
4602 #ifdef ANALYZE
4603 ANALYZE_PRINTF ("code skipped: SAMSUNG32/SAMSUNG48 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4604 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4605 #endif // ANALYZE
4606 key_repetition_len = 0;
4607 }
4608 else
4609 #endif
4610
4611 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1
4612 // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
4613 if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01))
4614 {
4615 #ifdef ANALYZE
4616 ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4617 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4618 #endif // ANALYZE
4619 key_repetition_len = 0;
4620 }
4621 else
4622 #endif
4623
4624 #if IRMP_SUPPORT_SPEAKER_PROTOCOL == 1
4625 // if SPEAKER protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame
4626 if (irmp_param.protocol == IRMP_SPEAKER_PROTOCOL && (repetition_frame_number & 0x01))
4627 {
4628 #ifdef ANALYZE
4629 ANALYZE_PRINTF ("code skipped: SPEAKER auto repetition frame #%d, counter = %d, auto repetition len = %d\n",
4630 repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN);
4631 #endif // ANALYZE
4632 key_repetition_len = 0;
4633 }
4634 else
4635 #endif
4636
4637 {
4638 #ifdef ANALYZE
4639 ANALYZE_PRINTF ("%8.3fms code detected, length = %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit);
4640 #endif // ANALYZE
4641 irmp_ir_detected = TRUE;
4642
4643 #if IRMP_SUPPORT_DENON_PROTOCOL == 1
4644 if (irmp_param.protocol == IRMP_DENON_PROTOCOL)
4645 { // check for repetition frame
4646 if ((~irmp_tmp_command & 0x3FF) == last_irmp_denon_command) // command bits must be inverted
4647 {
4648 irmp_tmp_command = last_irmp_denon_command; // use command received before!
4649 last_irmp_denon_command = 0;
4650
4651 irmp_protocol = irmp_param.protocol; // store protocol
4652 irmp_address = irmp_tmp_address; // store address
4653 irmp_command = irmp_tmp_command; // store command
4654 }
4655 else
4656 {
4657 if ((irmp_tmp_command & 0x01) == 0x00)
4658 {
4659 #ifdef ANALYZE
4660 ANALYZE_PRINTF ("%8.3fms info Denon: waiting for inverted command repetition\n", (double) (time_counter * 1000) / F_INTERRUPTS);
4661 #endif // ANALYZE
4662 last_irmp_denon_command = irmp_tmp_command;
4663 denon_repetition_len = 0;
4664 irmp_ir_detected = FALSE;
4665 }
4666 else
4667 {
4668 #ifdef ANALYZE
4669 ANALYZE_PRINTF ("%8.3fms warning Denon: got unexpected inverted command, ignoring it\n", (double) (time_counter * 1000) / F_INTERRUPTS);
4670 #endif // ANALYZE
4671 last_irmp_denon_command = 0;
4672 irmp_ir_detected = FALSE;
4673 }
4674 }
4675 }
4676 else
4677 #endif // IRMP_SUPPORT_DENON_PROTOCOL
4678
4679 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1
4680 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && irmp_tmp_command == 0x01ff)
4681 { // Grundig start frame?
4682 #ifdef ANALYZE
4683 ANALYZE_PRINTF ("Detected GRUNDIG start frame, ignoring it\n");
4684 #endif // ANALYZE
4685 irmp_ir_detected = FALSE;
4686 }
4687 else
4688 #endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL
4689
4690 #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1
4691 if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL && irmp_tmp_address == 0x00ff && irmp_tmp_command == 0x00fe)
4692 { // Nokia start frame?
4693 #ifdef ANALYZE
4694 ANALYZE_PRINTF ("Detected NOKIA start frame, ignoring it\n");
4695 #endif // ANALYZE
4696 irmp_ir_detected = FALSE;
4697 }
4698 else
4699 #endif // IRMP_SUPPORT_NOKIA_PROTOCOL
4700 {
4701 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
4702 if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame
4703 {
4704 if (key_repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX)
4705 {
4706 #ifdef ANALYZE
4707 ANALYZE_PRINTF ("Detected NEC repetition frame, key_repetition_len = %d\n", key_repetition_len);
4708 ANALYZE_ONLY_NORMAL_PRINTF("REPETETION FRAME ");
4709 #endif // ANALYZE
4710 irmp_tmp_address = last_irmp_address; // address is last address
4711 irmp_tmp_command = last_irmp_command; // command is last command
4712 irmp_flags |= IRMP_FLAG_REPETITION;
4713 key_repetition_len = 0;
4714 }
4715 else
4716 {
4717 #ifdef ANALYZE
4718 ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, key_repetition_len = %d > %d\n",
4719 key_repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX);
4720 #endif // ANALYZE
4721 irmp_ir_detected = FALSE;
4722 }
4723 }
4724 #endif // IRMP_SUPPORT_NEC_PROTOCOL
4725
4726 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
4727 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL)
4728 {
4729 uint_fast8_t xor_value;
4730
4731 xor_value = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4);
4732
4733 if (xor_value != (xor_check[2] & 0x0F))
4734 {
4735 #ifdef ANALYZE
4736 ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor_value, xor_check[2] & 0x0F);
4737 #endif // ANALYZE
4738 irmp_ir_detected = FALSE;
4739 }
4740
4741 xor_value = xor_check[2] ^ xor_check[3] ^ xor_check[4];
4742
4743 if (xor_value != xor_check[5])
4744 {
4745 #ifdef ANALYZE
4746 ANALYZE_PRINTF ("error 5: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor_value, xor_check[5]);
4747 #endif // ANALYZE
4748 irmp_ir_detected = FALSE;
4749 }
4750
4751 irmp_flags |= genre2; // write the genre2 bits into MSB of the flag byte
4752 }
4753 #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
4754
4755 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1
4756 if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL)
4757 {
4758 if (parity == PARITY_CHECK_FAILED)
4759 {
4760 #ifdef ANALYZE
4761 ANALYZE_PRINTF ("error 6: parity check failed\n");
4762 #endif // ANALYZE
4763 irmp_ir_detected = FALSE;
4764 }
4765
4766 if ((irmp_tmp_address & 0x03) == 0x02)
4767 {
4768 #ifdef ANALYZE
4769 ANALYZE_PRINTF ("code skipped: ORTEK end of transmission frame (key release)\n");
4770 #endif // ANALYZE
4771 irmp_ir_detected = FALSE;
4772 }
4773 irmp_tmp_address >>= 2;
4774 }
4775 #endif // IRMP_SUPPORT_ORTEK_PROTOCOL == 1
4776
4777 #if IRMP_SUPPORT_RC6_PROTOCOL == 1
4778 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode = 6?
4779 {
4780 irmp_protocol = IRMP_RC6A_PROTOCOL;
4781 }
4782 else
4783 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1
4784 {
4785 irmp_protocol = irmp_param.protocol;
4786 }
4787
4788 #if IRMP_SUPPORT_FDC_PROTOCOL == 1
4789 if (irmp_param.protocol == IRMP_FDC_PROTOCOL)
4790 {
4791 if (irmp_tmp_command & 0x000F) // released key?
4792 {
4793 irmp_tmp_command = (irmp_tmp_command >> 4) | 0x80; // yes, set bit 7
4794 }
4795 else
4796 {
4797 irmp_tmp_command >>= 4; // no, it's a pressed key
4798 }
4799 irmp_tmp_command |= (irmp_tmp_address << 2) & 0x0F00; // 000000CCCCAAAAAA -> 0000CCCC00000000
4800 irmp_tmp_address &= 0x003F;
4801 }
4802 #endif
4803
4804 irmp_address = irmp_tmp_address; // store address
4805 #if IRMP_SUPPORT_NEC_PROTOCOL == 1
4806 if (irmp_param.protocol == IRMP_NEC_PROTOCOL)
4807 {
4808 last_irmp_address = irmp_tmp_address; // store as last address, too
4809 }
4810 #endif
4811
4812 #if IRMP_SUPPORT_RC5_PROTOCOL == 1
4813 if (irmp_param.protocol == IRMP_RC5_PROTOCOL)
4814 {
4815 irmp_tmp_command |= rc5_cmd_bit6; // store bit 6
4816 }
4817 #endif
4818 #if IRMP_SUPPORT_S100_PROTOCOL == 1
4819 if (irmp_param.protocol == IRMP_S100_PROTOCOL)
4820 {
4821 irmp_tmp_command |= rc5_cmd_bit6; // store bit 6
4822 }
4823 #endif
4824 irmp_command = irmp_tmp_command; // store command
4825
4826 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1
4827 irmp_id = irmp_tmp_id;
4828 #endif
4829 }
4830 }
4831
4832 if (irmp_ir_detected)
4833 {
4834 if (last_irmp_command == irmp_tmp_command &&
4835 last_irmp_address == irmp_tmp_address &&
4836 key_repetition_len < IRMP_KEY_REPETITION_LEN)
4837 {
4838 irmp_flags |= IRMP_FLAG_REPETITION;
4839 }
4840
4841 last_irmp_address = irmp_tmp_address; // store as last address, too
4842 last_irmp_command = irmp_tmp_command; // store as last command, too
4843
4844 key_repetition_len = 0;
4845 }
4846 else
4847 {
4848 #ifdef ANALYZE
4849 ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');
4850 #endif // ANALYZE
4851 }
4852
4853 irmp_start_bit_detected = 0; // and wait for next start bit
4854 irmp_tmp_command = 0;
4855 irmp_pulse_time = 0;
4856 irmp_pause_time = 0;
4857
4858 #if IRMP_SUPPORT_JVC_PROTOCOL == 1
4859 if (irmp_protocol == IRMP_JVC_PROTOCOL) // the stop bit of JVC frame is also start bit of next frame
4860 { // set pulse time here!
4861 irmp_pulse_time = ((uint_fast8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME));
4862 }
4863 #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1
4864 }
4865 }
4866 }
4867
4868 #if defined(STELLARIS_ARM_CORTEX_M4)
4869 // Clear the timer interrupt
4870 TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
4871 #endif
4872
4873 return (irmp_ir_detected);
4874 }
4875
4876 #ifdef ANALYZE
4877
4878 /*---------------------------------------------------------------------------------------------------------------------------------------------------
4879 * main functions - for Unix/Linux + Windows only!
4880 *
4881 * AVR: see main.c!
4882 *
4883 * Compile it under linux with:
4884 * cc irmp.c -o irmp
4885 *
4886 * usage: ./irmp [-v|-s|-a|-l] < file
4887 *
4888 * options:
4889 * -v verbose
4890 * -s silent
4891 * -a analyze
4892 * -l list pulse/pauses
4893 *---------------------------------------------------------------------------------------------------------------------------------------------------
4894 */
4895
4896 void
4897 print_spectrum (char * text, int * buf, int is_pulse)
4898 {
4899 int i;
4900 int j;
4901 int min;
4902 int max;
4903 int max_value = 0;
4904 int value;
4905 int sum = 0;
4906 int counter = 0;
4907 double average = 0;
4908 double tolerance;
4909
4910 puts ("-----------------------------------------------------------------------------");
4911 printf ("%s:\n", text);
4912
4913 for (i = 0; i < 256; i++)
4914 {
4915 if (buf[i] > max_value)
4916 {
4917 max_value = buf[i];
4918 }
4919 }
4920
4921 for (i = 1; i < 200; i++)
4922 {
4923 if (buf[i] > 0)
4924 {
4925 printf ("%3d ", i);
4926 value = (buf[i] * 60) / max_value;
4927
4928 for (j = 0; j < value; j++)
4929 {
4930 putchar ('o');
4931 }
4932 printf (" %d\n", buf[i]);
4933
4934 sum += i * buf[i];
4935 counter += buf[i];
4936 }
4937 else
4938 {
4939 max = i - 1;
4940
4941 if (counter > 0)
4942 {
4943 average = (float) sum / (float) counter;
4944
4945 if (is_pulse)
4946 {
4947 printf ("pulse ");
4948 }
4949 else
4950 {
4951 printf ("pause ");
4952 }
4953
4954 printf ("avg: %4.1f=%6.1f us, ", average, (1000000. * average) / (float) F_INTERRUPTS);
4955 printf ("min: %2d=%6.1f us, ", min, (1000000. * min) / (float) F_INTERRUPTS);
4956 printf ("max: %2d=%6.1f us, ", max, (1000000. * max) / (float) F_INTERRUPTS);
4957
4958 tolerance = (max - average);
4959
4960 if (average - min > tolerance)
4961 {
4962 tolerance = average - min;
4963 }
4964
4965 tolerance = tolerance * 100 / average;
4966 printf ("tol: %4.1f%%\n", tolerance);
4967 }
4968
4969 counter = 0;
4970 sum = 0;
4971 min = i + 1;
4972 }
4973 }
4974 }
4975
4976 #define STATE_LEFT_SHIFT 0x01
4977 #define STATE_RIGHT_SHIFT 0x02
4978 #define STATE_LEFT_CTRL 0x04
4979 #define STATE_LEFT_ALT 0x08
4980 #define STATE_RIGHT_ALT 0x10
4981
4982 #define KEY_ESCAPE 0x1B // keycode = 0x006e
4983 #define KEY_MENUE 0x80 // keycode = 0x0070
4984 #define KEY_BACK 0x81 // keycode = 0x0071
4985 #define KEY_FORWARD 0x82 // keycode = 0x0072
4986 #define KEY_ADDRESS 0x83 // keycode = 0x0073
4987 #define KEY_WINDOW 0x84 // keycode = 0x0074
4988 #define KEY_1ST_PAGE 0x85 // keycode = 0x0075
4989 #define KEY_STOP 0x86 // keycode = 0x0076
4990 #define KEY_MAIL 0x87 // keycode = 0x0077
4991 #define KEY_FAVORITES 0x88 // keycode = 0x0078
4992 #define KEY_NEW_PAGE 0x89 // keycode = 0x0079
4993 #define KEY_SETUP 0x8A // keycode = 0x007a
4994 #define KEY_FONT 0x8B // keycode = 0x007b
4995 #define KEY_PRINT 0x8C // keycode = 0x007c
4996 #define KEY_ON_OFF 0x8E // keycode = 0x007c
4997
4998 #define KEY_INSERT 0x90 // keycode = 0x004b
4999 #define KEY_DELETE 0x91 // keycode = 0x004c
5000 #define KEY_LEFT 0x92 // keycode = 0x004f
5001 #define KEY_HOME 0x93 // keycode = 0x0050
5002 #define KEY_END 0x94 // keycode = 0x0051
5003 #define KEY_UP 0x95 // keycode = 0x0053
5004 #define KEY_DOWN 0x96 // keycode = 0x0054
5005 #define KEY_PAGE_UP 0x97 // keycode = 0x0055
5006 #define KEY_PAGE_DOWN 0x98 // keycode = 0x0056
5007 #define KEY_RIGHT 0x99 // keycode = 0x0059
5008 #define KEY_MOUSE_1 0x9E // keycode = 0x0400
5009 #define KEY_MOUSE_2 0x9F // keycode = 0x0800
5010
5011 static uint_fast8_t
5012 get_fdc_key (uint_fast16_t cmd)
5013 {
5014 static uint8_t key_table[128] =
5015 {
5016 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
5017 0, '^', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0xDF, '´', 0, '\b',
5018 '\t', 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 0xFC, '+', 0, 0, 'a',
5019 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 0xF6, 0xE4, '#', '\r', 0, '<', 'y', 'x',
5020 'c', 'v', 'b', 'n', 'm', ',', '.', '-', 0, 0, 0, 0, 0, ' ', 0, 0,
5021
5022 0, '°', '!', '"', '§', '$', '%', '&', '/', '(', ')', '=', '?', '`', 0, '\b',
5023 '\t', 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 0xDC, '*', 0, 0, 'A',
5024 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 0xD6, 0xC4, '\'', '\r', 0, '>', 'Y', 'X',
5025 'C', 'V', 'B', 'N', 'M', ';', ':', '_', 0, 0, 0, 0, 0, ' ', 0, 0
5026 };
5027 static uint_fast8_t state;
5028
5029 uint_fast8_t key = 0;
5030
5031 switch (cmd)
5032 {
5033 case 0x002C: state |= STATE_LEFT_SHIFT; break; // pressed left shift
5034 case 0x00AC: state &= ~STATE_LEFT_SHIFT; break; // released left shift
5035 case 0x0039: state |= STATE_RIGHT_SHIFT; break; // pressed right shift
5036 case 0x00B9: state &= ~STATE_RIGHT_SHIFT; break; // released right shift
5037 case 0x003A: state |= STATE_LEFT_CTRL; break; // pressed left ctrl
5038 case 0x00BA: state &= ~STATE_LEFT_CTRL; break; // released left ctrl
5039 case 0x003C: state |= STATE_LEFT_ALT; break; // pressed left alt
5040 case 0x00BC: state &= ~STATE_LEFT_ALT; break; // released left alt
5041 case 0x003E: state |= STATE_RIGHT_ALT; break; // pressed left alt
5042 case 0x00BE: state &= ~STATE_RIGHT_ALT; break; // released left alt
5043
5044 case 0x006e: key = KEY_ESCAPE; break;
5045 case 0x004b: key = KEY_INSERT; break;
5046 case 0x004c: key = KEY_DELETE; break;
5047 case 0x004f: key = KEY_LEFT; break;
5048 case 0x0050: key = KEY_HOME; break;
5049 case 0x0051: key = KEY_END; break;
5050 case 0x0053: key = KEY_UP; break;
5051 case 0x0054: key = KEY_DOWN; break;
5052 case 0x0055: key = KEY_PAGE_UP; break;
5053 case 0x0056: key = KEY_PAGE_DOWN; break;
5054 case 0x0059: key = KEY_RIGHT; break;
5055 case 0x0400: key = KEY_MOUSE_1; break;
5056 case 0x0800: key = KEY_MOUSE_2; break;
5057
5058 default:
5059 {
5060 if (!(cmd & 0x80)) // pressed key
5061 {
5062 if (cmd >= 0x70 && cmd <= 0x7F) // function keys
5063 {
5064 key = cmd + 0x10; // 7x -> 8x
5065 }
5066 else if (cmd < 64) // key listed in key_table
5067 {
5068 if (state & (STATE_LEFT_ALT | STATE_RIGHT_ALT))
5069 {
5070 switch (cmd)
5071 {
5072 case 0x0003: key = '²'; break;
5073 case 0x0008: key = '{'; break;
5074 case 0x0009: key = '['; break;
5075 case 0x000A: key = ']'; break;
5076 case 0x000B: key = '}'; break;
5077 case 0x000C: key = '\\'; break;
5078 case 0x001C: key = '~'; break;
5079 case 0x002D: key = '|'; break;
5080 case 0x0034: key = 0xB5; break; // Mu
5081 }
5082 }
5083 else if (state & (STATE_LEFT_CTRL))
5084 {
5085 if (key_table[cmd] >= 'a' && key_table[cmd] <= 'z')
5086 {
5087 key = key_table[cmd] - 'a' + 1;
5088 }
5089 else
5090 {
5091 key = key_table[cmd];
5092 }
5093 }
5094 else
5095 {
5096 int idx = cmd + ((state & (STATE_LEFT_SHIFT | STATE_RIGHT_SHIFT)) ? 64 : 0);
5097
5098 if (key_table[idx])
5099 {
5100 key = key_table[idx];
5101 }
5102 }
5103 }
5104 }
5105 break;
5106 }
5107 }
5108
5109 return (key);
5110 }
5111
5112 static int analyze = FALSE;
5113 static int list = FALSE;
5114 static IRMP_DATA irmp_data;
5115 static int expected_protocol;
5116 static int expected_address;
5117 static int expected_command;
5118 static int do_check_expected_values;
5119
5120 static void
5121 next_tick (void)
5122 {
5123 if (! analyze && ! list)
5124 {
5125 (void) irmp_ISR ();
5126
5127 if (irmp_get_data (&irmp_data))
5128 {
5129 uint_fast8_t key;
5130
5131 ANALYZE_ONLY_NORMAL_PUTCHAR (' ');
5132
5133 if (verbose)
5134 {
5135 printf ("%8.3fms ", (double) (time_counter * 1000) / F_INTERRUPTS);
5136 }
5137
5138 if (irmp_data.protocol == IRMP_ACP24_PROTOCOL)
5139 {
5140 uint16_t temp = (irmp_data.command & 0x000F) + 15;
5141
5142 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, temp=%d",
5143 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, temp);
5144 }
5145 else if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0)
5146 {
5147 if ((key >= 0x20 && key < 0x7F) || key >= 0xA0)
5148 {
5149 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key='%c'",
5150 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, key);
5151 }
5152 else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F)) // function keys
5153 {
5154 char * p = (char *) NULL;
5155
5156 switch (key)
5157 {
5158 case '\t' : p = "TAB"; break;
5159 case '\r' : p = "CR"; break;
5160 case KEY_ESCAPE : p = "ESCAPE"; break;
5161 case KEY_MENUE : p = "MENUE"; break;
5162 case KEY_BACK : p = "BACK"; break;
5163 case KEY_FORWARD : p = "FORWARD"; break;
5164 case KEY_ADDRESS : p = "ADDRESS"; break;
5165 case KEY_WINDOW : p = "WINDOW"; break;
5166 case KEY_1ST_PAGE : p = "1ST_PAGE"; break;
5167 case KEY_STOP : p = "STOP"; break;
5168 case KEY_MAIL : p = "MAIL"; break;
5169 case KEY_FAVORITES : p = "FAVORITES"; break;
5170 case KEY_NEW_PAGE : p = "NEW_PAGE"; break;
5171 case KEY_SETUP : p = "SETUP"; break;
5172 case KEY_FONT : p = "FONT"; break;
5173 case KEY_PRINT : p = "PRINT"; break;
5174 case KEY_ON_OFF : p = "ON_OFF"; break;
5175
5176 case KEY_INSERT : p = "INSERT"; break;
5177 case KEY_DELETE : p = "DELETE"; break;
5178 case KEY_LEFT : p = "LEFT"; break;
5179 case KEY_HOME : p = "HOME"; break;
5180 case KEY_END : p = "END"; break;
5181 case KEY_UP : p = "UP"; break;
5182 case KEY_DOWN : p = "DOWN"; break;
5183 case KEY_PAGE_UP : p = "PAGE_UP"; break;
5184 case KEY_PAGE_DOWN : p = "PAGE_DOWN"; break;
5185 case KEY_RIGHT : p = "RIGHT"; break;
5186 case KEY_MOUSE_1 : p = "KEY_MOUSE_1"; break;
5187 case KEY_MOUSE_2 : p = "KEY_MOUSE_2"; break;
5188 default : p = "<UNKNWON>"; break;
5189 }
5190
5191 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key=%s",
5192 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, p);
5193 }
5194 else
5195 {
5196 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x",
5197 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key);
5198 }
5199 }
5200 else
5201 {
5202 printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x",
5203 irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags);
5204 }
5205
5206 if (do_check_expected_values)
5207 {
5208 if (irmp_data.protocol != expected_protocol ||
5209 irmp_data.address != expected_address ||
5210 irmp_data.command != expected_command)
5211 {
5212 printf ("\nerror 7: expected values differ: p=%2d (%s), a=0x%04x, c=0x%04x\n",
5213 expected_protocol, irmp_protocol_names[expected_protocol], expected_address, expected_command);
5214 }
5215 else
5216 {
5217 printf (" checked!\n");
5218 }
5219 do_check_expected_values = FALSE; // only check 1st frame in a line!
5220 }
5221 else
5222 {
5223 putchar ('\n');
5224 }
5225 }
5226 }
5227 }
5228
5229 int
5230 main (int argc, char ** argv)
5231 {
5232 int i;
5233 int ch;
5234 int last_ch = 0;
5235 int pulse = 0;
5236 int pause = 0;
5237
5238 int start_pulses[256];
5239 int start_pauses[256];
5240 int pulses[256];
5241 int pauses[256];
5242
5243 int first_pulse = TRUE;
5244 int first_pause = TRUE;
5245
5246 if (argc == 2)
5247 {
5248 if (! strcmp (argv[1], "-v"))
5249 {
5250 verbose = TRUE;
5251 }
5252 else if (! strcmp (argv[1], "-l"))
5253 {
5254 list = TRUE;
5255 }
5256 else if (! strcmp (argv[1], "-a"))
5257 {
5258 analyze = TRUE;
5259 }
5260 else if (! strcmp (argv[1], "-s"))
5261 {
5262 silent = TRUE;
5263 }
5264 else if (! strcmp (argv[1], "-r"))
5265 {
5266 radio = TRUE;
5267 }
5268 }
5269
5270 for (i = 0; i < 256; i++)
5271 {
5272 start_pulses[i] = 0;
5273 start_pauses[i] = 0;
5274 pulses[i] = 0;
5275 pauses[i] = 0;
5276 }
5277
5278 IRMP_PIN = 0xFF;
5279
5280 while ((ch = getchar ()) != EOF)
5281 {
5282 if (ch == '_' || ch == '0')
5283 {
5284 if (last_ch != ch)
5285 {
5286 if (pause > 0)
5287 {
5288 if (list)
5289 {
5290 printf ("pause: %d\n", pause);
5291 }
5292
5293 if (analyze)
5294 {
5295 if (first_pause)
5296 {
5297 if (pause < 256)
5298 {
5299 start_pauses[pause]++;
5300 }
5301 first_pause = FALSE;
5302 }
5303 else
5304 {
5305 if (pause < 256)
5306 {
5307 pauses[pause]++;
5308 }
5309 }
5310 }
5311 }
5312 pause = 0;
5313 }
5314 pulse++;
5315 IRMP_PIN = 0x00;
5316 }
5317 else if (ch == 0xaf || ch == '-' || ch == '1')
5318 {
5319 if (last_ch != ch)
5320 {
5321 if (list)
5322 {
5323 printf ("pulse: %d ", pulse);
5324 }
5325
5326 if (analyze)
5327 {
5328 if (first_pulse)
5329 {
5330 if (pulse < 256)
5331 {
5332 start_pulses[pulse]++;
5333 }
5334 first_pulse = FALSE;
5335 }
5336 else
5337 {
5338 if (pulse < 256)
5339 {
5340 pulses[pulse]++;
5341 }
5342 }
5343 }
5344 pulse = 0;
5345 }
5346
5347 pause++;
5348 IRMP_PIN = 0xff;
5349 }
5350 else if (ch == '\n')
5351 {
5352 IRMP_PIN = 0xff;
5353 time_counter = 0;
5354
5355 if (list && pause > 0)
5356 {
5357 printf ("pause: %d\n", pause);
5358 }
5359 pause = 0;
5360
5361 if (! analyze)
5362 {
5363 for (i = 0; i < (int) ((10000.0 * F_INTERRUPTS) / 10000); i++) // newline: long pause of 10000 msec
5364 {
5365 next_tick ();
5366 }
5367 }
5368 first_pulse = TRUE;
5369 first_pause = TRUE;
5370 }
5371 else if (ch == '#')
5372 {
5373 time_counter = 0;
5374
5375 if (analyze)
5376 {
5377 while ((ch = getchar()) != '\n' && ch != EOF)
5378 {
5379 ;
5380 }
5381 }
5382 else
5383 {
5384 char buf[1024];
5385 char * p;
5386 int idx = -1;
5387
5388 puts ("----------------------------------------------------------------------");
5389 putchar (ch);
5390
5391
5392 while ((ch = getchar()) != '\n' && ch != EOF)
5393 {
5394 if (ch != '\r') // ignore CR in DOS/Windows files
5395 {
5396 if (ch == '[' && idx == -1)
5397 {
5398 idx = 0;
5399 }
5400 else if (idx >= 0)
5401 {
5402 if (ch == ']')
5403 {
5404 do_check_expected_values = FALSE;
5405 buf[idx] = '\0';
5406 idx = -1;
5407
5408 expected_protocol = atoi (buf);
5409
5410 if (expected_protocol > 0)
5411 {
5412 p = buf;
5413 while (*p)
5414 {
5415 if (*p == 'x')
5416 {
5417 p++;
5418
5419 if (sscanf (p, "%x", &expected_address) == 1)
5420 {
5421 do_check_expected_values = TRUE;
5422 }
5423 break;
5424 }
5425 p++;
5426 }
5427
5428 if (do_check_expected_values)
5429 {
5430 do_check_expected_values = FALSE;
5431
5432 while (*p)
5433 {
5434 if (*p == 'x')
5435 {
5436 p++;
5437
5438 if (sscanf (p, "%x", &expected_command) == 1)
5439 {
5440 do_check_expected_values = TRUE;
5441 }
5442 break;
5443 }
5444 p++;
5445 }
5446
5447 if (do_check_expected_values)
5448 {
5449 // printf ("!%2d %04x %04x!\n", expected_protocol, expected_address, expected_command);
5450 }
5451 }
5452 }
5453 }
5454 else if (idx < 1024 - 2)
5455 {
5456 buf[idx++] = ch;
5457 }
5458 }
5459 putchar (ch);
5460 }
5461 }
5462 putchar ('\n');
5463 }
5464
5465 }
5466
5467 last_ch = ch;
5468
5469 next_tick ();
5470 }
5471
5472 if (analyze)
5473 {
5474 print_spectrum ("START PULSES", start_pulses, TRUE);
5475 print_spectrum ("START PAUSES", start_pauses, FALSE);
5476 print_spectrum ("PULSES", pulses, TRUE);
5477 print_spectrum ("PAUSES", pauses, FALSE);
5478 puts ("-----------------------------------------------------------------------------");
5479 }
5480 return 0;
5481 }
5482
5483 #endif // ANALYZE