plumbing for 4513 (#4599)

* plumbing for 4513

* not static
This commit is contained in:
Matthew Kennedy 2022-09-20 03:19:51 -07:00 committed by GitHub
parent ff9ce3730a
commit a9cc3223dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 24 deletions

View File

@ -72,25 +72,6 @@ void turnInjectionPinLow(InjectionEvent *event) {
getFuelSchedule()->addFuelEventsForCylinder(event->ownIndex);
}
static bool isPhaseInRange(float test, float current, float next) {
bool afterCurrent = test >= current;
bool beforeNext = test < next;
if (next > current) {
// we're not near the end of the cycle, comparison is simple
// 0 |------------------------| 720
// next current
return afterCurrent && beforeNext;
} else {
// we're near the end of the cycle so we have to check the wraparound
// 0 -----------| |------ 720
// next current
// Check whether test is after current (ie, between current tooth and end of cycle)
// or if test if before next (ie, between start of cycle and next tooth)
return afterCurrent || beforeNext;
}
}
void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase, float nextPhase) {
auto eventAngle = injectionStartAngle;
@ -309,7 +290,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_
/**
* For spark we schedule both start of coil charge and actual spark based on trigger angle
*/
onTriggerEventSparkLogic(trgEventIndex, rpm, edgeTimestamp);
onTriggerEventSparkLogic(trgEventIndex, rpm, edgeTimestamp, currentPhase, nextPhase);
}
#endif /* EFI_ENGINE_CONTROL */

View File

@ -288,7 +288,7 @@ void turnSparkPinHigh(IgnitionEvent *event) {
}
static void scheduleSparkEvent(bool limitedSpark, uint32_t trgEventIndex, IgnitionEvent *event,
int rpm, efitick_t edgeTimestamp) {
int rpm, efitick_t edgeTimestamp, float currentPhase) {
angle_t sparkAngle = event->sparkAngle;
const floatms_t dwellMs = engine->engineState.sparkDwell;
@ -425,7 +425,7 @@ static void prepareIgnitionSchedule() {
initializeIgnitionActions();
}
void onTriggerEventSparkLogic(uint32_t trgEventIndex, int rpm, efitick_t edgeTimestamp) {
void onTriggerEventSparkLogic(uint32_t trgEventIndex, int rpm, efitick_t edgeTimestamp, float currentPhase, float nextPhase) {
ScopePerf perf(PE::OnTriggerEventSparkLogic);
if (!isValidRpm(rpm) || !engineConfiguration->isIgnitionEnabled) {
@ -470,7 +470,7 @@ void onTriggerEventSparkLogic(uint32_t trgEventIndex, int rpm, efitick_t edgeTim
}
#endif // EFI_LAUNCH_CONTROL
scheduleSparkEvent(limitedSpark, trgEventIndex, event, rpm, edgeTimestamp);
scheduleSparkEvent(limitedSpark, trgEventIndex, event, rpm, edgeTimestamp, currentPhase);
}
}
}

View File

@ -7,7 +7,7 @@
#pragma once
void onTriggerEventSparkLogic(uint32_t trgEventIndex, int rpm, efitick_t edgeTimestamp);
void onTriggerEventSparkLogic(uint32_t trgEventIndex, int rpm, efitick_t edgeTimestamp, float currentPhase, float nextPhase);
void turnSparkPinHigh(IgnitionEvent *event);
void fireSparkAndPrepareNextSchedule(IgnitionEvent *event);
int getNumberOfSparks(ignition_mode_e mode);

View File

@ -298,3 +298,22 @@ float limitRateOfChange(float newValue, float oldValue, float incrLimitPerSec, f
return (incrLimitPerSec <= 0.0f) ? newValue : oldValue + minF(newValue - oldValue, incrLimitPerSec * secsPassed);
return (decrLimitPerSec <= 0.0f) ? newValue : oldValue - minF(oldValue - newValue, decrLimitPerSec * secsPassed);
}
bool isPhaseInRange(float test, float current, float next) {
bool afterCurrent = test >= current;
bool beforeNext = test < next;
if (next > current) {
// we're not near the end of the cycle, comparison is simple
// 0 |------------------------| 720
// next current
return afterCurrent && beforeNext;
} else {
// we're near the end of the cycle so we have to check the wraparound
// 0 -----------| |------ 720
// next current
// Check whether test is after current (ie, between current tooth and end of cycle)
// or if test if before next (ie, between start of cycle and next tooth)
return afterCurrent || beforeNext;
}
}

View File

@ -86,6 +86,8 @@ bool strEqual(const char *str1, const char *str2);
// Currently used by air-interp. tCharge mode (see EngineState::updateTChargeK()).
float limitRateOfChange(float newValue, float oldValue, float incrLimitPerSec, float decrLimitPerSec, float secsPassed);
bool isPhaseInRange(float test, float current, float next);
#ifdef __cplusplus
}