Fix issues from #634 where launch would not engage if VSS was not used.

Added default value in updates and added a new unit test for this
This commit is contained in:
Josh Stewart 2024-08-14 10:50:47 +10:00
parent 8472f1dd1e
commit ec312a119d
4 changed files with 23 additions and 2 deletions

View File

@ -708,7 +708,7 @@ void boostControl(void)
{
currentStatus.flexBoostCorrection = table2D_getValue(&flexBoostTable, currentStatus.ethanolPct);
currentStatus.boostTarget += currentStatus.flexBoostCorrection;
currentStatus.boostTarget = min(currentStatus.boostTarget, (uint16_t)511);
currentStatus.boostTarget = min(currentStatus.boostTarget, (uint16_t)511U);
}
else
{

View File

@ -880,7 +880,12 @@ int8_t correctionSoftLaunch(int8_t advance)
{
byte ignSoftLaunchValue = advance;
//SoftCut rev limit for 2-step launch control.
if (configPage6.launchEnabled && currentStatus.clutchTrigger && (currentStatus.clutchEngagedRPM < ((unsigned int)(configPage6.flatSArm) * 100)) && (currentStatus.RPM > ((unsigned int)(configPage6.lnchSoftLim) * 100)) && (currentStatus.TPS >= configPage10.lnchCtrlTPS) && ( (configPage2.vssMode > 0) && (currentStatus.vss <= configPage10.lnchCtrlVss) ) )
if( configPage6.launchEnabled && currentStatus.clutchTrigger && \
(currentStatus.clutchEngagedRPM < ((unsigned int)(configPage6.flatSArm) * 100)) && \
(currentStatus.RPM > ((unsigned int)(configPage6.lnchSoftLim) * 100)) && \
(currentStatus.TPS >= configPage10.lnchCtrlTPS) && \
( (configPage2.vssMode == 0) || ((configPage2.vssMode > 0) && (currentStatus.vss <= configPage10.lnchCtrlVss)) ) \
)
{
currentStatus.launchingSoft = true;
BIT_SET(currentStatus.status2, BIT_STATUS2_SLAUNCH);

View File

@ -762,6 +762,9 @@ void doUpdates(void)
if(configPage2.unused1_126_1 == true) { configPage4.CANBroadcastProtocol = CAN_BROADCAST_PROTOCOL_BMW; } //unused1_126_1 was canBMWCluster
if(configPage2.unused1_126_2 == true) { configPage4.CANBroadcastProtocol = CAN_BROADCAST_PROTOCOL_VAG; } //unused1_126_2 was canVAGCluster
//VSS max limit on launch control
configPage10.lnchCtrlVss = 255;
writeAllConfig();
storeEEPROMVersion(24);
}

View File

@ -550,11 +550,14 @@ static void setup_correctionSoftLaunch(void) {
configPage6.flatSArm = 20;
configPage6.lnchSoftLim = 40;
configPage10.lnchCtrlTPS = 80;
configPage10.lnchCtrlVss = 50;
configPage2.vssMode = 2;
currentStatus.clutchTrigger = 1;
currentStatus.clutchEngagedRPM = ((configPage6.flatSArm) * 100) - 100;
currentStatus.RPM = ((configPage6.lnchSoftLim) * 100) + 100;
currentStatus.TPS = configPage10.lnchCtrlTPS + 1;
currentStatus.vss = 30;
}
static void test_correctionSoftLaunch_on(void) {
@ -623,6 +626,15 @@ static void test_correctionSoftLaunch_off_tpslow(void) {
TEST_ASSERT_BIT_LOW(BIT_STATUS2_SLAUNCH, currentStatus.status2);
}
static void test_correctionSoftLaunch_off_vsslimit(void) {
setup_correctionSoftLaunch();
currentStatus.vss = 100; //VSS above limit of 80
TEST_ASSERT_EQUAL(-8, correctionSoftLaunch(-8));
TEST_ASSERT_FALSE(currentStatus.launchingSoft);
TEST_ASSERT_BIT_LOW(BIT_STATUS2_SLAUNCH, currentStatus.status2);
}
static void test_correctionSoftLaunch(void) {
RUN_TEST_P(test_correctionSoftLaunch_on);
RUN_TEST_P(test_correctionSoftLaunch_off_disabled);
@ -630,6 +642,7 @@ static void test_correctionSoftLaunch(void) {
RUN_TEST_P(test_correctionSoftLaunch_off_clutchrpmlow);
RUN_TEST_P(test_correctionSoftLaunch_off_rpmlimit);
RUN_TEST_P(test_correctionSoftLaunch_off_tpslow);
RUN_TEST_P(test_correctionSoftLaunch_off_vsslimit);
}
extern int8_t correctionSoftFlatShift(int8_t advance);