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