rusEFI
The most advanced open source ECU
Functions
start_stop.cpp File Reference

Functions

void initStartStopButton ()
 
static void onStartStopButtonToggle ()
 
static void disengageStarterIfNeeded ()
 
PUBLIC_API_WEAK bool isCrankingSuppressed ()
 
void slowStartStopButtonCallback ()
 

Function Documentation

◆ disengageStarterIfNeeded()

static void disengageStarterIfNeeded ( )
static

Definition at line 35 of file start_stop.cpp.

35  {
37  // turn starter off once engine is now running!
38  bool wasStarterEngaged = enginePins.starterControl.getAndSet(0);
39  if (wasStarterEngaged) {
40  efiPrintf("Engine runs we can disengage the starter");
41  }
42  } else {
44  bool wasStarterEngaged = enginePins.starterControl.getAndSet(0);
45  if (wasStarterEngaged) {
46  efiPrintf("Cranking timeout %d seconds", engineConfiguration->startCrankingDuration);
47  }
48  }
49  }
50 }
RpmCalculator rpmCalculator
Definition: engine.h:274
StartStopState startStopState
Definition: engine.h:94
RegisteredOutputPin starterControl
Definition: efi_gpio.h:82
bool getAndSet(int logicValue)
Definition: efi_gpio.cpp:559
bool isRunning() const
EnginePins enginePins
Definition: efi_gpio.cpp:24
Engine * engine
engine_configuration_s * engineConfiguration
Timer startStopStateLastPush
Definition: start_stop.h:8

Referenced by slowStartStopButtonCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initStartStopButton()

void initStartStopButton ( )

See test_start_stop.cpp

Definition at line 11 of file start_stop.cpp.

11  {
12  /* startCrankingDuration is efitimesec_t, so we need to multiply it by 1000 to get milliseconds*/
17 }
void init(efitimems_t threshold, brain_pin_e &pin, pin_input_mode_e &mode, bool inverted=false)
Definition: debounce.cpp:23
ButtonDebounce startStopButtonDebounce
Definition: start_stop.h:6

Referenced by startHardware().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCrankingSuppressed()

PUBLIC_API_WEAK bool isCrankingSuppressed ( )

Definition at line 52 of file start_stop.cpp.

52  {
53  return false;
54 }

Referenced by slowStartStopButtonCallback().

Here is the caller graph for this function:

◆ onStartStopButtonToggle()

static void onStartStopButtonToggle ( )
static

Definition at line 19 of file start_stop.cpp.

19  {
21 
23  bool wasStarterEngaged = enginePins.starterControl.getAndSet(1);
24  if (!wasStarterEngaged) {
26  efiPrintf("Let's crank this engine for up to %d seconds via %s!",
29  }
30  } else if (engine->rpmCalculator.isRunning()) {
32  }
33 }
EngineState engineState
Definition: engine.h:311
bool isStopped() const override
const char * hwPortname(brain_pin_e brainPin)
void doScheduleStopEngine()
uint32_t startStopStateToggleCounter

Referenced by slowStartStopButtonCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ slowStartStopButtonCallback()

void slowStartStopButtonCallback ( )

Definition at line 56 of file start_stop.cpp.

56  {
57  if (!isIgnVoltage()) {
58  // nothing to crank if we are powered only via USB
60  return;
61  } else if (engine->startStopState.isFirstTime) {
62  // initialize when first time with proper power
65  }
66 
68  // where are odd cases of start button combined with ECU power source button we do not want to crank right on start
69  return;
70  }
71 
74  return;
75  }
76 
77  if (isCrankingSuppressed()) {
78  return;
79  }
80  }
81 
83 
85  // we are here on transition from 0 to 1
87  }
88  // todo: we shall extract start_stop.txt from engine_state.txt
91 
92  bool isStarterEngaged = enginePins.starterControl.getLogicValue();
93 
94  if (isStarterEngaged) {
96  }
97 }
bool readPinEvent()
bool getPhysicalState()
SwitchedState brakePedalSwitchedState
Definition: engine.h:188
bool getLogicValue() const
Definition: efi_gpio.cpp:652
bool isIgnVoltage()
startStopState("startStopState", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1165, 1.0, -1.0, -1.0, "")
static void onStartStopButtonToggle()
Definition: start_stop.cpp:19
PUBLIC_API_WEAK bool isCrankingSuppressed()
Definition: start_stop.cpp:52
static void disengageStarterIfNeeded()
Definition: start_stop.cpp:35
Timer timeSinceIgnitionPower
Definition: start_stop.h:7
bool isFirstTime
Definition: start_stop.h:10

Referenced by doPeriodicSlowCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.