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) {
|
||||
for (int iter = 0; iter < digit; iter++) {
|
||||
// todo: why we set LOW and then HIGH? not the other way around?
|
||||
enginePins.checkEnginePin.setValue(0);
|
||||
chThdSleepMilliseconds(duration);
|
||||
enginePins.checkEnginePin.setValue(1);
|
||||
|
@ -85,8 +86,15 @@ public:
|
|||
private:
|
||||
void PeriodicTask(efitime_t nowNt) override {
|
||||
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);
|
||||
for (int p = 0; p < localErrorCopy.count; p++) {
|
||||
// Calculate how many digits in this integer and display error code from start to end
|
||||
|
@ -113,7 +121,7 @@ void initMalfunctionIndicator(void) {
|
|||
if (!isMilEnabled()) {
|
||||
return;
|
||||
}
|
||||
instance.setPeriod(10);
|
||||
instance.setPeriod(10 /*ms*/);
|
||||
instance.Start();
|
||||
|
||||
#if TEST_MIL_CODE
|
||||
|
|
|
@ -45,6 +45,8 @@ typedef int pid_dt;
|
|||
* is actually after timeNow() due to interrupt context switches
|
||||
*
|
||||
* See getTimeNowNt()
|
||||
* See US2NT
|
||||
* See MS2US
|
||||
*/
|
||||
typedef int64_t efitime_t;
|
||||
|
||||
|
|
|
@ -812,6 +812,6 @@ int getRusEfiVersion(void) {
|
|||
if (initBootloader() != 0)
|
||||
return 123;
|
||||
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
||||
return 20190817;
|
||||
return 20190818;
|
||||
}
|
||||
#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
|
||||
// while for toothed wheels user would have to provide a value
|
||||
#define tdcPosition() \
|
||||
(ENGINE(triggerCentral.triggerShape.tdcPosition) + CONFIG(globalTriggerAngleOffset))
|
||||
(TRIGGER_SHAPE(tdcPosition) + CONFIG(globalTriggerAngleOffset))
|
||||
|
|
|
@ -38,9 +38,22 @@ TriggerState::TriggerState() {
|
|||
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() {
|
||||
triggerCycleCallback = NULL;
|
||||
shaft_is_synchronized = false;
|
||||
setShaftSynchronized(false);
|
||||
toothed_previous_time = 0;
|
||||
|
||||
memset(toothDurations, 0, sizeof(toothDurations));
|
||||
|
@ -316,7 +329,7 @@ bool TriggerState::isEvenRevolution() const {
|
|||
}
|
||||
|
||||
void TriggerState::onSynchronizationLost(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
shaft_is_synchronized = false;
|
||||
setShaftSynchronized(false);
|
||||
// Needed for early instant-RPM detection
|
||||
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) {
|
||||
shaft_is_synchronized = true;
|
||||
setShaftSynchronized(true);
|
||||
// this call would update duty cycle values
|
||||
nextTriggerEvent()
|
||||
;
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
* TRUE if we know where we are
|
||||
*/
|
||||
bool shaft_is_synchronized;
|
||||
efitime_t mostRecentSyncTime;
|
||||
|
||||
efitick_t lastDecodingErrorTime;
|
||||
// the boolean flag is a performance optimization so that complex comparison is avoided if no error
|
||||
|
@ -99,6 +100,7 @@ public:
|
|||
uint32_t orderingErrorCounter;
|
||||
|
||||
void resetTriggerState();
|
||||
void setShaftSynchronized(bool value);
|
||||
|
||||
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
|
||||
virtual void runtimeStatistics(efitime_t nowNt DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
|
|
Loading…
Reference in New Issue