only: encapsulation and ACR bugfix
This commit is contained in:
parent
d3e3db0192
commit
52a68b122f
|
@ -175,7 +175,7 @@ bool InjectionEvent::update() {
|
|||
|
||||
if (!isSimultaneous && !output->isInitialized()) {
|
||||
// todo: extract method for this index math
|
||||
warning(ObdCode::CUSTOM_OBD_INJECTION_NO_PIN_ASSIGNED, "no_pin_inj #%s", output->name);
|
||||
warning(ObdCode::CUSTOM_OBD_INJECTION_NO_PIN_ASSIGNED, "no_pin_inj #%s", output->getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -126,7 +126,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase
|
|||
#if EFI_PRINTF_FUEL_DETAILS
|
||||
if (printFuelDebug) {
|
||||
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->getName(), (int)durationUs,
|
||||
(int)MS2US(getCrankshaftRevolutionTimeMs(Sensor::getOrZero(SensorType::Rpm))) / 1000.0);
|
||||
}
|
||||
#endif /*EFI_PRINTF_FUEL_DETAILS */
|
||||
|
|
|
@ -28,7 +28,7 @@ static const char *prevSparkName = nullptr;
|
|||
|
||||
static void fireSparkBySettingPinLow(IgnitionEvent *event, IgnitionOutputPin *output) {
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
efiPrintf("spark goes low %d %s %d current=%d cnt=%d id=%d", getRevolutionCounter(), output->name, (int)getTimeNowUs(),
|
||||
efiPrintf("spark goes low %d %s %d current=%d cnt=%d id=%d", getRevolutionCounter(), output->getName(), (int)getTimeNowUs(),
|
||||
output->currentLogicValue, output->outOfOrder, event->sparkId);
|
||||
#endif /* SPARK_EXTREME_LOGGING */
|
||||
|
||||
|
@ -149,7 +149,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
|
|||
|
||||
#if FUEL_MATH_EXTREME_LOGGING
|
||||
if (printFuelDebug) {
|
||||
printf("addIgnitionEvent %s angle=%.1f\n", output->name, dwellStartAngle);
|
||||
printf("addIgnitionEvent %s angle=%.1f\n", output->getName(), dwellStartAngle);
|
||||
}
|
||||
// efiPrintf("addIgnitionEvent %s ind=%d", output->name, event->dwellPosition->eventIndex);
|
||||
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
||||
|
@ -157,21 +157,21 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
|
|||
|
||||
static void chargeTrailingSpark(IgnitionOutputPin* pin) {
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
efiPrintf("chargeTrailingSpark %s", pin->name);
|
||||
efiPrintf("chargeTrailingSpark %s", pin->getName());
|
||||
#endif /* SPARK_EXTREME_LOGGING */
|
||||
pin->setHigh();
|
||||
}
|
||||
|
||||
static void fireTrailingSpark(IgnitionOutputPin* pin) {
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
efiPrintf("fireTrailingSpark %s", pin->name);
|
||||
efiPrintf("fireTrailingSpark %s", pin->getName());
|
||||
#endif /* SPARK_EXTREME_LOGGING */
|
||||
pin->setLow();
|
||||
}
|
||||
|
||||
static void overFireSparkAndPrepareNextSchedule(IgnitionEvent *event) {
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
efiPrintf("overFireSparkAndPrepareNextSchedule %s", event->outputs[0]->name);
|
||||
efiPrintf("overFireSparkAndPrepareNextSchedule %s", event->outputs[0]->getName());
|
||||
#endif /* SPARK_EXTREME_LOGGING */
|
||||
fireSparkAndPrepareNextSchedule(event);
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ static void startDwellByTurningSparkPinHigh(IgnitionEvent *event, IgnitionOutput
|
|||
|
||||
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
efiPrintf("spark goes high %d %s %d current=%d cnt=%d id=%d", getRevolutionCounter(), output->name, (int)getTimeNowUs(),
|
||||
efiPrintf("spark goes high %d %s %d current=%d cnt=%d id=%d", getRevolutionCounter(), output->getName(), (int)getTimeNowUs(),
|
||||
output->currentLogicValue, output->outOfOrder, event->sparkId);
|
||||
#endif /* SPARK_EXTREME_LOGGING */
|
||||
|
||||
|
@ -349,7 +349,7 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
|
|||
*/
|
||||
if (!limitedSpark) {
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
efiPrintf("scheduling sparkUp %d %s now=%d %d later id=%d", getRevolutionCounter(), event->getOutputForLoggins()->name, (int)getTimeNowUs(), (int)angleOffset,
|
||||
efiPrintf("scheduling sparkUp %d %s now=%d %d later id=%d", getRevolutionCounter(), event->getOutputForLoggins()->getName(), (int)getTimeNowUs(), (int)angleOffset,
|
||||
event->sparkId);
|
||||
#endif /* SPARK_EXTREME_LOGGING */
|
||||
|
||||
|
@ -382,11 +382,11 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
|
|||
|
||||
if (scheduled) {
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
efiPrintf("scheduling sparkDown %d %s now=%d later id=%d", getRevolutionCounter(), event->getOutputForLoggins()->name, (int)getTimeNowUs(), event->sparkId);
|
||||
efiPrintf("scheduling sparkDown %d %s now=%d later id=%d", getRevolutionCounter(), event->getOutputForLoggins()->getName(), (int)getTimeNowUs(), event->sparkId);
|
||||
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
||||
} else {
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
efiPrintf("to queue sparkDown %d %s now=%d for id=%d angle=%.1f", getRevolutionCounter(), event->getOutputForLoggins()->name, (int)getTimeNowUs(), event->sparkId, sparkAngle);
|
||||
efiPrintf("to queue sparkDown %d %s now=%d for id=%d angle=%.1f", getRevolutionCounter(), event->getOutputForLoggins()->getName(), (int)getTimeNowUs(), event->sparkId, sparkAngle);
|
||||
#endif /* SPARK_EXTREME_LOGGING */
|
||||
|
||||
if (!limitedSpark && engine->enableOverdwellProtection) {
|
||||
|
@ -426,7 +426,7 @@ void initializeIgnitionActions() {
|
|||
|
||||
static void prepareIgnitionSchedule() {
|
||||
ScopePerf perf(PE::PrepareIgnitionSchedule);
|
||||
|
||||
|
||||
/**
|
||||
* TODO: warning. there is a bit of a hack here, todo: improve.
|
||||
* currently output signals/times dwellStartTimer from the previous revolutions could be
|
||||
|
|
|
@ -165,9 +165,9 @@ EnginePins::EnginePins() :
|
|||
triggerDecoderErrorPin("led: trigger debug", CONFIG_PIN_OFFSETS(triggerError)),
|
||||
speedoOut("speedoOut", CONFIG_OFFSET(speedometerOutputPin))
|
||||
{
|
||||
hpfpValve.name = PROTOCOL_HPFP_NAME;
|
||||
hpfpValve.setName(PROTOCOL_HPFP_NAME);
|
||||
#if EFI_HD_ACR
|
||||
harleyAcr.name = PROTOCOL_HPFP_NAME;
|
||||
harleyAcr.setName(PROTOCOL_ACR_NAME);
|
||||
#endif // EFI_HD_ACR
|
||||
|
||||
static_assert(efi::size(sparkNames) >= MAX_CYLINDER_COUNT, "Too many ignition pins");
|
||||
|
@ -175,14 +175,14 @@ EnginePins::EnginePins() :
|
|||
static_assert(efi::size(injectorNames) >= MAX_CYLINDER_COUNT, "Too many injection pins");
|
||||
for (int i = 0; i < MAX_CYLINDER_COUNT;i++) {
|
||||
enginePins.coils[i].coilIndex = i;
|
||||
enginePins.coils[i].name = sparkNames[i];
|
||||
enginePins.coils[i].setName(sparkNames[i]);
|
||||
enginePins.coils[i].shortName = sparkShortNames[i];
|
||||
|
||||
enginePins.trailingCoils[i].name = trailNames[i];
|
||||
enginePins.trailingCoils[i].setName(trailNames[i]);
|
||||
enginePins.trailingCoils[i].shortName = trailShortNames[i];
|
||||
|
||||
enginePins.injectors[i].injectorIndex = i;
|
||||
enginePins.injectors[i].name = injectorNames[i];
|
||||
enginePins.injectors[i].setName(injectorNames[i]);
|
||||
enginePins.injectors[i].shortName = injectorShortNames[i];
|
||||
|
||||
enginePins.injectorsStage2[i].injectorIndex = i;
|
||||
|
@ -192,7 +192,7 @@ EnginePins::EnginePins() :
|
|||
|
||||
static_assert(efi::size(auxValveShortNames) >= AUX_DIGITAL_VALVE_COUNT, "Too many aux valve pins");
|
||||
for (int i = 0; i < AUX_DIGITAL_VALVE_COUNT;i++) {
|
||||
enginePins.auxValve[i].name = auxValveShortNames[i];
|
||||
enginePins.auxValve[i].setName(auxValveShortNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ void EnginePins::unregisterPins() {
|
|||
void EnginePins::debug() {
|
||||
RegisteredOutputPin * pin = registeredOutputHead;
|
||||
while (pin != nullptr) {
|
||||
efiPrintf("%s %d", pin->registrationName, pin->currentLogicValue);
|
||||
efiPrintf("%s %d", pin->getRegistrationName(), pin->currentLogicValue);
|
||||
pin = pin->next;
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ void EnginePins::startAuxValves() {
|
|||
NamedOutputPin *output = &enginePins.auxValve[i];
|
||||
// todo: do we need auxValveMode and reuse code?
|
||||
if (isConfigurationChanged(auxValves[i])) {
|
||||
output->initPin(output->name, engineConfiguration->auxValves[i]);
|
||||
output->initPin(output->getName(), engineConfiguration->auxValves[i]);
|
||||
}
|
||||
}
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
@ -317,12 +317,12 @@ void EnginePins::startIgnitionPins() {
|
|||
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
NamedOutputPin *trailingOutput = &enginePins.trailingCoils[i];
|
||||
if (isPinOrModeChanged(trailingCoilPins[i], ignitionPinMode)) {
|
||||
trailingOutput->initPin(trailingOutput->name, engineConfiguration->trailingCoilPins[i], engineConfiguration->ignitionPinMode);
|
||||
trailingOutput->initPin(trailingOutput->getName(), engineConfiguration->trailingCoilPins[i], engineConfiguration->ignitionPinMode);
|
||||
}
|
||||
|
||||
NamedOutputPin *output = &enginePins.coils[i];
|
||||
if (isPinOrModeChanged(ignitionPins[i], ignitionPinMode)) {
|
||||
output->initPin(output->name, engineConfiguration->ignitionPins[i], engineConfiguration->ignitionPinMode);
|
||||
output->initPin(output->getName(), engineConfiguration->ignitionPins[i], engineConfiguration->ignitionPinMode);
|
||||
}
|
||||
}
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
@ -334,7 +334,7 @@ void EnginePins::startInjectionPins() {
|
|||
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||
NamedOutputPin *output = &enginePins.injectors[i];
|
||||
if (isPinOrModeChanged(injectionPins[i], injectionPinMode)) {
|
||||
output->initPin(output->name, engineConfiguration->injectionPins[i],
|
||||
output->initPin(output->getName(), engineConfiguration->injectionPins[i],
|
||||
engineConfiguration->injectionPinMode);
|
||||
}
|
||||
|
||||
|
@ -400,6 +400,10 @@ const char *NamedOutputPin::getName() const {
|
|||
return name;
|
||||
}
|
||||
|
||||
void NamedOutputPin::setName(const char* p_name) {
|
||||
name = p_name;
|
||||
}
|
||||
|
||||
const char *NamedOutputPin::getShortName() const {
|
||||
return shortName == nullptr ? name : shortName;
|
||||
}
|
||||
|
@ -530,7 +534,7 @@ void IgnitionOutputPin::reset() {
|
|||
signalFallSparkId = 0;
|
||||
}
|
||||
|
||||
bool OutputPin::isInitialized() {
|
||||
bool OutputPin::isInitialized() const {
|
||||
#if EFI_GPIO_HARDWARE && EFI_PROD_CODE
|
||||
#if (BOARD_EXT_GPIOCHIPS > 0)
|
||||
if (ext)
|
||||
|
|
|
@ -44,8 +44,11 @@ public:
|
|||
void init();
|
||||
void unregister();
|
||||
RegisteredOutputPin* const next;
|
||||
const char *registrationName;
|
||||
const char* getRegistrationName() const {
|
||||
return registrationName;
|
||||
}
|
||||
private:
|
||||
const char* const registrationName;
|
||||
const uint16_t m_pinOffset;
|
||||
const bool m_hasPinMode;
|
||||
const uint16_t m_pinModeOffset;
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
// dissociates pin from this output and un-registers it in pin repository
|
||||
void deInit();
|
||||
|
||||
bool isInitialized();
|
||||
bool isInitialized() const;
|
||||
|
||||
bool getAndSet(int logicValue);
|
||||
void setValue(const char *msg, int logicValue, bool isForce = false);
|
||||
|
@ -117,15 +117,18 @@ public:
|
|||
virtual void setHigh();
|
||||
virtual void setLow();
|
||||
const char *getName() const;
|
||||
void setName(const char*);
|
||||
const char *getShortName() const;
|
||||
/**
|
||||
* @return true if pin was stopped
|
||||
*/
|
||||
bool stop();
|
||||
// todo: char pointer is a bit of a memory waste here, we can reduce RAM usage by software-based getName() method
|
||||
const char *name = nullptr;
|
||||
/**
|
||||
* rusEfi Engine Sniffer protocol uses these short names to reduce bytes usage
|
||||
*/
|
||||
const char *shortName = nullptr;
|
||||
|
||||
private:
|
||||
// todo: char pointer is a bit of a memory waste here, we can reduce RAM usage by software-based getName() method
|
||||
const char *name = nullptr;
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ void InjectorOutputPin::open(efitick_t nowNt) {
|
|||
|
||||
#if FUEL_MATH_EXTREME_LOGGING
|
||||
if (printFuelDebug) {
|
||||
printf("InjectorOutputPin::open %s %d now=%0.1fms\r\n", name, overlappingCounter, (int)getTimeNowUs() / 1000.0);
|
||||
printf("InjectorOutputPin::open %s %d now=%0.1fms\r\n", getName(), overlappingCounter, (int)getTimeNowUs() / 1000.0);
|
||||
}
|
||||
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
||||
|
||||
|
@ -45,7 +45,7 @@ void InjectorOutputPin::open(efitick_t nowNt) {
|
|||
// */
|
||||
#if FUEL_MATH_EXTREME_LOGGING
|
||||
if (printFuelDebug) {
|
||||
printf("overlapping, no need to touch pin %s %d\r\n", name, (int)getTimeNowUs());
|
||||
printf("overlapping, no need to touch pin %s %d\r\n", getName(), (int)getTimeNowUs());
|
||||
}
|
||||
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
||||
} else {
|
||||
|
@ -59,7 +59,7 @@ void InjectorOutputPin::open(efitick_t nowNt) {
|
|||
void InjectorOutputPin::close(efitick_t nowNt) {
|
||||
#if FUEL_MATH_EXTREME_LOGGING
|
||||
if (printFuelDebug) {
|
||||
printf("InjectorOutputPin::close %s %d %d\r\n", name, overlappingCounter, (int)getTimeNowUs());
|
||||
printf("InjectorOutputPin::close %s %d %d\r\n", getName(), overlappingCounter, (int)getTimeNowUs());
|
||||
}
|
||||
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
||||
|
||||
|
@ -67,7 +67,7 @@ void InjectorOutputPin::close(efitick_t nowNt) {
|
|||
if (overlappingCounter > 0) {
|
||||
#if FUEL_MATH_EXTREME_LOGGING
|
||||
if (printFuelDebug) {
|
||||
printf("was overlapping, no need to touch pin %s %d\r\n", name, (int)getTimeNowUs());
|
||||
printf("was overlapping, no need to touch pin %s %d\r\n", getName(), (int)getTimeNowUs());
|
||||
}
|
||||
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue