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