use timer instead of home spun time math

This commit is contained in:
Matthew Kennedy 2024-04-25 15:06:11 -07:00 committed by rusefillc
parent 0f522f1947
commit 046ad7436f
2 changed files with 6 additions and 6 deletions

View File

@ -70,10 +70,9 @@ public:
*/ */
angle_t sparkAngle = NAN; angle_t sparkAngle = NAN;
floatms_t sparkDwell = 0; floatms_t sparkDwell = 0;
/**
* this timestamp allows us to measure actual dwell time // this timer allows us to measure actual dwell time
*/ Timer actualDwellTimer;
uint32_t actualStartOfDwellNt = 0;
float dwellAngle = 0; float dwellAngle = 0;

View File

@ -208,11 +208,12 @@ void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
#if !EFI_UNIT_TEST #if !EFI_UNIT_TEST
if (engineConfiguration->debugMode == DBG_DWELL_METRIC) { if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
uint32_t actualDwellDurationNt = getTimeNowLowerNt() - event->actualStartOfDwellNt; float actualDwellMs = event->actualDwellTimer.getElapsedSeconds(nowNt) * 1e3;
/** /**
* ratio of desired dwell duration to actual dwell duration gives us some idea of how good is input trigger jitter * ratio of desired dwell duration to actual dwell duration gives us some idea of how good is input trigger jitter
*/ */
float ratio = NT2US(actualDwellDurationNt) / 1000.0 / event->sparkDwell; float ratio = actualDwellMs / event->sparkDwell;
// todo: smarted solution for index to field mapping // todo: smarted solution for index to field mapping
switch (event->cylinderIndex) { switch (event->cylinderIndex) {