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