Add `Clutch Up Switch` option to`Activation Mode` combobox on `Shift Torque Reduction (Flat Shift)` dialog #7117

This commit is contained in:
kifir 2024-12-17 22:52:12 +02:00 committed by kifir23917
parent 6eb30ea69f
commit 348fe3eaa7
17 changed files with 145 additions and 18 deletions

View File

@ -28,6 +28,8 @@ namespace engine_configuration_defaults {
/* Other Sensor Inputs: */
constexpr switch_input_pin_e CLUTCH_DOWN_PIN = Gpio::Unassigned;
constexpr bool CLUTCH_DOWN_PIN_INVERTED = false;
constexpr switch_input_pin_e CLUTCH_UP_PIN = Gpio::Unassigned;
constexpr bool CLUTCH_UP_PIN_INVERTED = false;
/* Launch Control: */
constexpr switch_input_pin_e LAUNCH_ACTIVATE_PIN = Gpio::Unassigned;

View File

@ -605,6 +605,7 @@ typedef enum __attribute__ ((__packed__)) {
TORQUE_REDUCTION_BUTTON = 0,
LAUNCH_BUTTON = 1,
TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH = 2,
TORQUE_REDUCTION_CLUTCH_UP_SWITCH = 3,
} torqueReductionActivationMode_e;
typedef enum __attribute__ ((__packed__)) {

View File

@ -59,6 +59,14 @@ void ShiftTorqueReductionController::updateTriggerPinState() {
);
break;
}
case TORQUE_REDUCTION_CLUTCH_UP_SWITCH: {
updateTriggerPinState(
engineConfiguration->clutchUpPin,
engineConfiguration->clutchUpPinInverted,
engine->engineState.lua.clutchUpState
);
break;
}
default: {
break; // we shouldn't be here!
}

View File

@ -1445,7 +1445,7 @@ float tChargeAirDecrLimit;Maximum allowed rate of decrease allowed for the estim
pin_input_mode_e torqueReductionTriggerPinMode;
#define torqueReductionActivationMode_e_enum "Torque Reduction Button", "Launch Button", "Clutch Down Switch"
#define torqueReductionActivationMode_e_enum "Torque Reduction Button", "Launch Button", "Clutch Down Switch", "Clutch Up Switch"
custom torqueReductionActivationMode_e 1 bits, S08, @OFFSET@, [0:1], @@torqueReductionActivationMode_e_enum@@
torqueReductionActivationMode_e torqueReductionActivationMode;

View File

@ -5011,11 +5011,17 @@ dialog = tcuControls, "Transmission Settings"
field = "Clutch Down Inverted", clutchDownPinInverted, {clutchDownPin != 0}
field = "Clutch Down Mode", clutchDownPinMode, {clutchDownPin != 0}
dialog = ClutchUpDialog, "Clutch Up"
field = "Clutch Up", clutchUpPin
field = "Clutch Up Inverted", clutchUpPinInverted, {clutchUpPin != 0}
field = "Clutch Up Mode", clutchUpPinMode, {clutchUpPin != 0}
dialog = TorqueReductionActivationModeDialog, "Activation", yAxis
field = "Activation Mode", torqueReductionActivationMode
panel = TorqueReductionButtonDialog, {torqueReductionActivationMode == @@torqueReductionActivationMode_e_TORQUE_REDUCTION_BUTTON@@}
panel = LaunchButtonDialog, {torqueReductionActivationMode == @@torqueReductionActivationMode_e_LAUNCH_BUTTON@@}
panel = ClutchDownDialog, {torqueReductionActivationMode == @@torqueReductionActivationMode_e_TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH@@}
panel = ClutchUpDialog, {torqueReductionActivationMode == @@torqueReductionActivationMode_e_TORQUE_REDUCTION_CLUTCH_UP_SWITCH@@}
dialog = TorqueReductionSettings, "Settings"
field = "Limit Torque Reduction Time", limitTorqueReductionTime
@ -5028,7 +5034,7 @@ dialog = tcuControls, "Transmission Settings"
dialog = ShiftTorqueReductionSettingsDialog, "", yAxis
field = "Enable Shift Torque Reduction", torqueReductionEnabled
panel = TorqueReductionActivationModeDialog, {torqueReductionEnabled == 1}
panel = TorqueReductionSettings, {torqueReductionEnabled == 1 && ((torqueReductionActivationMode == @@torqueReductionActivationMode_e_TORQUE_REDUCTION_BUTTON@@) || (torqueReductionActivationMode == @@torqueReductionActivationMode_e_LAUNCH_BUTTON@@ && launchActivatePin != 0) || (torqueReductionActivationMode == @@torqueReductionActivationMode_e_TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH@@))}
panel = TorqueReductionSettings, {torqueReductionEnabled == 1 && ((torqueReductionActivationMode == @@torqueReductionActivationMode_e_TORQUE_REDUCTION_BUTTON@@) || (torqueReductionActivationMode == @@torqueReductionActivationMode_e_LAUNCH_BUTTON@@ && launchActivatePin != 0) || (torqueReductionActivationMode == @@torqueReductionActivationMode_e_TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH@@) || (torqueReductionActivationMode == @@torqueReductionActivationMode_e_TORQUE_REDUCTION_CLUTCH_UP_SWITCH@@))}
dialog = ShiftTorqueReductionDialog, "", border
panel = ShiftTorqueReductionSettingsDialog, West

View File

@ -12,6 +12,8 @@ enum class TestSwitchPin {
LAUNCH,
CLUTCH_DOWN,
LUA_CLUTCH_DOWN,
CLUTCH_UP,
LUA_CLUTCH_UP,
};
struct ShiftTorqueReductionSwitchParams {

View File

@ -10,7 +10,8 @@ const EngineConfig ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG = Engi
.setTorqueReductionEnabled(true)
.setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN)
.setLaunchActivatePin(TEST_LAUNCH_BUTTON_PIN)
.setClutchDownPin(TEST_CLUTCH_DOWN_PIN);
.setClutchDownPin(TEST_CLUTCH_DOWN_PIN)
.setClutchUpPin(TEST_CLUTCH_UP_PIN);
void ShiftTorqueReductionSwitchTestBase::SetUp() {
TestBase::SetUp();
@ -56,6 +57,14 @@ void ShiftTorqueReductionSwitchTestBase::setPinState(const TestSwitchPin pin, co
getTestLuaScriptExecutor().setClutchDownState(state);
break;
}
case TestSwitchPin::CLUTCH_UP: {
setMockState(TEST_CLUTCH_UP_PIN, state);;
break;
}
case TestSwitchPin::LUA_CLUTCH_UP: {
getTestLuaScriptExecutor().setClutchUpState(state);
break;
}
default: {
FAIL() << "Unexpected pin:" << static_cast<int>(pin);
break;

View File

@ -17,6 +17,7 @@ protected:
static constexpr switch_input_pin_e TEST_TORQUE_REDUCTION_BUTTON_PIN = Gpio::F15;
static constexpr switch_input_pin_e TEST_LAUNCH_BUTTON_PIN = Gpio::G15;
static constexpr switch_input_pin_e TEST_CLUTCH_DOWN_PIN = Gpio::E15;
static constexpr switch_input_pin_e TEST_CLUTCH_UP_PIN = Gpio::D15;
void SetUp() override;

View File

@ -59,6 +59,14 @@ namespace {
.setClutchDownPinInverted(true),
/* expectedIsTorqueReductionTriggerPinValid = */ true,
/* description = */ "CLUTCH_DOWN"
},
ShiftTorqueReductionSwitchParams {
/* inputPin = */ TestSwitchPin::CLUTCH_UP,
/* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone()
.setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH)
.setClutchUpPinInverted(true),
/* expectedIsTorqueReductionTriggerPinValid = */ true,
/* description = */ "CLUTCH_UP"
}
)
);

View File

@ -22,6 +22,8 @@ namespace {
TestSwitchPin::LAUNCH,
TestSwitchPin::CLUTCH_DOWN,
TestSwitchPin::LUA_CLUTCH_DOWN,
TestSwitchPin::CLUTCH_UP,
TestSwitchPin::LUA_CLUTCH_UP,
};
const bool expectedIsTorqueReductionTriggerPinValid =
engine->shiftTorqueReductionController.isTorqueReductionTriggerPinValid;
@ -171,6 +173,47 @@ namespace {
.setClutchDownPinInverted(true),
/* expectedIsTorqueReductionTriggerPinValid = */ false,
/* description = */ "LUA_CLUTCH_DOWN (pinInverted = true)"
},
ShiftTorqueReductionSwitchParams {
/* inputPin = */ TestSwitchPin::CLUTCH_UP,
/* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone()
.setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH),
/* expectedIsTorqueReductionTriggerPinValid = */ true,
/* description = */ "CLUTCH_UP"
},
ShiftTorqueReductionSwitchParams {
/* inputPin = */ TestSwitchPin::CLUTCH_UP,
/* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone()
.setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH)
.setClutchUpPinInverted(false),
/* expectedIsTorqueReductionTriggerPinValid = */ true,
/* description = */ "CLUTCH_UP (pinInverted = false)"
},
ShiftTorqueReductionSwitchParams {
/* inputPin = */ TestSwitchPin::LUA_CLUTCH_UP,
/* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone()
.setClutchUpPin(Gpio::Unassigned)
.setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH),
/* expectedIsTorqueReductionTriggerPinValid = */ false,
/* description = */ "LUA_CLUTCH_UP"
},
ShiftTorqueReductionSwitchParams {
/* inputPin = */ TestSwitchPin::LUA_CLUTCH_UP,
/* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone()
.setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH)
.setClutchUpPin(Gpio::Unassigned)
.setClutchUpPinInverted(false),
/* expectedIsTorqueReductionTriggerPinValid = */ false,
/* description = */ "LUA_CLUTCH_UP (pinInverted = false)"
},
ShiftTorqueReductionSwitchParams {
/* inputPin = */ TestSwitchPin::LUA_CLUTCH_UP,
/* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone()
.setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH)
.setClutchUpPin(Gpio::Unassigned)
.setClutchUpPinInverted(true),
/* expectedIsTorqueReductionTriggerPinValid = */ false,
/* description = */ "LUA_CLUTCH_UP (pinInverted = true)"
}
)
);

