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 rusefi
parent b6a3d4f977
commit 6d010189e3
2 changed files with 6 additions and 6 deletions

View File

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

View File

@ -208,11 +208,12 @@ void fireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
#if !EFI_UNIT_TEST
if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
#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
*/
float ratio = NT2US(actualDwellDurationNt) / 1000.0 / event->sparkDwell;
float ratio = actualDwellMs / event->sparkDwell;
// todo: smarted solution for index to field mapping
switch (event->cylinderIndex) {