new feature: check engine light to blink on trigger synchronization
This commit is contained in:
parent
c29f038b83
commit
1c0d38abef
|
@ -45,6 +45,7 @@ EXTERN_ENGINE;
|
||||||
|
|
||||||
static void blink_digits(int digit, int duration) {
|
static void blink_digits(int digit, int duration) {
|
||||||
for (int iter = 0; iter < digit; iter++) {
|
for (int iter = 0; iter < digit; iter++) {
|
||||||
|
// todo: why we set LOW and then HIGH? not the other way around?
|
||||||
enginePins.checkEnginePin.setValue(0);
|
enginePins.checkEnginePin.setValue(0);
|
||||||
chThdSleepMilliseconds(duration);
|
chThdSleepMilliseconds(duration);
|
||||||
enginePins.checkEnginePin.setValue(1);
|
enginePins.checkEnginePin.setValue(1);
|
||||||
|
@ -85,8 +86,15 @@ public:
|
||||||
private:
|
private:
|
||||||
void PeriodicTask(efitime_t nowNt) override {
|
void PeriodicTask(efitime_t nowNt) override {
|
||||||
UNUSED(nowNt);
|
UNUSED(nowNt);
|
||||||
static error_codes_set_s localErrorCopy;
|
|
||||||
|
|
||||||
|
if (nowNt - engine->triggerCentral.triggerState.mostRecentSyncTime < US2NT(MS2US(500))) {
|
||||||
|
enginePins.checkEnginePin.setValue(1);
|
||||||
|
chThdSleepMilliseconds(500);
|
||||||
|
enginePins.checkEnginePin.setValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static error_codes_set_s localErrorCopy;
|
||||||
|
// todo: why do I not see this on a real vehicle? is this whole blinking logic not used?
|
||||||
getErrorCodes(&localErrorCopy);
|
getErrorCodes(&localErrorCopy);
|
||||||
for (int p = 0; p < localErrorCopy.count; p++) {
|
for (int p = 0; p < localErrorCopy.count; p++) {
|
||||||
// Calculate how many digits in this integer and display error code from start to end
|
// Calculate how many digits in this integer and display error code from start to end
|
||||||
|
@ -113,7 +121,7 @@ void initMalfunctionIndicator(void) {
|
||||||
if (!isMilEnabled()) {
|
if (!isMilEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
instance.setPeriod(10);
|
instance.setPeriod(10 /*ms*/);
|
||||||
instance.Start();
|
instance.Start();
|
||||||
|
|
||||||
#if TEST_MIL_CODE
|
#if TEST_MIL_CODE
|
||||||
|
|
|
@ -45,6 +45,8 @@ typedef int pid_dt;
|
||||||
* is actually after timeNow() due to interrupt context switches
|
* is actually after timeNow() due to interrupt context switches
|
||||||
*
|
*
|
||||||
* See getTimeNowNt()
|
* See getTimeNowNt()
|
||||||
|
* See US2NT
|
||||||
|
* See MS2US
|
||||||
*/
|
*/
|
||||||
typedef int64_t efitime_t;
|
typedef int64_t efitime_t;
|
||||||
|
|
||||||
|
|
|
@ -812,6 +812,6 @@ int getRusEfiVersion(void) {
|
||||||
if (initBootloader() != 0)
|
if (initBootloader() != 0)
|
||||||
return 123;
|
return 123;
|
||||||
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
||||||
return 20190817;
|
return 20190818;
|
||||||
}
|
}
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
|
|
|
@ -67,4 +67,4 @@ void setSingleCoilDwell(engine_configuration_s *engineConfiguration);
|
||||||
// expectation is that for well-known triggers CONFIG(globalTriggerAngleOffset) would usually be zero
|
// expectation is that for well-known triggers CONFIG(globalTriggerAngleOffset) would usually be zero
|
||||||
// while for toothed wheels user would have to provide a value
|
// while for toothed wheels user would have to provide a value
|
||||||
#define tdcPosition() \
|
#define tdcPosition() \
|
||||||
(ENGINE(triggerCentral.triggerShape.tdcPosition) + CONFIG(globalTriggerAngleOffset))
|
(TRIGGER_SHAPE(tdcPosition) + CONFIG(globalTriggerAngleOffset))
|
||||||
|
|
|
@ -38,9 +38,22 @@ TriggerState::TriggerState() {
|
||||||
resetTriggerState();
|
resetTriggerState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriggerState::setShaftSynchronized(bool value) {
|
||||||
|
if (value) {
|
||||||
|
if (!shaft_is_synchronized) {
|
||||||
|
// just got synchronized
|
||||||
|
mostRecentSyncTime = getTimeNowNt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// sync loss
|
||||||
|
mostRecentSyncTime = 0;
|
||||||
|
}
|
||||||
|
shaft_is_synchronized = value;
|
||||||
|
}
|
||||||
|
|
||||||
void TriggerState::resetTriggerState() {
|
void TriggerState::resetTriggerState() {
|
||||||
triggerCycleCallback = NULL;
|
triggerCycleCallback = NULL;
|
||||||
shaft_is_synchronized = false;
|
setShaftSynchronized(false);
|
||||||
toothed_previous_time = 0;
|
toothed_previous_time = 0;
|
||||||
|
|
||||||
memset(toothDurations, 0, sizeof(toothDurations));
|
memset(toothDurations, 0, sizeof(toothDurations));
|
||||||
|
@ -316,7 +329,7 @@ bool TriggerState::isEvenRevolution() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerState::onSynchronizationLost(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void TriggerState::onSynchronizationLost(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
shaft_is_synchronized = false;
|
setShaftSynchronized(false);
|
||||||
// Needed for early instant-RPM detection
|
// Needed for early instant-RPM detection
|
||||||
engine->rpmCalculator.setStopSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
|
engine->rpmCalculator.setStopSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
@ -369,7 +382,7 @@ void TriggerState::handleTriggerError(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerState::onShaftSynchronization(efitime_t nowNt, trigger_wheel_e triggerWheel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
void TriggerState::onShaftSynchronization(efitime_t nowNt, trigger_wheel_e triggerWheel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
shaft_is_synchronized = true;
|
setShaftSynchronized(true);
|
||||||
// this call would update duty cycle values
|
// this call would update duty cycle values
|
||||||
nextTriggerEvent()
|
nextTriggerEvent()
|
||||||
;
|
;
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
* TRUE if we know where we are
|
* TRUE if we know where we are
|
||||||
*/
|
*/
|
||||||
bool shaft_is_synchronized;
|
bool shaft_is_synchronized;
|
||||||
|
efitime_t mostRecentSyncTime;
|
||||||
|
|
||||||
efitick_t lastDecodingErrorTime;
|
efitick_t lastDecodingErrorTime;
|
||||||
// the boolean flag is a performance optimization so that complex comparison is avoided if no error
|
// the boolean flag is a performance optimization so that complex comparison is avoided if no error
|
||||||
|
@ -99,6 +100,7 @@ public:
|
||||||
uint32_t orderingErrorCounter;
|
uint32_t orderingErrorCounter;
|
||||||
|
|
||||||
void resetTriggerState();
|
void resetTriggerState();
|
||||||
|
void setShaftSynchronized(bool value);
|
||||||
|
|
||||||
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
|
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
|
||||||
virtual void runtimeStatistics(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
virtual void runtimeStatistics(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
Loading…
Reference in New Issue