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