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