Delayed A/C compressor switch #922

This commit is contained in:
rusefi 2019-09-08 21:05:03 -04:00
parent 9417adcbd6
commit e79287f537
6 changed files with 17 additions and 3 deletions

View File

@ -280,7 +280,7 @@ void setMiataNA6_MAP_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
// W57 PE3 A/C compressor relay out
boardConfiguration->acRelayPin = GPIOE_3;
// W58 PE4 A/C fan relay out
#endif
#endif /* EFI_UNIT_TEST */
miataNAcommon(PASS_CONFIG_PARAMETER_SIGNATURE);
}

View File

@ -316,7 +316,12 @@ public:
engine->clutchDownState = efiReadPin(CONFIGB(clutchDownPin));
}
if (hasAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE)) {
engine->acSwitchState = getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
bool result = getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
if (engine->acSwitchState != result) {
engine->acSwitchState = result;
engine->acSwitchLastChangeTime = getTimeNowUs();
}
engine->acSwitchState = result;
}
if (CONFIGB(clutchUpPin) != GPIO_UNASSIGNED) {
engine->clutchUpState = efiReadPin(CONFIGB(clutchUpPin));

View File

@ -80,6 +80,7 @@ public:
operation_mode_e getOperationMode(DECLARE_ENGINE_PARAMETER_SIGNATURE);
int globalSparkIdCoutner = 0;
#if !EFI_PROD_CODE
@ -205,7 +206,10 @@ public:
bool clutchUpState = false;
bool clutchDownState = false;
bool brakePedalState = false;
// todo: extract some helper which would contain boolean state and most recent toggle time?
bool acSwitchState = false;
efitimeus_t acSwitchLastChangeTime = 0;
bool isRunningPwmTest = false;

View File

@ -44,7 +44,7 @@ typedef enum {
LE_METHOD_INTAKE_AIR = 108,
LE_METHOD_VBATT = 109,
LE_METHOD_AC_TOGGLE = 110,
LE_METHOD_FSIO_SETTING = 111,
LE_METHOD_TIME_SINCE_AC_TOGGLE = 111,
LE_METHOD_KNOCK = 112,
LE_METHOD_FSIO_TABLE = 113,
LE_METHOD_SELF = 114,
@ -57,6 +57,7 @@ typedef enum {
LE_METHOD_STARTUP_FUEL_PUMP_DURATION = 121,
LE_METHOD_IN_SHUTDOWN = 122,
LE_METHOD_FSIO_DIGITAL_INPUT = 123,
LE_METHOD_FSIO_SETTING = 124,
Force_4b_le_action = ENUM_32_BITS,

View File

@ -51,6 +51,7 @@ static LENameOrdinalPair leFan(LE_METHOD_FAN, "fan");
static LENameOrdinalPair leCoolant(LE_METHOD_COOLANT, "coolant");
static LENameOrdinalPair leIsCoolantBroken(LE_METHOD_IS_COOLANT_BROKEN, "is_clt_broken");
static LENameOrdinalPair leAcToggle(LE_METHOD_AC_TOGGLE, "ac_on_switch");
static LENameOrdinalPair leAcToggle(LE_METHOD_TIME_SINCE_AC_TOGGLE, "time_since_ac_on_switch");
static LENameOrdinalPair leFanOnSetting(LE_METHOD_FAN_ON_SETTING, "fan_on_setting");
static LENameOrdinalPair leFanOffSetting(LE_METHOD_FAN_OFF_SETTING, "fan_off_setting");
static LENameOrdinalPair leTimeSinceBoot(LE_METHOD_TIME_SINCE_BOOT, "time_since_boot");
@ -113,6 +114,8 @@ float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
switch (action) {
case LE_METHOD_FAN:
return enginePins.fanRelay.getLogicValue();
case LE_METHOD_TIME_SINCE_AC_TOGGLE:
return (getTimeNowUs() - engine->acSwitchLastChangeTime) / US_PER_SECOND_F;
case LE_METHOD_AC_TOGGLE:
return getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
case LE_METHOD_COOLANT:

View File

@ -14,6 +14,7 @@
#include "rusefi_types.h"
#define US_PER_SECOND 1000000
#define US_PER_SECOND_F 1000000.0
#define US_PER_SECOND_LL 1000000LL
#define MS2US(MS_TIME) ((MS_TIME) * 1000)