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