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