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