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