rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
start_stop.cpp
Go to the documentation of this file.
1#include "pch.h"
2
3/**
4 * See test_start_stop.cpp
5 */
6
7#include "start_stop.h"
9
10#if EFI_SHAFT_POSITION_INPUT
12 /* startCrankingDuration is efitimesec_t, so we need to multiply it by 1000 to get milliseconds*/
17}
18
20 bool wasStarterEngaged = enginePins.starterControl.getAndSet(1);
21 if (!wasStarterEngaged) {
23 efiPrintf("Let's crank this engine for up to %d seconds via %s!",
26 }
27}
28
38
41 // turn starter off once engine is now running!
42 bool wasStarterEngaged = enginePins.starterControl.getAndSet(0);
43 if (wasStarterEngaged) {
44 efiPrintf("Engine runs we can disengage the starter");
45 }
46 } else {
48 bool wasStarterEngaged = enginePins.starterControl.getAndSet(0);
49 if (wasStarterEngaged) {
50 efiPrintf("Cranking timeout %d seconds", engineConfiguration->startCrankingDuration);
51 }
52 }
53 }
54}
55
56PUBLIC_API_WEAK bool isCrankingSuppressed() {
57 return false;
58}
59
61 if (!isIgnVoltage()) {
62 // nothing to crank if we are powered only via USB
64 return;
65 } else if (engine->startStopState.isFirstTime) {
66 // initialize when first time with proper power
69 }
70
72 // where are odd cases of start button combined with ECU power source button we do not want to crank right on start
73 return;
74 }
75
78 return;
79 }
80
82 return;
83 }
84 }
85
87
89 // we are here on transition from 0 to 1
91 }
92 // todo: we shall extract start_stop.txt from engine_state.txt
95
96 bool isStarterEngaged = enginePins.starterControl.getLogicValue();
97
98 if (isStarterEngaged) {
100 }
101}
102#endif // EFI_SHAFT_POSITION_INPUT
bool readPinEvent()
void init(efitimems_t threshold, brain_pin_e &pin, pin_input_mode_e &mode, bool inverted=false)
Definition debounce.cpp:23
bool getPhysicalState()
EngineState engineState
Definition engine.h:327
SwitchedState brakePedalSwitchedState
Definition engine.h:199
RpmCalculator rpmCalculator
Definition engine.h:289
StartStopState startStopState
Definition engine.h:101
RegisteredOutputPin starterControl
Definition efi_gpio.h:82
bool getLogicValue() const
Definition efi_gpio.cpp:653
bool getAndSet(int logicValue)
Definition efi_gpio.cpp:561
bool isStopped() const override
bool isRunning() const
EnginePins enginePins
Definition efi_gpio.cpp:24
static Engine *const engine
Definition engine.h:386
static constexpr engine_configuration_s * engineConfiguration
bool isIgnVoltage()
const char * hwPortname(brain_pin_e brainPin)
startStopState("startStopState", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1304, 1.0, -1.0, -1.0, "")
void doScheduleStopEngine(StopRequestedReason reason)
static void onStartStopButtonToggle()
PUBLIC_API_WEAK bool isCrankingSuppressed()
static void disengageStarterIfNeeded()
void doStartCranking()
void slowStartStopButtonCallback()
void initStartStopButton()
Timer timeSinceIgnitionPower
Definition start_stop.h:7
ButtonDebounce startStopButtonDebounce
Definition start_stop.h:6
Timer startStopStateLastPush
Definition start_stop.h:8