This commit is contained in:
rusefi 2017-11-16 14:44:53 -05:00
parent 7732d06dad
commit af1ca0b38f
3 changed files with 13 additions and 2 deletions

View File

@ -8,11 +8,13 @@
#include "adc_inputs.h" #include "adc_inputs.h"
#include "allsensors.h" #include "allsensors.h"
EXTERN_ENGINE;
#if !EFI_PROD_CODE #if !EFI_PROD_CODE
static int mockTps; static int mockTps;
#endif #endif /* EFI_PROD_CODE */
EXTERN_ENGINE; static percent_t mockPedalPosition = MOCK_UNDEFINED;
/** /**
* this allows unit tests to simulate TPS position * this allows unit tests to simulate TPS position
@ -23,6 +25,10 @@ void setMockTpsPosition(percent_t tpsPosition) {
#endif #endif
} }
void setMockPedalPosition(percent_t value) {
mockPedalPosition = value;
}
/** /**
* We are using one instance for read and another for modification, this is how we get lock-free thread-safety * We are using one instance for read and another for modification, this is how we get lock-free thread-safety
* *
@ -133,6 +139,9 @@ bool hasPedalPositionSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
} }
percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_SIGNATURE) { percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (mockPedalPosition != MOCK_UNDEFINED) {
return mockPedalPosition;
}
float voltage = getVoltageDivided("pPS", engineConfiguration->pedalPositionChannel); float voltage = getVoltageDivided("pPS", engineConfiguration->pedalPositionChannel);
float result = interpolate(engineConfiguration->throttlePedalUpVoltage, 0, engineConfiguration->throttlePedalWOTVoltage, 100, voltage); float result = interpolate(engineConfiguration->throttlePedalUpVoltage, 0, engineConfiguration->throttlePedalWOTVoltage, 100, voltage);

View File

@ -31,6 +31,7 @@ float getTPSVoltage(DECLARE_ENGINE_PARAMETER_SIGNATURE);
percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_SUFFIX); percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_SUFFIX);
void setBosch0280750009(DECLARE_ENGINE_PARAMETER_SIGNATURE); void setBosch0280750009(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void setMockTpsPosition(percent_t tpsPosition); void setMockTpsPosition(percent_t tpsPosition);
void setMockPedalPosition(percent_t value);
typedef struct { typedef struct {
efitimeus_t prevTime; efitimeus_t prevTime;

View File

@ -1107,6 +1107,7 @@ typedef struct {
} command_f_s; } command_f_s;
command_f_s commandsF[] = {{"mock_iat_voltage", setIatVoltage}, command_f_s commandsF[] = {{"mock_iat_voltage", setIatVoltage},
{"mock_pedal_position", setMockPedalPosition},
{"mock_maf_voltage", setMafVoltage}, {"mock_maf_voltage", setMafVoltage},
{"mock_afr_voltage", setAfrVoltage}, {"mock_afr_voltage", setAfrVoltage},
{"mock_tps_voltage", setTpsVoltage}, {"mock_tps_voltage", setTpsVoltage},