lua pedal is a thing

This commit is contained in:
rusefillc 2024-11-11 20:35:02 -05:00
parent 4e690dfc18
commit 73fcb5e490
2 changed files with 8 additions and 17 deletions

View File

@ -163,12 +163,6 @@ bool EtbController::init(dc_function_e function, DcMotor *motor, pid_s *pidParam
// If we are a throttle, require redundant TPS sensor
if (isEtbMode()) {
// We don't need to init throttles, so nothing to do here.
if (!hasPedal) {
etbErrorCode = (int8_t)TpsState::PpsError;
return false;
}
// If no sensor is configured for this throttle, skip initialization.
if (!Sensor::hasSensor(functionToTpsSensor(function))) {
etbErrorCode = (int8_t)TpsState::TpsError;
@ -937,9 +931,6 @@ PUBLIC_API_WEAK ValueProvider3D* pedal2TpsProvider() {
void doInitElectronicThrottle() {
bool hasPedal = Sensor::hasSensor(SensorType::AcceleratorPedalPrimary);
#if EFI_UNIT_TEST
printf("doInitElectronicThrottle %s\n", boolToString(hasPedal));
#endif // EFI_UNIT_TEST
bool anyEtbConfigured = false;
@ -960,7 +951,7 @@ void doInitElectronicThrottle() {
auto pid = getPidForDcFunction(func);
bool dcConfigured = controller->init(func, motor, pid, pedal2TpsProvider(), hasPedal);
bool dcConfigured = controller->init(func, motor, pid, pedal2TpsProvider(), false);
bool etbConfigured = dcConfigured && controller->isEtbMode();
anyEtbConfigured |= etbConfigured;
}

View File

@ -77,10 +77,10 @@ TEST(etb, initializationSingleThrottle) {
Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 0);
// Expect mock0 to be init as throttle 1, and PID params
EXPECT_CALL(mocks[0], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true));
EXPECT_CALL(mocks[0], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), false)).WillOnce(Return(true));
// Expect mock1 to be init as none
EXPECT_CALL(mocks[1], init(DC_None, _, _, _, true)).Times(0);
EXPECT_CALL(mocks[1], init(DC_None, _, _, _, false)).Times(0);
doInitElectronicThrottle();
}
@ -105,10 +105,10 @@ TEST(etb, initializationSingleThrottleInSecondSlot) {
Sensor::setMockValue(SensorType::AcceleratorPedalPrimary, 0, false);
// Expect mock0 to be init as none
EXPECT_CALL(mocks[0], init(DC_None, _, _, _, true)).Times(0);
EXPECT_CALL(mocks[0], init(DC_None, _, _, _, false)).Times(0);
// Expect mock1 to be init as throttle 1, and PID params
EXPECT_CALL(mocks[1], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true));
EXPECT_CALL(mocks[1], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), false)).WillOnce(Return(true));
doInitElectronicThrottle();
}
@ -138,10 +138,10 @@ TEST(etb, initializationDualThrottle) {
engineConfiguration->etbFunctions[1] = DC_Throttle2;
// Expect mock0 to be init as throttle 1, and PID params
EXPECT_CALL(mocks[0], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true));
EXPECT_CALL(mocks[0], init(DC_Throttle1, _, &engineConfiguration->etb, Ne(nullptr), false)).WillOnce(Return(true));
// Expect mock1 to be init as throttle 2, and PID params
EXPECT_CALL(mocks[1], init(DC_Throttle2, _, &engineConfiguration->etb, Ne(nullptr), true)).WillOnce(Return(true));
EXPECT_CALL(mocks[1], init(DC_Throttle2, _, &engineConfiguration->etb, Ne(nullptr), false)).WillOnce(Return(true));
doInitElectronicThrottle();
}
@ -246,7 +246,7 @@ TEST(etb, initializationNoThrottles) {
Sensor::setMockValue(SensorType::Tps1Primary, 0);
Sensor::setMockValue(SensorType::Tps1, 0.0f, false);
EXPECT_NO_FATAL_ERROR(initElectronicThrottle());
EXPECT_FATAL_ERROR(initElectronicThrottle());
}
TEST(etb, idlePlumbing) {