Merge remote-tracking branch 'origin/master' into master

This commit is contained in:
rusefi 2020-09-09 08:58:54 -04:00
commit 38c4794ef0
8 changed files with 29 additions and 42 deletions

View File

@ -222,7 +222,6 @@ public:
bool startStopState = false;
efitick_t startStopStateLastPushTime = 0;
int startStopStateToggleCounter = 0;
/**

View File

@ -50,6 +50,7 @@ CONTROLLERS_SRC_CPP = \
$(CONTROLLERS_DIR)/serial/serial_sensor.cpp \
$(CONTROLLERS_DIR)/buttonshift.cpp \
$(CONTROLLERS_DIR)/tcu.cpp \
$(CONTROLLERS_DIR)/start_stop.cpp \
CONTROLLERS_INC=\
$(CONTROLLERS_DIR) \

View File

@ -58,6 +58,7 @@
#include "gppwm.h"
#include "date_stamp.h"
#include "buttonshift.h"
#include "start_stop.h"
#if EFI_SENSOR_CHART
#include "sensor_chart.h"
@ -591,6 +592,8 @@ void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S
initButtonShift(PASS_ENGINE_PARAMETER_SIGNATURE);
initStartStopButton(PASS_ENGINE_PARAMETER_SIGNATURE);
#if EFI_ELECTRONIC_THROTTLE_BODY
initElectronicThrottle(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */

View File

@ -14,6 +14,7 @@ char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *bu
void initPeriodicEvents(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
void initStartStopButton(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void initDataStructures(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void touchTimeCounter();

View File

@ -13,6 +13,7 @@
EXTERN_ENGINE;
extern LoggingWithStorage sharedLogger;
extern ButtonDebounce startStopButtonDebounce;
#if ENABLE_PERF_TRACE
static uint8_t nextThreadId = 0;
@ -154,9 +155,7 @@ void touchTimeCounter() {
static void onStartStopButtonToggle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engine->startStopStateToggleCounter++;
if (engine->rpmCalculator.isStopped()) {
engine->startStopStateLastPushTime = getTimeNowNt();
if (engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) {
bool wasStarterEngaged = enginePins.starterControl.getAndSet(1);
if (!wasStarterEngaged) {
scheduleMsg(&sharedLogger, "Let's crank this engine for up to %dseconds!", CONFIG(startCrankingDuration));
@ -167,29 +166,16 @@ static void onStartStopButtonToggle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
}
}
static bool isFirstStartStopCallback = true;
void slowStartStopButtonCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (CONFIG(startStopButtonPin) != GPIO_UNASSIGNED) {
#if EFI_PROD_CODE
bool startStopState = efiReadPin(CONFIG(startStopButtonPin));
bool startStopState = startStopButtonDebounce.readPinEvent();
if (isFirstStartStopCallback) {
// we just remember initial value on first callback and do not react to it
isFirstStartStopCallback = false;
} else if (startStopState && !engine->startStopState) {
// we are here on transition from 0 to 1
onStartStopButtonToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
}
engine->startStopState = startStopState;
if (startStopState && !engine->startStopState) {
// we are here on transition from 0 to 1
onStartStopButtonToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
}
engine->startStopState = startStopState;
#endif /* EFI_PROD_CODE */
}
if (engine->startStopStateLastPushTime == 0) {
// nothing is going on with startStop button
return;
}
// todo: should this be simply FSIO?
if (engine->rpmCalculator.isRunning()) {
@ -198,15 +184,6 @@ void slowStartStopButtonCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (wasStarterEngaged) {
scheduleMsg(&sharedLogger, "Engine runs we can disengage the starter");
}
engine->startStopStateLastPushTime = 0;
}
if (getTimeNowNt() - engine->startStopStateLastPushTime > NT_PER_SECOND * CONFIG(startCrankingDuration)) {
bool wasStarterEngaged = enginePins.starterControl.getAndSet(0);
if (wasStarterEngaged) {
scheduleMsg(&sharedLogger, "Cranking timeout %dseconds", CONFIG(startCrankingDuration));
}
engine->startStopStateLastPushTime = 0;
}
}

View File

@ -0,0 +1,10 @@
#include "start_stop.h"
#include "engine.h"
EXTERN_ENGINE;
ButtonDebounce startStopButtonDebounce;
void initStartStopButton(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
startStopButtonDebounce.init(CONFIG(startCrankingDuration), &CONFIG(startStopButtonPin), &CONFIG(startStopButtonMode));
}

View File

@ -0,0 +1,6 @@
#pragma once
#include "debounce.h"
#include "globalaccess.h"
void initStartStopButton(DECLARE_ENGINE_PARAMETER_SIGNATURE);

View File

@ -339,10 +339,6 @@ void applyNewHardwareSettings(void) {
brain_pin_markUnused(activeConfiguration.clutchUpPin);
}
if (isPinOrModeChanged(startStopButtonPin, startStopButtonMode)) {
brain_pin_markUnused(activeConfiguration.startStopButtonPin);
}
enginePins.unregisterPins();
#if EFI_SHAFT_POSITION_INPUT
@ -502,12 +498,6 @@ void initHardware(Logging *l) {
initSmartGpio(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif
if (CONFIG(startStopButtonPin) != GPIO_UNASSIGNED) {
efiSetPadMode("start/stop", CONFIG(startStopButtonPin),
getInputMode(CONFIG(startStopButtonMode)));
}
// output pins potentially depend on 'initSmartGpio'
initOutputPins(PASS_ENGINE_PARAMETER_SIGNATURE);