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