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