auto-sync

This commit is contained in:
rusEfi 2014-12-03 16:03:09 -06:00
parent a611130271
commit 5c96277fbf
8 changed files with 22 additions and 21 deletions

View File

@ -123,7 +123,7 @@ void StartupFuelPumping::setPumpsCounter(engine_configuration_s *engineConfigura
}
void StartupFuelPumping::update(DECLARE_ENGINE_PARAMETER_F) {
if (engine->rpmCalculator.rpm() == 0) {
if (engine->rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F) == 0) {
bool isTpsAbove50 = getTPS(PASS_ENGINE_PARAMETER_F) >= 50;
if (this->isTpsAbove50 != isTpsAbove50) {

View File

@ -66,8 +66,6 @@ static float v_averagedMapValue;
EXTERN_ENGINE;
extern engine_configuration_s *engineConfiguration;
static scheduling_s startTimer[2];
static scheduling_s endTimer[2];
@ -100,7 +98,7 @@ void mapAveragingCallback(adcsample_t value) {
#if EFI_ANALOG_CHART
if (engineConfiguration->analogChartMode == AC_MAP)
if (perRevolutionCounter % FAST_MAP_CHART_SKIP_FACTOR == 0)
acAddData(getCrankshaftAngleNt(engine, getTimeNowNt()), currentPressure);
acAddData(getCrankshaftAngleNt(getTimeNowNt() PASS_ENGINE_PARAMETER), currentPressure);
#endif /* EFI_ANALOG_CHART */
chSysLockFromIsr()

View File

@ -406,8 +406,8 @@ void MainTriggerCallback::init(Engine *engine, engine_configuration2_s *engineCo
}
static void showMainInfo(Engine *engine) {
int rpm = engine->rpmCalculator.rpm();
#if EFI_PROD_CODE
int rpm = engine->rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F);
float el = getEngineLoadT(PASS_ENGINE_PARAMETER);
scheduleMsg(&logger, "rpm %d engine_load %f", rpm, el);
scheduleMsg(&logger, "fuel %fms timing %f", getFuelMs(rpm PASS_ENGINE_PARAMETER),

View File

@ -62,7 +62,7 @@ RpmCalculator::RpmCalculator() {
/**
* @return true if there was a full shaft revolution within the last second
*/
bool RpmCalculator::isRunning(void) {
bool RpmCalculator::isRunning(DECLARE_ENGINE_PARAMETER_F) {
uint64_t nowNt = getTimeNowNt();
return nowNt - lastRpmEventTimeNt < US2NT(US_PER_SECOND);
}
@ -96,12 +96,12 @@ uint32_t RpmCalculator::getRevolutionCounterSinceStart(void) {
*/
// todo: migrate to float return result or add a float verion? this would have with calculations
// todo: add a version which does not check time & saves time? need to profile
int RpmCalculator::rpm(void) {
int RpmCalculator::rpm(DECLARE_ENGINE_PARAMETER_F) {
#if !EFI_PROD_CODE
if (mockRpm != MOCK_UNDEFINED)
return mockRpm;
#endif
if (!isRunning()) {
if (!isRunning(PASS_ENGINE_PARAMETER_F)) {
revolutionCounterSinceStart = 0;
return 0;
}
@ -141,12 +141,12 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index DECL
if (index != 0) {
#if EFI_ANALOG_CHART || defined(__DOXYGEN__)
if (engineConfiguration->analogChartMode == AC_TRIGGER)
acAddData(getCrankshaftAngleNt(engine, nowNt), 1000 * ckpSignalType + index);
acAddData(getCrankshaftAngleNt(nowNt PASS_ENGINE_PARAMETER), 1000 * ckpSignalType + index);
#endif
return;
}
bool hadRpmRecently = rpmState->isRunning();
bool hadRpmRecently = rpmState->isRunning(PASS_ENGINE_PARAMETER_F);
if (hadRpmRecently) {
uint64_t diffNt = nowNt - rpmState->lastRpmEventTimeNt;
@ -169,7 +169,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index DECL
rpmState->lastRpmEventTimeNt = nowNt;
#if EFI_ANALOG_CHART || defined(__DOXYGEN__)
if (engineConfiguration->analogChartMode == AC_TRIGGER)
acAddData(getCrankshaftAngleNt(engine, nowNt), index);
acAddData(getCrankshaftAngleNt(nowNt PASS_ENGINE_PARAMETER), index);
#endif
}
@ -212,7 +212,7 @@ int getRevolutionCounter() {
/**
* @return Current crankshaft angle, 0 to 720 for four-stroke
*/
float getCrankshaftAngleNt(Engine *engine, uint64_t timeNt) {
float getCrankshaftAngleNt(uint64_t timeNt DECLARE_ENGINE_PARAMETER_S) {
uint64_t timeSinceZeroAngleNt = timeNt - engine->rpmCalculator.lastRpmEventTimeNt;
/**
@ -220,7 +220,7 @@ float getCrankshaftAngleNt(Engine *engine, uint64_t timeNt) {
* compiler is not smart enough to figure out that "A / ( B / C)" could be optimized into
* "A * C / B" in order to replace a slower division with a faster multiplication.
*/
return timeSinceZeroAngleNt / getOneDegreeTimeNt(engine->rpmCalculator.rpm());
return timeSinceZeroAngleNt / getOneDegreeTimeNt(engine->rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F));
}
void initRpmCalculator(Engine *engine) {

View File

@ -31,8 +31,8 @@ public:
int mockRpm;
#endif
RpmCalculator();
bool isRunning(void);
int rpm(void);
bool isRunning(DECLARE_ENGINE_PARAMETER_F);
int rpm(DECLARE_ENGINE_PARAMETER_F);
void onNewEngineCycle();
uint32_t getRevolutionCounter(void);
void setRpmValue(int value);
@ -60,7 +60,7 @@ private:
/**
* @brief Current RPM
*/
#define getRpmE(engine) (engine)->rpmCalculator.rpm()
#define getRpmE(engine) (engine)->rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F)
bool isCrankingE(Engine *engine);
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index DECLARE_ENGINE_PARAMETER_S);
@ -69,7 +69,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index DECL
*/
void initRpmCalculator(Engine *engine);
float getCrankshaftAngleNt(Engine *engine, uint64_t timeNt);
float getCrankshaftAngleNt(uint64_t timeNt DECLARE_ENGINE_PARAMETER_S);
#endif
#ifdef __cplusplus

View File

@ -73,7 +73,8 @@ typedef Thread thread_t;
extern engine_configuration_s *engineConfiguration; \
extern board_configuration_s *boardConfiguration; \
extern persistent_config_container_s persistentState; \
extern Engine _engine
extern Engine _engine; \
extern engine_configuration2_s * engineConfiguration2
#define DECLARE_ENGINE_PARAMETER_F void
#define DECLARE_ENGINE_PARAMETER_S

View File

@ -13,12 +13,14 @@
void testSpeedDensity(void) {
printf("*************************************************** testSpeedDensity\r\n");
EngineTestHelper eth(FORD_INLINE_6_1995);
Engine *engine = &eth.engine;
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
eth.ec->triggerConfig.customTotalToothCount = 8;
eth.initTriggerShapeAndRpmCalculator();
eth.fireTriggerEvents();
assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.rpm());
assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F));
// 427 cubic inches, that's a LOT of engine
eth.ec->displacement = 6.99728;

View File

@ -401,10 +401,10 @@ static void testRpmCalculator(void) {
eth.engine.engineConfiguration->injectorLag = 0.0;
timeNow = 0;
assertEquals(0, eth.engine.rpmCalculator.rpm());
assertEquals(0, eth.engine.rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F));
eth.fireTriggerEvents();
assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.rpm());
assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F));
assertEqualsM("index #1", 15, eth.triggerCentral.triggerState.getCurrentIndex());
static MainTriggerCallback triggerCallbackInstance;