mirror of https://github.com/rusefi/rusefi-1.git
refactoring: reducing code duplication
This commit is contained in:
parent
2ee280be5b
commit
88348ebd09
|
@ -184,7 +184,7 @@ void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
#endif /* EFI_IDLE_CONTROL */
|
#endif /* EFI_IDLE_CONTROL */
|
||||||
|
|
||||||
#if EFI_SHAFT_POSITION_INPUT
|
#if EFI_SHAFT_POSITION_INPUT
|
||||||
onConfigurationChangeTriggerCallback(&activeConfiguration PASS_ENGINE_PARAMETER_SUFFIX);
|
onConfigurationChangeTriggerCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||||
#if EFI_EMULATE_POSITION_SENSORS
|
#if EFI_EMULATE_POSITION_SENSORS
|
||||||
onConfigurationChangeRpmEmulatorCallback(&activeConfiguration);
|
onConfigurationChangeRpmEmulatorCallback(&activeConfiguration);
|
||||||
|
|
|
@ -78,4 +78,6 @@
|
||||||
x.config = config; \
|
x.config = config; \
|
||||||
x.boardConfiguration = boardConfiguration;
|
x.boardConfiguration = boardConfiguration;
|
||||||
|
|
||||||
|
#define isConfigurationChanged(x) (engineConfiguration->x != activeConfiguration.x)
|
||||||
|
|
||||||
#endif /* CONTROLLERS_CORE_COMMON_HEADERS_H_ */
|
#endif /* CONTROLLERS_CORE_COMMON_HEADERS_H_ */
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
extern persistent_config_container_s persistentState; \
|
extern persistent_config_container_s persistentState; \
|
||||||
extern persistent_config_s *config; \
|
extern persistent_config_s *config; \
|
||||||
|
|
||||||
#define isConfigurationChanged(x) (engineConfiguration->x != activeConfiguration.x)
|
|
||||||
|
|
||||||
#define EXTERN_ENGINE \
|
#define EXTERN_ENGINE \
|
||||||
extern Engine ___engine; \
|
extern Engine ___engine; \
|
||||||
extern Engine *engine; \
|
extern Engine *engine; \
|
||||||
|
|
|
@ -667,31 +667,29 @@ static void resetRunningTriggerCounters() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COMPARE_CONFIG_PARAMS(param) (engineConfiguration->param != previousConfiguration->param)
|
void onConfigurationChangeTriggerCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
void onConfigurationChangeTriggerCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (int i = 0; i < CAM_INPUTS_COUNT; i++) {
|
for (int i = 0; i < CAM_INPUTS_COUNT; i++) {
|
||||||
changed |= COMPARE_CONFIG_PARAMS(camInputs[i]);
|
changed |= isConfigurationChanged(camInputs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
changed |=
|
changed |=
|
||||||
COMPARE_CONFIG_PARAMS(trigger.type) ||
|
isConfigurationChanged(trigger.type) ||
|
||||||
COMPARE_CONFIG_PARAMS(ambiguousOperationMode) ||
|
isConfigurationChanged(ambiguousOperationMode) ||
|
||||||
COMPARE_CONFIG_PARAMS(useOnlyRisingEdgeForTrigger) ||
|
isConfigurationChanged(useOnlyRisingEdgeForTrigger) ||
|
||||||
COMPARE_CONFIG_PARAMS(globalTriggerAngleOffset) ||
|
isConfigurationChanged(globalTriggerAngleOffset) ||
|
||||||
COMPARE_CONFIG_PARAMS(trigger.customTotalToothCount) ||
|
isConfigurationChanged(trigger.customTotalToothCount) ||
|
||||||
COMPARE_CONFIG_PARAMS(trigger.customSkippedToothCount) ||
|
isConfigurationChanged(trigger.customSkippedToothCount) ||
|
||||||
COMPARE_CONFIG_PARAMS(bc.triggerInputPins[0]) ||
|
isConfigurationChanged(bc.triggerInputPins[0]) ||
|
||||||
COMPARE_CONFIG_PARAMS(bc.triggerInputPins[1]) ||
|
isConfigurationChanged(bc.triggerInputPins[1]) ||
|
||||||
COMPARE_CONFIG_PARAMS(bc.triggerInputPins[2]) ||
|
isConfigurationChanged(bc.triggerInputPins[2]) ||
|
||||||
COMPARE_CONFIG_PARAMS(vvtMode) ||
|
isConfigurationChanged(vvtMode) ||
|
||||||
COMPARE_CONFIG_PARAMS(bc.vvtCamSensorUseRise) ||
|
isConfigurationChanged(bc.vvtCamSensorUseRise) ||
|
||||||
COMPARE_CONFIG_PARAMS(vvtOffset) ||
|
isConfigurationChanged(vvtOffset) ||
|
||||||
COMPARE_CONFIG_PARAMS(vvtDisplayInverted) ||
|
isConfigurationChanged(vvtDisplayInverted) ||
|
||||||
COMPARE_CONFIG_PARAMS(bc.miataNb2VVTRatioFrom) ||
|
isConfigurationChanged(bc.miataNb2VVTRatioFrom) ||
|
||||||
COMPARE_CONFIG_PARAMS(bc.miataNb2VVTRatioTo) ||
|
isConfigurationChanged(bc.miataNb2VVTRatioTo) ||
|
||||||
COMPARE_CONFIG_PARAMS(nbVvtIndex);
|
isConfigurationChanged(nbVvtIndex);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
assertEngineReference();
|
assertEngineReference();
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ void addTriggerEventListener(ShaftPositionListener handler, const char *name, En
|
||||||
int isSignalDecoderError(void);
|
int isSignalDecoderError(void);
|
||||||
void resetMaxValues();
|
void resetMaxValues();
|
||||||
|
|
||||||
void onConfigurationChangeTriggerCallback(engine_configuration_s *previousConfiguration DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void onConfigurationChangeTriggerCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
bool isTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
bool isTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,9 @@ void print(const char *fmt, ...);
|
||||||
|
|
||||||
#define CCM_OPTIONAL
|
#define CCM_OPTIONAL
|
||||||
|
|
||||||
#define EXTERN_ENGINE extern EnginePins enginePins
|
#define EXTERN_ENGINE extern EnginePins enginePins; \
|
||||||
|
extern engine_configuration_s activeConfiguration
|
||||||
|
|
||||||
#define EXTERN_CONFIG
|
#define EXTERN_CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue