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