Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 9 | mjames | 1 | #include "libIgnTiming/edis.h" |
| 2 | |||
| 3 | extern "C" |
||
| 4 | |||
| 5 | { |
||
| 6 | // -10 degrees = 1792 uS |
||
| 7 | static int const MINUS_10_DEGREES_PULSE = 1792; |
||
| 8 | // 0 degrees = 1536 uS |
||
| 9 | static int const ZERO_DEGREES_PULSE = 1536; |
||
| 10 | // 60 degrees = 0 uS but limited to 64uS min = 57.5 degrees |
||
| 11 | static int const MAX_ADVANCE = 60; |
||
| 12 | static int const MAX_ADVANCE_PULSE = 64; |
||
| 13 | // add 2048 uS for multispark |
||
| 14 | static int const DOUBLE_PULSE = 2048; |
||
| 15 | |||
| 16 | int mapTimingToMicroseconds(int timing, unsigned char multispark) |
||
| 17 | { |
||
| 18 | int base = multispark ? DOUBLE_PULSE : 0; |
||
| 19 | |||
| 20 | int code = (MAX_ADVANCE * TIMING_SCALE - timing) * ZERO_DEGREES_PULSE / (MAX_ADVANCE * TIMING_SCALE); |
||
| 21 | if (code < MAX_ADVANCE_PULSE) |
||
| 22 | code = MAX_ADVANCE_PULSE; |
||
| 23 | if (code > MINUS_10_DEGREES_PULSE) |
||
| 24 | code = MINUS_10_DEGREES_PULSE; |
||
| 25 | return code + base; |
||
| 26 | } |
||
| 27 | } |