View File

@ -20,6 +20,16 @@ EngineConfig EngineConfig::setClutchDownPinInverted(const std::optional<bool> va
return *this;
}
EngineConfig EngineConfig::setClutchUpPin(const std::optional<switch_input_pin_e> value) {
m_clutchUpPin = value;
return *this;
}
EngineConfig EngineConfig::setClutchUpPinInverted(const std::optional<bool> value) {
m_clutchUpPinInverted = value;
return *this;
}
EngineConfig EngineConfig::setLaunchActivatePin(const std::optional<switch_input_pin_e> value) {
m_launchActivatePin = value;
return *this;

View File

@ -13,6 +13,8 @@ public:
// Other Sensor Inputs
std::optional<switch_input_pin_e> getClutchDownPin() const { return m_clutchDownPin; }
std::optional<bool> getClutchDownPinInverted() const { return m_clutchDownPinInverted; }
std::optional<switch_input_pin_e> getClutchUpPin() const { return m_clutchUpPin; }
std::optional<bool> getClutchUpPinInverted() const { return m_clutchUpPinInverted; }
// Launch Control
std::optional<switch_input_pin_e> getLaunchActivatePin() const { return m_launchActivatePin; }
@ -90,6 +92,8 @@ public:
// Other Sensor Inputs
EngineConfig setClutchDownPin(std::optional<switch_input_pin_e> value);
EngineConfig setClutchDownPinInverted(std::optional<bool> value);
EngineConfig setClutchUpPin(std::optional<switch_input_pin_e> value);
EngineConfig setClutchUpPinInverted(std::optional<bool> value);
// Launch Control
EngineConfig setLaunchActivatePin(std::optional<switch_input_pin_e> value);
@ -159,6 +163,8 @@ private:
// Other Sensor Inputs
std::optional<switch_input_pin_e> m_clutchDownPin;
std::optional<bool> m_clutchDownPinInverted;
std::optional<switch_input_pin_e> m_clutchUpPin;
std::optional<bool> m_clutchUpPinInverted;
// Launch Control
std::optional<switch_input_pin_e> m_launchActivatePin;

View File

@ -39,6 +39,8 @@ void TestBase<GtestBase>::setUpEngineConfiguration(const EngineConfig& config) {
// Other Sensor Inputs
getTestEngineConfiguration().configureClutchDownPin(config.getClutchDownPin());
getTestEngineConfiguration().configureClutchDownPinInverted(config.getClutchDownPinInverted());
getTestEngineConfiguration().configureClutchUpPin(config.getClutchUpPin());
getTestEngineConfiguration().configureClutchUpPinInverted(config.getClutchUpPinInverted());
// Launch Control
getTestEngineConfiguration().configureLaunchActivatePin(config.getLaunchActivatePin());

View File

@ -34,6 +34,28 @@ void TestEngineConfiguration::configureClutchDownPinInverted(const std::optional
}
}
void TestEngineConfiguration::configureClutchUpPin(const std::optional<switch_input_pin_e> pin) {
if (pin.has_value()) {
engineConfiguration->clutchUpPin = pin.value();
} else {
ASSERT_EQ(
engineConfiguration->clutchUpPin,
engine_configuration_defaults::CLUTCH_UP_PIN
); // check default value
}
}
void TestEngineConfiguration::configureClutchUpPinInverted(const std::optional<bool> pinInverted) {
if (pinInverted.has_value()) {
engineConfiguration->clutchUpPinInverted = pinInverted.value();
} else {
ASSERT_EQ(
engineConfiguration->clutchUpPinInverted,
engine_configuration_defaults::CLUTCH_UP_PIN_INVERTED
); // check default value
}
}
void TestEngineConfiguration::configureLaunchControlEnabled(const std::optional<bool> launchControlEnabled) {
if (launchControlEnabled.has_value()) {
engineConfiguration->launchControlEnabled = launchControlEnabled.value();

View File

@ -13,6 +13,8 @@ public:
// Other Sensor Inputs
void configureClutchDownPin(std::optional<switch_input_pin_e> pin);
void configureClutchDownPinInverted(std::optional<bool> pinInverted);
void configureClutchUpPin(std::optional<switch_input_pin_e> pin);
void configureClutchUpPinInverted(std::optional<bool> pinInverted);
// Launch Control Settings
void configureLaunchControlEnabled(std::optional<bool> launchControlEnabled);

View File

@ -25,6 +25,10 @@ void TestLuaScriptExecutor::setClutchDownState(const bool state) {
executeFormattedLuaScript("setClutchDownState(%s);", toLuaBoolean(state));
}
void TestLuaScriptExecutor::setClutchUpState(const bool state) {
executeFormattedLuaScript("setClutchUpState(%s);", toLuaBoolean(state));
}
void TestLuaScriptExecutor::setTorqueReductionState(const bool state) {
executeFormattedLuaScript("setTorqueReductionState(%s);", toLuaBoolean(state));
}

View File

@ -9,6 +9,7 @@ public:
static TestLuaScriptExecutor& getInstance();
void setClutchDownState(bool state);
void setClutchUpState(bool state);
void setTorqueReductionState(bool state);
void setSparkSkipRatio(float sparkSkipRatio);
void setSparkHardSkipRatio(float sparkSkipRatio);