AC is EngineModule (#3604)

* AC is engine module

* missed a spot with main relay while we're at it

* TS
This commit is contained in:
Matthew Kennedy 2021-11-25 04:59:31 -08:00 committed by GitHub
parent 342d161c78
commit 0badb6b2ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 12 deletions

View File

@ -245,7 +245,7 @@ static const void * getStructAddr(live_data_e structId) {
case LDS_TRIGGER_STATE:
return static_cast<trigger_state_s*>(&engine->triggerCentral.triggerState);
case LDS_AC_CONTROL:
return static_cast<ac_control_s*>(&engine->acState);
return static_cast<ac_control_s*>(&engine->module<AcController>().unmock());
case LDS_FUEL_PUMP:
return static_cast<fuel_pump_control_s*>(&engine->module<FuelPumpController>().unmock());
#if EFI_ELECTRONIC_THROTTLE_BODY

View File

@ -8,7 +8,7 @@ static Deadband<200> maxRpmDeadband;
static Deadband<5> maxCltDeadband;
static Deadband<5> maxTpsDeadband;
bool AcState::getAcState() {
bool AcController::getAcState() {
latest_usage_ac_control = getTimeNowSeconds();
auto rpm = Sensor::getOrZero(SensorType::Rpm);
@ -51,15 +51,19 @@ bool AcState::getAcState() {
return acButtonState;
}
bool AcState::updateAc() {
void AcController::onSlowCallback() {
bool isEnabled = getAcState();
m_acEnabled = isEnabled;
enginePins.acRelay.setValue(isEnabled);
#if EFI_TUNER_STUDIO
tsOutputChannels.acSwitchState = engine->acSwitchState;
tsOutputChannels.acState = isEnabled;
#endif // EFI_TUNER_STUDIO
return isEnabled;
}
bool AcController::isAcEnabled() const {
return m_acEnabled;
}

View File

@ -2,11 +2,14 @@
#include "ac_control_generated.h"
class AcState final : public ac_control_s {
class AcController final : public ac_control_s, public EngineModule {
public:
// Returns true if AC is currently active
bool updateAc();
void onSlowCallback() override;
bool isAcEnabled() const;
private:
bool getAcState();
bool m_acEnabled = false;
};

View File

@ -232,13 +232,12 @@ void Engine::periodicSlowCallback() {
runHardcodedFsio();
#endif /* EFI_FSIO */
bool acActive = acState.updateAc();
updateFans(acActive);
updateGppwm();
engine->engineModules.apply_all([](auto & m) { m.onSlowCallback(); });
updateFans(module<AcController>().unmock().isAcEnabled());
#if EFI_BOOST_CONTROL
updateBoostControl();
#endif // EFI_BOOST_CONTROL

View File

@ -31,6 +31,7 @@
#include "trigger_scheduler.h"
#include "fuel_pump.h"
#include "main_relay.h"
#include "ac_control.h"
#include "type_list.h"
#include "boost_control.h"
@ -110,7 +111,7 @@ protected:
class Engine final : public TriggerStateListener {
public:
Engine();
AcState acState;
// todo: technical debt: enableOverdwellProtection #3553
bool enableOverdwellProtection = true;
@ -138,6 +139,7 @@ public:
FuelPumpController,
MainRelayController,
AcController,
EngineModule // dummy placeholder so the previous entries can all have commas
> engineModules;