mirror of https://github.com/rusefi/rusefi-1.git
maybe more working MAP sampling (#3689)
* what if we do this * cleanup * s * test
This commit is contained in:
parent
8016da48b7
commit
6de8364895
|
@ -668,6 +668,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
|||
engine->outputChannels.currentEnginePhase = toothAngle;
|
||||
#endif // EFI_TUNER_STUDIO
|
||||
|
||||
#if WITH_TS_STATE
|
||||
if (engineConfiguration->vvtMode[0] == VVT_MAP_V_TWIN_ANOTHER) {
|
||||
// we are trying to figure out which 360 half of the total 720 degree cycle is which, so we compare those in 360 degree sense.
|
||||
auto toothAngle360 = toothAngle;
|
||||
|
@ -678,36 +679,30 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
|||
if (mapCamPrevToothAngle < engineConfiguration->mapCamDetectionAnglePosition && toothAngle360 > engineConfiguration->mapCamDetectionAnglePosition) {
|
||||
// we are somewhere close to 'mapCamDetectionAnglePosition'
|
||||
|
||||
float map = Sensor::getOrZero(SensorType::Map);
|
||||
// warning: hack hack hack
|
||||
float map = engine->outputChannels.instantMAPValue;
|
||||
|
||||
if (map > mapCamPrevCycleValue) {
|
||||
#if WITH_TS_STATE
|
||||
// Compute diff against the last time we were here
|
||||
float diff = map - mapCamPrevCycleValue;
|
||||
mapCamPrevCycleValue = map;
|
||||
|
||||
if (diff > 0) {
|
||||
engine->outputChannels.TEMPLOG_map_peak++;
|
||||
int revolutionCounter = engine->triggerCentral.triggerState.getTotalRevolutionCounter();
|
||||
engine->outputChannels.TEMPLOG_MAP_AT_CYCLE_COUNT = revolutionCounter - prevChangeAtCycle;
|
||||
prevChangeAtCycle = revolutionCounter;
|
||||
#endif // WITH_TS_STATE
|
||||
|
||||
efitick_t stamp = getTimeNowNt();
|
||||
hwHandleVvtCamSignal(TV_RISE, stamp, /*index*/0);
|
||||
hwHandleVvtCamSignal(TV_FALL, stamp, /*index*/0);
|
||||
hwHandleVvtCamSignal(TV_RISE, timestamp, /*index*/0);
|
||||
hwHandleVvtCamSignal(TV_FALL, timestamp, /*index*/0);
|
||||
}
|
||||
#if WITH_TS_STATE
|
||||
|
||||
engine->outputChannels.TEMPLOG_MAP_AT_SPECIAL_POINT = map;
|
||||
engine->outputChannels.TEMPLOG_MAP_AT_DIFF = map - mapCamPrevCycleValue;
|
||||
#endif // WITH_TS_STATE
|
||||
|
||||
mapCamPrevCycleValue = map;
|
||||
|
||||
|
||||
|
||||
engine->outputChannels.TEMPLOG_MAP_AT_DIFF = diff;
|
||||
}
|
||||
|
||||
mapCamPrevToothAngle = toothAngle360;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // WITH_TS_STATE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ TEST(trigger, map_cam_by_magic_point) {
|
|||
engineConfiguration->camInputs[0] = GPIOA_0;
|
||||
engineConfiguration->vvtMode[0] = VVT_MAP_V_TWIN_ANOTHER;
|
||||
|
||||
Sensor::setMockValue(SensorType::Map, 100);
|
||||
engine->outputChannels.instantMAPValue = 100;
|
||||
|
||||
engineConfiguration->mapCamDetectionAnglePosition = 90;
|
||||
|
||||
|
@ -88,7 +88,7 @@ TEST(trigger, map_cam_by_magic_point) {
|
|||
ASSERT_EQ(0, engine->outputChannels.vvtSyncCounter);
|
||||
|
||||
|
||||
Sensor::setMockValue(SensorType::Map, 120);
|
||||
engine->outputChannels.instantMAPValue = 120;
|
||||
eth.smartFireTriggerEvents2(/*count*/4, /*delayMs*/200);
|
||||
|
||||
ASSERT_EQ(2, engine->outputChannels.TEMPLOG_map_peak);
|
||||
|
|
Loading…
Reference in New Issue