rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
rotational_idle.cpp
Go to the documentation of this file.
1#include "pch.h"
2#include "rotational_idle.h"
3
7
10
12 return false;
13 }
14
15 //TODO: we need to use deadbands ond this!! (and on the tps/pps)
18 return true;
19 }
20
21 // TODO: auto_engage sounds too generic, maybe better auto_engage_pps_enable?
24 return true; // tps is below the maximum
25 }
26
27 return false;
28}
29
30static bool calculateSkip(uint32_t counter, uint8_t max, uint8_t adder) {
31 if (max == 0) {
32 return false;
33 }
34 return ((counter % max) + adder) >= max;
35}
36
37/**
38 * Determines whether to skip spark based on rotational idle skip pattern configuration.
39 *
40 * The skip pattern works using modulo arithmetic with configurable accumulators:
41 * - Each accumulator has: acc_max (pattern period), acc_adder (phase shift), acc_offset (cylinder offset)
42 * - For each accumulator: counter = globalSparkCounter + offset + acc_offset
43 * - Skip condition: ((counter % acc_max) + acc_adder) >= acc_max
44 *
45 * Example with acc_max=2, acc_adder=1, acc_offset=0:
46 * counter=0: (0 % 2) + 1 = 1 < 2 -> fire spark
47 * counter=1: (1 % 2) + 1 = 2 >= 2 -> skip spark
48 * counter=2: (2 % 2) + 1 = 1 < 2 -> fire spark
49 * counter=3: (3 % 2) + 1 = 2 >= 2 -> skip spark
50 *
51 * If acc_max=0, that accumulator is disabled and won't skip.
52 *
53 * @return True if should skip a spark event.
54 */
56 bool result = false;
58
59 if (cutMode == RotationalCutMode::Fuel) {
60 return false;
61 }
62
65 return false;
66 }
67
69
70
71 for (size_t i = 0; i < efi::size(engineConfiguration->rotationalIdleController.accumulators); i++){
73
74 uint32_t counter = engine->engineState.globalSparkCounter + accConfig.acc_offset;
75 result |= calculateSkip(counter, accConfig.acc_max, accConfig.acc_adder);
76 }
77
78 return result;
79}
EngineState engineState
Definition engine.h:352
bool shouldSkipSparkRotationalIdle()
bool shouldEngageRotationalIdle()
static float getOrZero(SensorType type)
Definition sensor.h:87
static EngineAccessor engine
Definition engine.h:415
static constexpr engine_configuration_s * engineConfiguration
static bool calculateSkip(uint32_t counter, uint8_t max, uint8_t adder)
@ DriverThrottleIntent