migrating to SensorType::Rpm API

This commit is contained in:
Andrey 2022-01-20 23:32:59 -05:00
parent 9313bcca92
commit cda2b711cf
8 changed files with 10 additions and 10 deletions

View File

@ -68,7 +68,7 @@ float WallFuel::adjust(float desiredMassGrams) {
} }
// Ignore really slow RPM // Ignore really slow RPM
int rpm = GET_RPM(); int rpm = Sensor::getOrZero(SensorType::Rpm);
if (rpm < 100) { if (rpm < 100) {
return desiredMassGrams; return desiredMassGrams;
} }

View File

@ -132,7 +132,7 @@ static void handleGetDataRequest(const CANRxFrame& rx) {
obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Map)); obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Map));
break; break;
case PID_RPM: case PID_RPM:
obdSendValue(_1_MODE, pid, 2, GET_RPM() * ODB_RPM_MULT); // rotation/min. (A*256+B)/4 obdSendValue(_1_MODE, pid, 2, Sensor::getOrZero(SensorType::Rpm) * ODB_RPM_MULT); // rotation/min. (A*256+B)/4
break; break;
case PID_SPEED: case PID_SPEED:
obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::VehicleSpeed)); obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::VehicleSpeed));

View File

@ -235,7 +235,7 @@ void InjectionEvent::onTriggerTooth(size_t trgEventIndex, int rpm, efitick_t now
if (printFuelDebug) { if (printFuelDebug) {
InjectorOutputPin *output = outputs[0]; InjectorOutputPin *output = outputs[0];
printf("handleFuelInjectionEvent fuelout %s injection_duration %dus engineCycleDuration=%.1fms\t\n", output->name, (int)durationUs, printf("handleFuelInjectionEvent fuelout %s injection_duration %dus engineCycleDuration=%.1fms\t\n", output->name, (int)durationUs,
(int)MS2US(getCrankshaftRevolutionTimeMs(GET_RPM())) / 1000.0); (int)MS2US(getCrankshaftRevolutionTimeMs(Sensor::getOrZero(SensorType::Rpm))) / 1000.0);
} }
#endif /*EFI_PRINTF_FUEL_DETAILS */ #endif /*EFI_PRINTF_FUEL_DETAILS */
@ -550,7 +550,7 @@ void updatePrimeInjectionPulseState() {
static void showMainInfo(Engine *engine) { static void showMainInfo(Engine *engine) {
#if EFI_PROD_CODE #if EFI_PROD_CODE
int rpm = GET_RPM(); int rpm = Sensor::getOrZero(SensorType::Rpm);
float el = getFuelingLoad(); float el = getFuelingLoad();
efiPrintf("rpm %d engine_load %.2f", rpm, el); efiPrintf("rpm %d engine_load %.2f", rpm, el);
efiPrintf("fuel %.2fms timing %.2f", engine->injectionDuration, engine->engineState.timingAdvance[0]); efiPrintf("fuel %.2fms timing %.2f", engine->injectionDuration, engine->engineState.timingAdvance[0]);

View File

@ -172,7 +172,7 @@ void postMapState(TunerStudioOutputChannels *tsOutputChannels) {
#endif /* EFI_TUNER_STUDIO */ #endif /* EFI_TUNER_STUDIO */
void refreshMapAveragingPreCalc() { void refreshMapAveragingPreCalc() {
int rpm = GET_RPM(); int rpm = Sensor::getOrZero(SensorType::Rpm);
if (isValidRpm(rpm)) { if (isValidRpm(rpm)) {
MAP_sensor_config_s * c = &engineConfiguration->map; MAP_sensor_config_s * c = &engineConfiguration->map;
angle_t start = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle); angle_t start = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle);
@ -211,7 +211,7 @@ void mapAveragingTriggerCallback(
if (index != (uint32_t)engineConfiguration->mapAveragingSchedulingAtIndex) if (index != (uint32_t)engineConfiguration->mapAveragingSchedulingAtIndex)
return; return;
int rpm = GET_RPM(); int rpm = Sensor::getOrZero(SensorType::Rpm);
if (!isValidRpm(rpm)) { if (!isValidRpm(rpm)) {
return; return;
} }

View File

@ -326,7 +326,7 @@ static void onTdcCallback(void *) {
} }
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */
itoa10(rpmBuffer, GET_RPM()); itoa10(rpmBuffer, Sensor::getOrZero(SensorType::Rpm));
#if EFI_ENGINE_SNIFFER #if EFI_ENGINE_SNIFFER
waveChart.startDataCollection(); waveChart.startDataCollection();
#endif #endif

View File

@ -230,7 +230,7 @@ static void startDwellByTurningSparkPinHigh(IgnitionEvent *event, IgnitionOutput
// todo: no reason for this to be disabled in unit_test mode?! // todo: no reason for this to be disabled in unit_test mode?!
#if ! EFI_UNIT_TEST #if ! EFI_UNIT_TEST
if (GET_RPM() > 2 * engineConfiguration->cranking.rpm) { if (Sensor::getOrZero(SensorType::Rpm) > 2 * engineConfiguration->cranking.rpm) {
const char *outputName = output->getName(); const char *outputName = output->getName();
if (prevSparkName == outputName && getCurrentIgnitionMode() != IM_ONE_COIL) { if (prevSparkName == outputName && getCurrentIgnitionMode() != IM_ONE_COIL) {
warning(CUSTOM_OBD_SKIPPED_SPARK, "looks like skipped spark event %d %s", getRevolutionCounter(), outputName); warning(CUSTOM_OBD_SKIPPED_SPARK, "looks like skipped spark event %d %s", getRevolutionCounter(), outputName);

View File

@ -606,7 +606,7 @@ void TriggerState::decodeTriggerEvent(
} else { } else {
efiPrintf("%srpm=%d time=%d eventIndex=%d gapIndex=%d: gap=%.3f expected from %.3f to %.3f error=%s", efiPrintf("%srpm=%d time=%d eventIndex=%d gapIndex=%d: gap=%.3f expected from %.3f to %.3f error=%s",
triggerConfiguration.PrintPrefix, triggerConfiguration.PrintPrefix,
GET_RPM(), (int)Sensor::getOrZero(SensorType::Rpm),
/* cast is needed to make sure we do not put 64 bit value to stack*/ (int)getTimeNowSeconds(), /* cast is needed to make sure we do not put 64 bit value to stack*/ (int)getTimeNowSeconds(),
currentCycle.current_index, currentCycle.current_index,
i, i,

View File

@ -344,7 +344,7 @@ void EngineTestHelper::applyTriggerWaveform() {
void EngineTestHelper::assertRpm(int expectedRpm, const char *msg) { void EngineTestHelper::assertRpm(int expectedRpm, const char *msg) {
Engine *engine = &this->engine; Engine *engine = &this->engine;
EXPECT_EQ(expectedRpm, GET_RPM()) << msg; EXPECT_EQ(expectedRpm, Sensor::getOrZero(SensorType::Rpm)) << msg;
} }
void setupSimpleTestEngineWithMaf(EngineTestHelper *eth, injection_mode_e injectionMode, void setupSimpleTestEngineWithMaf(EngineTestHelper *eth, injection_mode_e injectionMode,