20 return (currentIndex +
size - 1) %
size;
28 return previousValue != currentValue;
31#if EFI_EMULATE_POSITION_SENSORS
33#if !EFI_SHAFT_POSITION_INPUT
34 fail(
"EFI_SHAFT_POSITION_INPUT required to have EFI_EMULATE_POSITION_SENSORS")
50#if EFI_SHAFT_POSITION_INPUT
51 for (
size_t i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) {
52 if (
needEvent(stateIndex, multiChannelStateSequence, i)) {
93 criticalError(
"We should not have reach this line");
98 criticalAssertVoid(rpm >= 0 && rpm <= 30000,
"emulator RPM out of range");
106 float rPerSecond = NAN;
110 rPerSecond = rpm * rpmM / 60.0;
117 efiPrintf(
"Emulating position sensor(s). RPM=%d", rpm);
131 state->safe.periodNt = -1;
157 *
state->multiChannelStateSequence,
185 for (
int cami = 0; cami < CAMS_PER_BANK; cami++) {
209 if (incGlobalConfiguration) {
262 }
else if (
channel == 1 && i == 0) {
275 if (isConfigurationChanged(triggerSimulatorPins[i])) {
291 if (isConfigurationChanged(triggerSimulatorPins[i])) {
const char * getEngine_type_e(engine_type_e value)
TriggerCentral triggerCentral
int getGlobalConfigurationVersion() const
SingleTimerExecutor scheduler
RpmCalculator rpmCalculator
void resetEngineSnifferIfInTestMode()
virtual operation_mode_e getOperationMode() const =0
virtual pin_state_t getChannelState(int channelIndex, int phaseIndex) const =0
Single output pin reference and state.
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Multi-channel software PWM output configuration.
OutputPin * outputPins[PWM_PHASE_MAX_WAVE_PER_PWM]
void weComplexInit(Scheduler *executor, MultiChannelStateSequence const *seq, pwm_cycle_callback *pwmCycleCallback, pwm_gen_callback *callback)
void setFrequency(float frequency)
TriggerWaveform vvtShape[CAMS_PER_BANK]
TriggerWaveform triggerShape
bool directSelfStimulation
void handleEmulatorCallback(int channel, const MultiChannelStateSequence &mcss, int stateIndex)
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
efitimems_t getTimeNowMs()
Returns the 32 bit number of milliseconds since the board initialization.
EngineRotationState * getEngineRotationState()
static EngineAccessor engine
void incrementGlobalConfigurationVersion(const char *msg)
static constexpr engine_configuration_s * engineConfiguration
bool isBrainPinValid(brain_pin_e brainPin)
void applyPinState(int stateIndex, PwmConfig *state)
void copyPwmParameters(PwmConfig *state, MultiChannelStateSequence const *seq)
@ FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR
@ FOUR_STROKE_TWELVE_TIMES_CRANK_SENSOR
@ FOUR_STROKE_THREE_TIMES_CRANK_SENSOR
@ FOUR_STROKE_CRANK_SENSOR
@ FOUR_STROKE_SIX_TIMES_CRANK_SENSOR
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")
Gpio triggerSimulatorPins[TRIGGER_SIMULATOR_PIN_COUNT]
bool invertSecondaryTriggerSignal
uint16_t triggerSimulatorRpm
pin_output_mode_e camSimulatorPinMode
bool invertPrimaryTriggerSignal
pin_output_mode_e triggerSimulatorPinModes[TRIGGER_SIMULATOR_PIN_COUNT]
int getCrankDivider(operation_mode_e operationMode)
void handleVvtCamSignal(TriggerValue front, efitick_t nowNt, int index)
void handleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp)
PwmConfig triggerEmulatorSignals[NUM_EMULATOR_CHANNELS]
void disableTriggerStimulator()
void setTriggerEmulatorRPM(int rpm)
static float getRpmMultiplier(operation_mode_e mode)
void startTriggerEmulatorPins()
void onConfigurationChangeRpmEmulatorCallback(engine_configuration_s *previousConfiguration)
void initTriggerEmulator()
static void emulatorApplyPinState(int stateIndex, PwmConfig *state)
void stopTriggerEmulatorPins()
void enableExternalTriggerStimulator()
static void updateTriggerWaveformIfNeeded(PwmConfig *state)
fail("EFI_SHAFT_POSITION_INPUT required to have EFI_EMULATE_POSITION_SENSORS") TriggerEmulatorHelper
int getPreviousIndex(const int currentIndex, const int size)
static TriggerEmulatorHelper helper
bool needEvent(const int currentIndex, const MultiChannelStateSequence &mcss, int channelIndex)
static OutputPin emulatorOutputs[NUM_EMULATOR_CHANNELS][PWM_PHASE_MAX_WAVE_PER_PWM]
PUBLIC_API_WEAK void onTriggerEmulatorPinState(int, int)
static int atTriggerVersions[NUM_EMULATOR_CHANNELS]
void enableTriggerStimulator(bool incGlobalConfiguration)
TriggerWaveform * triggerEmulatorWaveforms[NUM_EMULATOR_CHANNELS]
static bool hasInitTriggerEmulator
static void startSimulatedTriggerSignal()
bool needEvent(const int currentIndex, const MultiChannelStateSequence &mcss, int channelIndex)