auto-sync

This commit is contained in:
rusEfi 2014-11-25 09:03:25 -06:00
parent cebb1c13bb
commit 930909d7de
6 changed files with 25 additions and 8 deletions

View File

@ -50,7 +50,9 @@ float getAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_S) {
} else { } else {
angle = getBaseAdvance(rpm, engineLoad); angle = getBaseAdvance(rpm, engineLoad);
} }
return fixAngle(angle - engineConfiguration->ignitionOffset PASS_ENGINE_PARAMETER); angle -= engineConfiguration->ignitionOffset;
angle = fixAngle(angle PASS_ENGINE_PARAMETER);
return angle;
} }
void prepareTimingMap(void) { void prepareTimingMap(void) {

View File

@ -56,9 +56,9 @@ float fixAngle(float angle DECLARE_ENGINE_PARAMETER_S) {
efiAssert(engineConfiguration->engineCycle != 0, "engine cycle", NAN); efiAssert(engineConfiguration->engineCycle != 0, "engine cycle", NAN);
// I guess this implementation would be faster than 'angle % 720' // I guess this implementation would be faster than 'angle % 720'
while (angle < 0) while (angle < 0)
angle += engineConfiguration->engineCycle; angle += CONFIG(engineCycle);
while (angle >= engineConfiguration->engineCycle) while (angle >= CONFIG(engineCycle))
angle -= engineConfiguration->engineCycle; angle -= CONFIG(engineCycle);
return angle; return angle;
} }
@ -281,7 +281,8 @@ int getEngineCycleEventCount2(operation_mode_e mode, trigger_shape_s * s) {
void findTriggerPosition(trigger_shape_s * s, event_trigger_position_s *position, void findTriggerPosition(trigger_shape_s * s, event_trigger_position_s *position,
float angleOffset DECLARE_ENGINE_PARAMETER_S) { float angleOffset DECLARE_ENGINE_PARAMETER_S) {
angleOffset = fixAngle(angleOffset + engineConfiguration->globalTriggerAngleOffset PASS_ENGINE_PARAMETER); angleOffset += engineConfiguration->globalTriggerAngleOffset;
angleOffset = fixAngle(angleOffset PASS_ENGINE_PARAMETER);
int engineCycleEventCount = getEngineCycleEventCount2(getOperationMode(engineConfiguration), s); int engineCycleEventCount = getEngineCycleEventCount2(getOperationMode(engineConfiguration), s);

View File

@ -72,7 +72,9 @@ void trigger_shape_s::setTriggerShapeSynchPointIndex(engine_configuration_s *eng
// explicit check for zero to avoid issues where logical zero is not exactly zero due to float nature // explicit check for zero to avoid issues where logical zero is not exactly zero due to float nature
eventAngles[i] = 0; eventAngles[i] = 0;
} else { } else {
eventAngles[i] = fixAngle(getAngle((triggerShapeSynchPointIndex + i) % engineCycleEventCount) - firstAngle PASS_ENGINE_PARAMETER); float angle = getAngle((triggerShapeSynchPointIndex + i) % engineCycleEventCount) - firstAngle;
angle = fixAngle(angle PASS_ENGINE_PARAMETER);
eventAngles[i] = angle;
} }
} }
} }

View File

@ -228,7 +228,9 @@ static void reportWave(Logging *logging, int index) {
float oneDegreeUs = getOneDegreeTimeUs(getRpm()); float oneDegreeUs = getOneDegreeTimeUs(getRpm());
appendPrintf(logging, "advance%d%s", index, DELIMETER); appendPrintf(logging, "advance%d%s", index, DELIMETER);
appendFloat(logging, fixAngle((offsetUs / oneDegreeUs) - engineConfiguration->globalTriggerAngleOffset PASS_ENGINE_PARAMETER), 3); float angle = (offsetUs / oneDegreeUs) - engineConfiguration->globalTriggerAngleOffset;
angle = fixAngle(angle PASS_ENGINE_PARAMETER);
appendFloat(logging, angle, 3);
appendPrintf(logging, "%s", DELIMETER); appendPrintf(logging, "%s", DELIMETER);
} }
} }

View File

@ -71,11 +71,19 @@ typedef Thread thread_t;
#define EXTERN_ENGINE extern Engine *engine; \ #define EXTERN_ENGINE extern Engine *engine; \
extern engine_configuration_s *engineConfiguration; \ extern engine_configuration_s *engineConfiguration; \
extern board_configuration_s *boardConfiguration; extern board_configuration_s *boardConfiguration; \
extern persistent_config_container_s persistentState
#define DECLARE_ENGINE_PARAMETER_F void #define DECLARE_ENGINE_PARAMETER_F void
#define DECLARE_ENGINE_PARAMETER_S #define DECLARE_ENGINE_PARAMETER_S
#define PASS_ENGINE_PARAMETER_F #define PASS_ENGINE_PARAMETER_F
#define PASS_ENGINE_PARAMETER #define PASS_ENGINE_PARAMETER
/**
* this macro allows the compiled to figure out the complete static address, that's a performance
* optimization
*/
#define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x
#endif /* GLOBAL_H_ */ #endif /* GLOBAL_H_ */

View File

@ -45,4 +45,6 @@ class Engine;
#define PASS_ENGINE_PARAMETER_F engine, engineConfiguration #define PASS_ENGINE_PARAMETER_F engine, engineConfiguration
#define PASS_ENGINE_PARAMETER , engine, engineConfiguration #define PASS_ENGINE_PARAMETER , engine, engineConfiguration
#define CONFIG(x) engineConfiguration->x
#endif /* GLOBAL_H_ */ #endif /* GLOBAL_H_ */