auto-sync
This commit is contained in:
parent
6674a9d941
commit
5a7c5f2222
|
@ -140,10 +140,16 @@ int getGlobalConfigurationVersion(void) {
|
|||
*/
|
||||
void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_F) {
|
||||
globalConfigurationVersion++;
|
||||
/**
|
||||
* All these callbacks could be implemented as listeners, but these days I am saving RAM
|
||||
*/
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
applyNewHardwareSettings();
|
||||
#endif /* EFI_PROD_CODE */
|
||||
engine->preCalculate();
|
||||
#if EFI_ALTERNATOR_CONTROL || defined(__DOXYGEN__)
|
||||
onConfigurationChangeAlternatorCallback(&activeConfiguration);
|
||||
#endif
|
||||
rememberCurrentConfiguration();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,19 +37,21 @@ static THD_WORKING_AREA(alternatorControlThreadStack, UTILITY_THREAD_STACK_SIZE)
|
|||
static float currentAltDuty;
|
||||
|
||||
#if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
|
||||
static LocalVersionHolder parametersVersion;
|
||||
extern TunerStudioOutputChannels tsOutputChannels;
|
||||
#endif
|
||||
|
||||
static bool currentPlainOnOffState = false;
|
||||
static bool shouldResetPid = false;
|
||||
|
||||
static msg_t AltCtrlThread(int param) {
|
||||
UNUSED(param);
|
||||
chRegSetThreadName("AlternatorController");
|
||||
while (true) {
|
||||
#if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
|
||||
if (parametersVersion.isOld())
|
||||
if (shouldResetPid) {
|
||||
altPid.reset();
|
||||
}
|
||||
shouldResetPid = false;
|
||||
#endif
|
||||
|
||||
int dt = maxI(10, engineConfiguration->alternatorDT);
|
||||
|
@ -144,6 +146,10 @@ void setDefaultAlternatorParameters(void) {
|
|||
engineConfiguration->alternatorDT = 100;
|
||||
}
|
||||
|
||||
void onConfigurationChangeAlternatorCallback(engine_configuration_s *previousConfiguration) {
|
||||
shouldResetPid = !altPid.isSame(&previousConfiguration->alternatorControl);
|
||||
}
|
||||
|
||||
void initAlternatorCtrl(Logging *sharedLogger) {
|
||||
logger = sharedLogger;
|
||||
addConsoleAction("altinfo", showAltInfo);
|
||||
|
|
|
@ -16,4 +16,6 @@ void setAltPFactor(float p);
|
|||
void showAltInfo(void);
|
||||
void setDefaultAlternatorParameters(void);
|
||||
|
||||
void onConfigurationChangeAlternatorCallback(engine_configuration_s *previousConfiguration);
|
||||
|
||||
#endif /* ALTERNATORCONTROLLER_H_ */
|
||||
|
|
|
@ -27,6 +27,11 @@ void Pid::init(pid_s *pid, float minResult, float maxResult) {
|
|||
prevError = 0;
|
||||
}
|
||||
|
||||
bool Pid::isSame(pid_s *pid) {
|
||||
return this->pid->dFactor == pid->dFactor && this->pid->iFactor == pid->iFactor &&
|
||||
this->pid->offset == pid->offset && this->pid->pFactor == pid->pFactor;
|
||||
}
|
||||
|
||||
float Pid::getValue(float target, float input, float dTime) {
|
||||
float error = target - input;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
Pid();
|
||||
Pid(pid_s *pid, float minResult, float maxResult);
|
||||
void init(pid_s *pid, float minResult, float maxResult);
|
||||
bool isSame(pid_s *pid);
|
||||
|
||||
float getValue(float target, float input, float dTime);
|
||||
void updateFactors(float pFactor, float iFactor, float dFactor);
|
||||
|
|
Loading…
Reference in New Issue