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