FreeEMS  0.2.0-SNAPSHOT-282-g9efc524
MissingTeeth.h
Go to the documentation of this file.
1 /* FreeEMS - the open source engine management system
2  *
3  * Copyright 2011-2014 Fred Cooke
4  *
5  * This file is part of the FreeEMS project.
6  *
7  * FreeEMS software is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * FreeEMS software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
19  *
20  * We ask that if you make any changes to this file you email them upstream to
21  * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22  *
23  * Thank you for choosing FreeEMS to run your engine!
24  */
25 
26 
27 /** @file
28  *
29  * @ingroup allHeaders
30  * @ingroup interruptHandlers
31  * @ingroup enginePositionRPMDecoders
32  *
33  * @brief Missing teeth, M-N, with or without cam sync, configured externally
34  *
35  * This sets up the required arrays and defines such that the generic missing
36  * teeth decoder base can function in a specific way for the configured values.
37  *
38  * Choose one of these three options:
39  * - CRANK_ONLY
40  * - CAM_ONLY
41  * - CRANK_WITH_CAM_SYNC
42  *
43  * @note The above setting will affect the init routine. CRANK_WITH_CAM_SYNC is
44  * not currently supported.
45  *
46  * Define both of these values appropriately:
47  * - TOTAL_TEETH
48  * - MISSING_TEETH
49  *
50  * @note Please see the docs directory MissingTeethValidCombos.ods file first.
51  */
52 
53 
54 typedef struct {
55  unsigned lastPair: 4;
56  unsigned thisPair: 4;
57 } twoPairs;
58 
59 typedef union {
61  unsigned char pattern;
62 } match;
63 
64 
65 #define DECODER_MAX_CODE_TIME 250 // From Spudmn's measurements in NZ. 171us runtime was max = 214 ticks.
66 
67 #include "../../inc/freeEMS.h"
68 #include "../../inc/utils.h"
69 #include "../../inc/interrupts.h"
70 // See approximately 72 lines below for decoderInterface.h include
71 
72 
73 #ifndef TOTAL_TEETH
74 #error "Total number of teeth not defined!"
75 #endif
76 
77 #if (TOTAL_TEETH < 4)
78 #error "Total number of teeth must be greater than 4!"
79 #endif
80 
81 #ifndef MISSING_TEETH
82 #error "Number of missing teeth not defined!"
83 #endif
84 
85 #if (MISSING_TEETH < 1)
86 #error "Missing teeth must be greater than 0!"
87 #endif
88 
89 #if ((MISSING_TEETH * 3) > TOTAL_TEETH)
90 #error "Too many missing teeth! (or not enough total teeth!)"
91 #endif
92 
93 
94 #define NUMBER_OF_WHEEL_EVENTS (TOTAL_TEETH - MISSING_TEETH)
95 
96 
97 #if (NUMBER_OF_WHEEL_EVENTS > 64)
98 #error "Real events over 64 are currently not supported by this decoder style!"
99 #endif
100 
101 
102 #if ((defined(CRANK_ONLY) && defined(CAM_ONLY)) || (defined(CRANK_ONLY) && defined(CRANK_WITH_CAM_SYNC)) || (defined(CRANK_WITH_CAM_SYNC) && defined(CAM_ONLY)))
103 #error "Can not be cam and crank, choose one!"
104 #endif
105 
106 
107 #if defined(CRANK_ONLY)
108 #define CONFIGURED_SYNC CRANK_SYNC
109 #define NUMBER_OF_REAL_EVENTS NUMBER_OF_WHEEL_EVENTS
110 #define NUMBER_OF_VIRTUAL_EVENTS (2 * NUMBER_OF_REAL_EVENTS)
111 #define ANGLE_BETWEEN_EVENTS ((ANGLE_FACTOR * 360.0) / TOTAL_TEETH)
112 #define angleOfSingleIteration (360 * ANGLE_FACTOR)
113 #elif defined(CAM_ONLY)
114 #define CONFIGURED_SYNC CAM_SYNC
115 #define NUMBER_OF_REAL_EVENTS NUMBER_OF_WHEEL_EVENTS
116 #define NUMBER_OF_VIRTUAL_EVENTS NUMBER_OF_REAL_EVENTS
117 #define ANGLE_BETWEEN_EVENTS ((ANGLE_FACTOR * 720.0) / TOTAL_TEETH)
118 #define angleOfSingleIteration (720 * ANGLE_FACTOR)
119 #elif defined(CRANK_WITH_CAM_SYNC)
120 #define CONFIGURED_SYNC CAM_SYNC
121 #define NUMBER_OF_REAL_EVENTS (2 * NUMBER_OF_WHEEL_EVENTS)
122 #define NUMBER_OF_VIRTUAL_EVENTS NUMBER_OF_REAL_EVENTS
123 #define ANGLE_BETWEEN_EVENTS ((ANGLE_FACTOR * 360.0) / TOTAL_TEETH)
124 #define angleOfSingleIteration (720 * ANGLE_FACTOR)
125 #error "Not yet supported!" // And maybe done a different way, we'll see...
126 #else
127 #error "You MUST configure the style of this decoder!"
128 #endif
129 
130 
131 #include "../../inc/decoderInterface.h"
132 
133 
134 // For cam events, this is all that is used, for crank, this is the first half.
135 #define E0 0
136 #define E1 ANGLE_BETWEEN_EVENTS
137 #define E2 ( E1 + ANGLE_BETWEEN_EVENTS)
138 #define E3 ( E2 + ANGLE_BETWEEN_EVENTS)
139 #define E4 ( E3 + ANGLE_BETWEEN_EVENTS)
140 #define E5 ( E4 + ANGLE_BETWEEN_EVENTS)
141 #define E6 ( E5 + ANGLE_BETWEEN_EVENTS)
142 #define E7 ( E6 + ANGLE_BETWEEN_EVENTS)
143 #define E8 ( E7 + ANGLE_BETWEEN_EVENTS)
144 #define E9 ( E8 + ANGLE_BETWEEN_EVENTS)
145 #define E10 ( E9 + ANGLE_BETWEEN_EVENTS)
146 #define E11 ( E10 + ANGLE_BETWEEN_EVENTS)
147 #define E12 ( E11 + ANGLE_BETWEEN_EVENTS)
148 #define E13 ( E12 + ANGLE_BETWEEN_EVENTS)
149 #define E14 ( E13 + ANGLE_BETWEEN_EVENTS)
150 #define E15 ( E14 + ANGLE_BETWEEN_EVENTS)
151 #define E16 ( E15 + ANGLE_BETWEEN_EVENTS)
152 #define E17 ( E16 + ANGLE_BETWEEN_EVENTS)
153 #define E18 ( E17 + ANGLE_BETWEEN_EVENTS)
154 #define E19 ( E18 + ANGLE_BETWEEN_EVENTS)
155 #define E20 ( E19 + ANGLE_BETWEEN_EVENTS)
156 #define E21 ( E20 + ANGLE_BETWEEN_EVENTS)
157 #define E22 ( E21 + ANGLE_BETWEEN_EVENTS)
158 #define E23 ( E22 + ANGLE_BETWEEN_EVENTS)
159 #define E24 ( E23 + ANGLE_BETWEEN_EVENTS)
160 #define E25 ( E24 + ANGLE_BETWEEN_EVENTS)
161 #define E26 ( E25 + ANGLE_BETWEEN_EVENTS)
162 #define E27 ( E26 + ANGLE_BETWEEN_EVENTS)
163 #define E28 ( E27 + ANGLE_BETWEEN_EVENTS)
164 #define E29 ( E28 + ANGLE_BETWEEN_EVENTS)
165 #define E30 ( E29 + ANGLE_BETWEEN_EVENTS)
166 #define E31 ( E30 + ANGLE_BETWEEN_EVENTS)
167 #define E32 ( E31 + ANGLE_BETWEEN_EVENTS)
168 #define E33 ( E32 + ANGLE_BETWEEN_EVENTS)
169 #define E34 ( E33 + ANGLE_BETWEEN_EVENTS)
170 #define E35 ( E34 + ANGLE_BETWEEN_EVENTS)
171 #define E36 ( E35 + ANGLE_BETWEEN_EVENTS)
172 #define E37 ( E36 + ANGLE_BETWEEN_EVENTS)
173 #define E38 ( E37 + ANGLE_BETWEEN_EVENTS)
174 #define E39 ( E38 + ANGLE_BETWEEN_EVENTS)
175 #define E40 ( E39 + ANGLE_BETWEEN_EVENTS)
176 #define E41 ( E40 + ANGLE_BETWEEN_EVENTS)
177 #define E42 ( E41 + ANGLE_BETWEEN_EVENTS)
178 #define E43 ( E42 + ANGLE_BETWEEN_EVENTS)
179 #define E44 ( E43 + ANGLE_BETWEEN_EVENTS)
180 #define E45 ( E44 + ANGLE_BETWEEN_EVENTS)
181 #define E46 ( E45 + ANGLE_BETWEEN_EVENTS)
182 #define E47 ( E46 + ANGLE_BETWEEN_EVENTS)
183 #define E48 ( E47 + ANGLE_BETWEEN_EVENTS)
184 #define E49 ( E48 + ANGLE_BETWEEN_EVENTS)
185 #define E50 ( E49 + ANGLE_BETWEEN_EVENTS)
186 #define E51 ( E50 + ANGLE_BETWEEN_EVENTS)
187 #define E52 ( E51 + ANGLE_BETWEEN_EVENTS)
188 #define E53 ( E52 + ANGLE_BETWEEN_EVENTS)
189 #define E54 ( E53 + ANGLE_BETWEEN_EVENTS)
190 #define E55 ( E54 + ANGLE_BETWEEN_EVENTS)
191 #define E56 ( E55 + ANGLE_BETWEEN_EVENTS)
192 #define E57 ( E56 + ANGLE_BETWEEN_EVENTS)
193 #define E58 ( E57 + ANGLE_BETWEEN_EVENTS)
194 #define E59 ( E58 + ANGLE_BETWEEN_EVENTS)
195 #define E60 ( E59 + ANGLE_BETWEEN_EVENTS)
196 #define E61 ( E60 + ANGLE_BETWEEN_EVENTS)
197 #define E62 ( E61 + ANGLE_BETWEEN_EVENTS)
198 #define E63 ( E62 + ANGLE_BETWEEN_EVENTS)
199 
200 
201 // For crank speed wheels we need a second set of events offset 360 degrees from the first set. With a cam sync, they are real, without, only virtual.
202 #define E0_2 ((ANGLE_FACTOR * 360.0) + E0)
203 #define E1_2 ((ANGLE_FACTOR * 360.0) + E1)
204 #define E2_2 ((ANGLE_FACTOR * 360.0) + E2)
205 #define E3_2 ((ANGLE_FACTOR * 360.0) + E3)
206 #define E4_2 ((ANGLE_FACTOR * 360.0) + E4)
207 #define E5_2 ((ANGLE_FACTOR * 360.0) + E5)
208 #define E6_2 ((ANGLE_FACTOR * 360.0) + E6)
209 #define E7_2 ((ANGLE_FACTOR * 360.0) + E7)
210 #define E8_2 ((ANGLE_FACTOR * 360.0) + E8)
211 #define E9_2 ((ANGLE_FACTOR * 360.0) + E9)
212 #define E10_2 ((ANGLE_FACTOR * 360.0) + E10)
213 #define E11_2 ((ANGLE_FACTOR * 360.0) + E11)
214 #define E12_2 ((ANGLE_FACTOR * 360.0) + E12)
215 #define E13_2 ((ANGLE_FACTOR * 360.0) + E13)
216 #define E14_2 ((ANGLE_FACTOR * 360.0) + E14)
217 #define E15_2 ((ANGLE_FACTOR * 360.0) + E15)
218 #define E16_2 ((ANGLE_FACTOR * 360.0) + E16)
219 #define E17_2 ((ANGLE_FACTOR * 360.0) + E17)
220 #define E18_2 ((ANGLE_FACTOR * 360.0) + E18)
221 #define E19_2 ((ANGLE_FACTOR * 360.0) + E19)
222 #define E20_2 ((ANGLE_FACTOR * 360.0) + E20)
223 #define E21_2 ((ANGLE_FACTOR * 360.0) + E21)
224 #define E22_2 ((ANGLE_FACTOR * 360.0) + E22)
225 #define E23_2 ((ANGLE_FACTOR * 360.0) + E23)
226 #define E24_2 ((ANGLE_FACTOR * 360.0) + E24)
227 #define E25_2 ((ANGLE_FACTOR * 360.0) + E25)
228 #define E26_2 ((ANGLE_FACTOR * 360.0) + E26)
229 #define E27_2 ((ANGLE_FACTOR * 360.0) + E27)
230 #define E28_2 ((ANGLE_FACTOR * 360.0) + E28)
231 #define E29_2 ((ANGLE_FACTOR * 360.0) + E29)
232 #define E30_2 ((ANGLE_FACTOR * 360.0) + E30)
233 #define E31_2 ((ANGLE_FACTOR * 360.0) + E31)
234 #define E32_2 ((ANGLE_FACTOR * 360.0) + E32)
235 #define E33_2 ((ANGLE_FACTOR * 360.0) + E33)
236 #define E34_2 ((ANGLE_FACTOR * 360.0) + E34)
237 #define E35_2 ((ANGLE_FACTOR * 360.0) + E35)
238 #define E36_2 ((ANGLE_FACTOR * 360.0) + E36)
239 #define E37_2 ((ANGLE_FACTOR * 360.0) + E37)
240 #define E38_2 ((ANGLE_FACTOR * 360.0) + E38)
241 #define E39_2 ((ANGLE_FACTOR * 360.0) + E39)
242 #define E40_2 ((ANGLE_FACTOR * 360.0) + E40)
243 #define E41_2 ((ANGLE_FACTOR * 360.0) + E41)
244 #define E42_2 ((ANGLE_FACTOR * 360.0) + E42)
245 #define E43_2 ((ANGLE_FACTOR * 360.0) + E43)
246 #define E44_2 ((ANGLE_FACTOR * 360.0) + E44)
247 #define E45_2 ((ANGLE_FACTOR * 360.0) + E45)
248 #define E46_2 ((ANGLE_FACTOR * 360.0) + E46)
249 #define E47_2 ((ANGLE_FACTOR * 360.0) + E47)
250 #define E48_2 ((ANGLE_FACTOR * 360.0) + E48)
251 #define E49_2 ((ANGLE_FACTOR * 360.0) + E49)
252 #define E50_2 ((ANGLE_FACTOR * 360.0) + E50)
253 #define E51_2 ((ANGLE_FACTOR * 360.0) + E51)
254 #define E52_2 ((ANGLE_FACTOR * 360.0) + E52)
255 #define E53_2 ((ANGLE_FACTOR * 360.0) + E53)
256 #define E54_2 ((ANGLE_FACTOR * 360.0) + E54)
257 #define E55_2 ((ANGLE_FACTOR * 360.0) + E55)
258 #define E56_2 ((ANGLE_FACTOR * 360.0) + E56)
259 #define E57_2 ((ANGLE_FACTOR * 360.0) + E57)
260 #define E58_2 ((ANGLE_FACTOR * 360.0) + E58)
261 #define E59_2 ((ANGLE_FACTOR * 360.0) + E59)
262 #define E60_2 ((ANGLE_FACTOR * 360.0) + E60)
263 #define E61_2 ((ANGLE_FACTOR * 360.0) + E61)
264 #define E62_2 ((ANGLE_FACTOR * 360.0) + E62)
265 #define E63_2 ((ANGLE_FACTOR * 360.0) + E63)
266 
267 
268 const unsigned short eventAngles[] = {
269 E0 // Always this event...
270 
271 #if (NUMBER_OF_WHEEL_EVENTS > 1)
272 ,E1
273 #if (NUMBER_OF_WHEEL_EVENTS > 2)
274 ,E2
275 #if (NUMBER_OF_WHEEL_EVENTS > 3)
276 ,E3
277 #if (NUMBER_OF_WHEEL_EVENTS > 4)
278 ,E4
279 #if (NUMBER_OF_WHEEL_EVENTS > 5)
280 ,E5
281 #if (NUMBER_OF_WHEEL_EVENTS > 6)
282 ,E6
283 #if (NUMBER_OF_WHEEL_EVENTS > 7)
284 ,E7
285 #if (NUMBER_OF_WHEEL_EVENTS > 8)
286 ,E8
287 #if (NUMBER_OF_WHEEL_EVENTS > 9)
288 ,E9
289 #if (NUMBER_OF_WHEEL_EVENTS > 10)
290 ,E10
291 #if (NUMBER_OF_WHEEL_EVENTS > 11)
292 ,E11
293 #if (NUMBER_OF_WHEEL_EVENTS > 12)
294 ,E12
295 #if (NUMBER_OF_WHEEL_EVENTS > 13)
296 ,E13
297 #if (NUMBER_OF_WHEEL_EVENTS > 14)
298 ,E14
299 #if (NUMBER_OF_WHEEL_EVENTS > 15)
300 ,E15
301 #if (NUMBER_OF_WHEEL_EVENTS > 16)
302 ,E16
303 #if (NUMBER_OF_WHEEL_EVENTS > 17)
304 ,E17
305 #if (NUMBER_OF_WHEEL_EVENTS > 18)
306 ,E18
307 #if (NUMBER_OF_WHEEL_EVENTS > 19)
308 ,E19
309 #if (NUMBER_OF_WHEEL_EVENTS > 20)
310 ,E20
311 #if (NUMBER_OF_WHEEL_EVENTS > 21)
312 ,E21
313 #if (NUMBER_OF_WHEEL_EVENTS > 22)
314 ,E22
315 #if (NUMBER_OF_WHEEL_EVENTS > 23)
316 ,E23
317 #if (NUMBER_OF_WHEEL_EVENTS > 24)
318 ,E24
319 #if (NUMBER_OF_WHEEL_EVENTS > 25)
320 ,E25
321 #if (NUMBER_OF_WHEEL_EVENTS > 26)
322 ,E26
323 #if (NUMBER_OF_WHEEL_EVENTS > 27)
324 ,E27
325 #if (NUMBER_OF_WHEEL_EVENTS > 28)
326 ,E28
327 #if (NUMBER_OF_WHEEL_EVENTS > 29)
328 ,E29
329 #if (NUMBER_OF_WHEEL_EVENTS > 30)
330 ,E30
331 #if (NUMBER_OF_WHEEL_EVENTS > 31)
332 ,E31
333 #if (NUMBER_OF_WHEEL_EVENTS > 32)
334 ,E32
335 #if (NUMBER_OF_WHEEL_EVENTS > 33)
336 ,E33
337 #if (NUMBER_OF_WHEEL_EVENTS > 34)
338 ,E34
339 #if (NUMBER_OF_WHEEL_EVENTS > 35)
340 ,E35
341 #if (NUMBER_OF_WHEEL_EVENTS > 36)
342 ,E36
343 #if (NUMBER_OF_WHEEL_EVENTS > 37)
344 ,E37
345 #if (NUMBER_OF_WHEEL_EVENTS > 38)
346 ,E38
347 #if (NUMBER_OF_WHEEL_EVENTS > 39)
348 ,E39
349 #if (NUMBER_OF_WHEEL_EVENTS > 40)
350 ,E40
351 #if (NUMBER_OF_WHEEL_EVENTS > 41)
352 ,E41
353 #if (NUMBER_OF_WHEEL_EVENTS > 42)
354 ,E42
355 #if (NUMBER_OF_WHEEL_EVENTS > 43)
356 ,E43
357 #if (NUMBER_OF_WHEEL_EVENTS > 44)
358 ,E44
359 #if (NUMBER_OF_WHEEL_EVENTS > 45)
360 ,E45
361 #if (NUMBER_OF_WHEEL_EVENTS > 46)
362 ,E46
363 #if (NUMBER_OF_WHEEL_EVENTS > 47)
364 ,E47
365 #if (NUMBER_OF_WHEEL_EVENTS > 48)
366 ,E48
367 #if (NUMBER_OF_WHEEL_EVENTS > 49)
368 ,E49
369 #if (NUMBER_OF_WHEEL_EVENTS > 50)
370 ,E50
371 #if (NUMBER_OF_WHEEL_EVENTS > 51)
372 ,E51
373 #if (NUMBER_OF_WHEEL_EVENTS > 52)
374 ,E52
375 #if (NUMBER_OF_WHEEL_EVENTS > 53)
376 ,E53
377 #if (NUMBER_OF_WHEEL_EVENTS > 54)
378 ,E54
379 #if (NUMBER_OF_WHEEL_EVENTS > 55)
380 ,E55
381 #if (NUMBER_OF_WHEEL_EVENTS > 56)
382 ,E56
383 #if (NUMBER_OF_WHEEL_EVENTS > 57)
384 ,E57
385 #if (NUMBER_OF_WHEEL_EVENTS > 58)
386 ,E58
387 #if (NUMBER_OF_WHEEL_EVENTS > 59)
388 ,E59
389 #if (NUMBER_OF_WHEEL_EVENTS > 60)
390 ,E60
391 #if (NUMBER_OF_WHEEL_EVENTS > 61)
392 ,E61
393 #if (NUMBER_OF_WHEEL_EVENTS > 62)
394 ,E62
395 #if (NUMBER_OF_WHEEL_EVENTS > 63)
396 ,E63
397 #endif
398 #endif
399 #endif
400 #endif
401 #endif
402 #endif
403 #endif
404 #endif
405 #endif
406 #endif
407 #endif
408 #endif
409 #endif
410 #endif
411 #endif
412 #endif
413 #endif
414 #endif
415 #endif
416 #endif
417 #endif
418 #endif
419 #endif
420 #endif
421 #endif
422 #endif
423 #endif
424 #endif
425 #endif
426 #endif
427 #endif
428 #endif
429 #endif
430 #endif
431 #endif
432 #endif
433 #endif
434 #endif
435 #endif
436 #endif
437 #endif
438 #endif
439 #endif
440 #endif
441 #endif
442 #endif
443 #endif
444 #endif
445 #endif
446 #endif
447 #endif
448 #endif
449 #endif
450 #endif
451 #endif
452 #endif
453 #endif
454 #endif
455 #endif
456 #endif
457 #endif
458 #endif
459 #endif
460 
461 
462 // If the missing tooth wheel is on the camshaft, it represents a full 720
463 // degree cycle and duplicating the events with 360 offset is not necessary.
464 #ifndef CAM_ONLY
465 ,E0_2
466 #if (NUMBER_OF_WHEEL_EVENTS > 1)
467 ,E1_2
468 #if (NUMBER_OF_WHEEL_EVENTS > 2)
469 ,E2_2
470 #if (NUMBER_OF_WHEEL_EVENTS > 3)
471 ,E3_2
472 #if (NUMBER_OF_WHEEL_EVENTS > 4)
473 ,E4_2
474 #if (NUMBER_OF_WHEEL_EVENTS > 5)
475 ,E5_2
476 #if (NUMBER_OF_WHEEL_EVENTS > 6)
477 ,E6_2
478 #if (NUMBER_OF_WHEEL_EVENTS > 7)
479 ,E7_2
480 #if (NUMBER_OF_WHEEL_EVENTS > 8)
481 ,E8_2
482 #if (NUMBER_OF_WHEEL_EVENTS > 9)
483 ,E9_2
484 #if (NUMBER_OF_WHEEL_EVENTS > 10)
485 ,E10_2
486 #if (NUMBER_OF_WHEEL_EVENTS > 11)
487 ,E11_2
488 #if (NUMBER_OF_WHEEL_EVENTS > 12)
489 ,E12_2
490 #if (NUMBER_OF_WHEEL_EVENTS > 13)
491 ,E13_2
492 #if (NUMBER_OF_WHEEL_EVENTS > 14)
493 ,E14_2
494 #if (NUMBER_OF_WHEEL_EVENTS > 15)
495 ,E15_2
496 #if (NUMBER_OF_WHEEL_EVENTS > 16)
497 ,E16_2
498 #if (NUMBER_OF_WHEEL_EVENTS > 17)
499 ,E17_2
500 #if (NUMBER_OF_WHEEL_EVENTS > 18)
501 ,E18_2
502 #if (NUMBER_OF_WHEEL_EVENTS > 19)
503 ,E19_2
504 #if (NUMBER_OF_WHEEL_EVENTS > 20)
505 ,E20_2
506 #if (NUMBER_OF_WHEEL_EVENTS > 21)
507 ,E21_2
508 #if (NUMBER_OF_WHEEL_EVENTS > 22)
509 ,E22_2
510 #if (NUMBER_OF_WHEEL_EVENTS > 23)
511 ,E23_2
512 #if (NUMBER_OF_WHEEL_EVENTS > 24)
513 ,E24_2
514 #if (NUMBER_OF_WHEEL_EVENTS > 25)
515 ,E25_2
516 #if (NUMBER_OF_WHEEL_EVENTS > 26)
517 ,E26_2
518 #if (NUMBER_OF_WHEEL_EVENTS > 27)
519 ,E27_2
520 #if (NUMBER_OF_WHEEL_EVENTS > 28)
521 ,E28_2
522 #if (NUMBER_OF_WHEEL_EVENTS > 29)
523 ,E29_2
524 #if (NUMBER_OF_WHEEL_EVENTS > 30)
525 ,E30_2
526 #if (NUMBER_OF_WHEEL_EVENTS > 31)
527 ,E31_2
528 #if (NUMBER_OF_WHEEL_EVENTS > 32)
529 ,E32_2
530 #if (NUMBER_OF_WHEEL_EVENTS > 33)
531 ,E33_2
532 #if (NUMBER_OF_WHEEL_EVENTS > 34)
533 ,E34_2
534 #if (NUMBER_OF_WHEEL_EVENTS > 35)
535 ,E35_2
536 #if (NUMBER_OF_WHEEL_EVENTS > 36)
537 ,E36_2
538 #if (NUMBER_OF_WHEEL_EVENTS > 37)
539 ,E37_2
540 #if (NUMBER_OF_WHEEL_EVENTS > 38)
541 ,E38_2
542 #if (NUMBER_OF_WHEEL_EVENTS > 39)
543 ,E39_2
544 #if (NUMBER_OF_WHEEL_EVENTS > 40)
545 ,E40_2
546 #if (NUMBER_OF_WHEEL_EVENTS > 41)
547 ,E41_2
548 #if (NUMBER_OF_WHEEL_EVENTS > 42)
549 ,E42_2
550 #if (NUMBER_OF_WHEEL_EVENTS > 43)
551 ,E43_2
552 #if (NUMBER_OF_WHEEL_EVENTS > 44)
553 ,E44_2
554 #if (NUMBER_OF_WHEEL_EVENTS > 45)
555 ,E45_2
556 #if (NUMBER_OF_WHEEL_EVENTS > 46)
557 ,E46_2
558 #if (NUMBER_OF_WHEEL_EVENTS > 47)
559 ,E47_2
560 #if (NUMBER_OF_WHEEL_EVENTS > 48)
561 ,E48_2
562 #if (NUMBER_OF_WHEEL_EVENTS > 49)
563 ,E49_2
564 #if (NUMBER_OF_WHEEL_EVENTS > 50)
565 ,E50_2
566 #if (NUMBER_OF_WHEEL_EVENTS > 51)
567 ,E51_2
568 #if (NUMBER_OF_WHEEL_EVENTS > 52)
569 ,E52_2
570 #if (NUMBER_OF_WHEEL_EVENTS > 53)
571 ,E53_2
572 #if (NUMBER_OF_WHEEL_EVENTS > 54)
573 ,E54_2
574 #if (NUMBER_OF_WHEEL_EVENTS > 55)
575 ,E55_2
576 #if (NUMBER_OF_WHEEL_EVENTS > 56)
577 ,E56_2
578 #if (NUMBER_OF_WHEEL_EVENTS > 57)
579 ,E57_2
580 #if (NUMBER_OF_WHEEL_EVENTS > 58)
581 ,E58_2
582 #if (NUMBER_OF_WHEEL_EVENTS > 59)
583 ,E59_2
584 #if (NUMBER_OF_WHEEL_EVENTS > 60)
585 ,E60_2
586 #if (NUMBER_OF_WHEEL_EVENTS > 61)
587 ,E61_2
588 #if (NUMBER_OF_WHEEL_EVENTS > 62)
589 ,E62_2
590 #if (NUMBER_OF_WHEEL_EVENTS > 63)
591 ,E63_2
592 #endif
593 #endif
594 #endif
595 #endif
596 #endif
597 #endif
598 #endif
599 #endif
600 #endif
601 #endif
602 #endif
603 #endif
604 #endif
605 #endif
606 #endif
607 #endif
608 #endif
609 #endif
610 #endif
611 #endif
612 #endif
613 #endif
614 #endif
615 #endif
616 #endif
617 #endif
618 #endif
619 #endif
620 #endif
621 #endif
622 #endif
623 #endif
624 #endif
625 #endif
626 #endif
627 #endif
628 #endif
629 #endif
630 #endif
631 #endif
632 #endif
633 #endif
634 #endif
635 #endif
636 #endif
637 #endif
638 #endif
639 #endif
640 #endif
641 #endif
642 #endif
643 #endif
644 #endif
645 #endif
646 #endif
647 #endif
648 #endif
649 #endif
650 #endif
651 #endif
652 #endif
653 #endif
654 #endif
655 #endif
656 
657 };
658 
659 
660 /// @todo TODO build this with similar hash if logic: need to reconsider how to use this or whether to even have it. A "corresponding event" table might be good instead, kinda like the mapping above, but from real to real, only when the angles are exactly 360 out.
661 const unsigned char eventValidForCrankSync[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; // this is only correct while doing pure crank sync, wrong once doing more, i think, TBC...