auto-sync

This commit is contained in:
rusEfi 2016-09-26 00:03:15 -04:00
parent 04fbf2ed53
commit e5690535aa
6 changed files with 20 additions and 5 deletions

View File

@ -129,6 +129,10 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_S) {
floatms_t fuelPerCycle = getRunningFuel(baseFuel, rpm PASS_ENGINE_PARAMETER);
theoreticalInjectionLength = fuelPerCycle
/ getNumberOfInjections(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
#if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__)
printf("baseFuel=%f fuelPerCycle=%f theoreticalInjectionLength=%f\t\n",
baseFuel, fuelPerCycle, theoreticalInjectionLength);
#endif /*EFI_PRINTF_FUEL_DETAILS */
}
return theoreticalInjectionLength + ENGINE(engineState.injectorLag);
}

View File

@ -18,8 +18,6 @@
#define MS2US(MS_TIME) ((MS_TIME) * 1000)
#define US_TO_TI_TEMP 10
// todo: implement a function to work with times considering counter overflow
#define overflowDiff(now, time) ((now) - (time))

View File

@ -90,6 +90,10 @@ floatms_t getSpeedDensityFuel(int rpm DECLARE_ENGINE_PARAMETER_S) {
float adjustedMap = map + engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_F);
engine->engineState.airMass = getAirMass(engineConfiguration, ENGINE(engineState.currentVE), adjustedMap, tChargeK);
#if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__)
printf("map=%f adjustedMap=%f airMass=%f\t\n",
map, adjustedMap, engine->engineState.airMass);
#endif /*EFI_PRINTF_FUEL_DETAILS */
return sdMath(engineConfiguration, engine->engineState.airMass, ENGINE(engineState.targetAFR)) * 1000;
}

View File

@ -38,7 +38,7 @@ void scheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t ti
}
static void timerCallback(scheduling_s *scheduling) {
#if EFI_SIMULATOR || defined(__DOXYGEN__)
#if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__)
if (scheduling->callback == (schfunc_t)&seTurnPinLow) {
printf("executing cb=seTurnPinLow p=%d sch=%d now=%d\r\n", (int)scheduling->param, (int)scheduling,
(int)getTimeNowUs());

View File

@ -87,7 +87,7 @@ static void endSimultaniousInjection(Engine *engine) {
}
}
static void scheduleFuelInjection(int injEventIndex, OutputSignal *signal, efitimeus_t nowUs, float delayUs, float durationUs, InjectorOutputPin *output DECLARE_ENGINE_PARAMETER_S) {
static void scheduleFuelInjection(int rpm, int injEventIndex, OutputSignal *signal, efitimeus_t nowUs, floatus_t delayUs, floatus_t durationUs, InjectorOutputPin *output DECLARE_ENGINE_PARAMETER_S) {
if (durationUs < 0) {
warning(CUSTOM_OBD_3, "duration cannot be negative: %d", durationUs);
return;
@ -96,6 +96,10 @@ static void scheduleFuelInjection(int injEventIndex, OutputSignal *signal, efiti
warning(CUSTOM_OBD_4, "NaN in scheduleFuelInjection", durationUs);
return;
}
#if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__)
printf("fuelout %s duration %d total=%d\t\n", output->name, (int)durationUs,
(int)MS2US(getCrankshaftRevolutionTimeMs(rpm)));
#endif /*EFI_PRINTF_FUEL_DETAILS */
efiAssertVoid(signal!=NULL, "signal is NULL");
int index = getRevolutionCounter() % 2;
@ -126,6 +130,9 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
* x2 or /2?
*/
const floatms_t injectionDuration = ENGINE(wallFuel).adjust(event->injectorIndex, ENGINE(fuelMs) PASS_ENGINE_PARAMETER);
#if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__)
printf("fuel fuelMs=%f adjusted=%f\t\n", ENGINE(fuelMs), injectionDuration);
#endif /*EFI_PRINTF_FUEL_DETAILS */
// todo: pre-calculate 'numberOfInjections'
floatms_t totalPerCycle = injectionDuration * getNumberOfInjections(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
@ -195,7 +202,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
prevOutputName = outputName;
}
scheduleFuelInjection(injEventIndex, signal, getTimeNowUs(), injectionStartDelayUs, MS2US(injectionDuration), event->output PASS_ENGINE_PARAMETER);
scheduleFuelInjection(rpm, injEventIndex, signal, getTimeNowUs(), injectionStartDelayUs, MS2US(injectionDuration), event->output PASS_ENGINE_PARAMETER);
}
}

View File

@ -12,6 +12,8 @@
#define EFI_ENABLE_MOCK_ADC TRUE
#define EFI_PRINTF_FUEL_DETAILS TRUE
#define EFI_GPIO TRUE
#define EFI_FSIO TRUE