gppwm load axis can be another GPPWM channel (!!!!!) (#4587)
* gppwm load axis can be another GPPWM channel (!!!!!) * explicit cast * efiAssert not void * kick
This commit is contained in:
parent
3418bd1217
commit
d84a290eca
|
@ -44,22 +44,32 @@ expected<float> readGppwmChannel(gppwm_channel_e channel) {
|
||||||
return Sensor::get(SensorType::AuxLinear1);
|
return Sensor::get(SensorType::AuxLinear1);
|
||||||
case GPPWM_AuxLinear2:
|
case GPPWM_AuxLinear2:
|
||||||
return Sensor::get(SensorType::AuxLinear2);
|
return Sensor::get(SensorType::AuxLinear2);
|
||||||
|
case GPPWM_GppwmOutput1:
|
||||||
|
return (float)engine->outputChannels.gppwmOutput[0];
|
||||||
|
case GPPWM_GppwmOutput2:
|
||||||
|
return (float)engine->outputChannels.gppwmOutput[1];
|
||||||
|
case GPPWM_GppwmOutput3:
|
||||||
|
return (float)engine->outputChannels.gppwmOutput[2];
|
||||||
|
case GPPWM_GppwmOutput4:
|
||||||
|
return (float)engine->outputChannels.gppwmOutput[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
return unexpected;
|
return unexpected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GppwmChannel::setOutput(float result) {
|
float GppwmChannel::setOutput(float result) {
|
||||||
// Not init yet, nothing to do.
|
// Not init yet, nothing to do.
|
||||||
if (!m_config) {
|
if (!m_config) {
|
||||||
return;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_usePwm) {
|
if (m_usePwm) {
|
||||||
efiAssertVoid(OBD_PCM_Processor_Fault, m_usePwm, "m_usePwm null");
|
efiAssert(OBD_PCM_Processor_Fault, m_usePwm, "m_usePwm null", 0);
|
||||||
m_pwm->setSimplePwmDutyCycle(clampF(0, result / 100.0f, 1));
|
m_pwm->setSimplePwmDutyCycle(clampF(0, result / 100.0f, 1));
|
||||||
|
|
||||||
|
return result;
|
||||||
} else {
|
} else {
|
||||||
efiAssertVoid(OBD_PCM_Processor_Fault, m_output, "m_output null");
|
efiAssert(OBD_PCM_Processor_Fault, m_output, "m_output null", 0);
|
||||||
if (m_config->offBelowDuty > m_config->onAboveDuty) {
|
if (m_config->offBelowDuty > m_config->onAboveDuty) {
|
||||||
firmwareError(CUSTOM_ERR_6122, "You can't have off below %d greater than on above %d",
|
firmwareError(CUSTOM_ERR_6122, "You can't have off below %d greater than on above %d",
|
||||||
m_config->offBelowDuty,
|
m_config->offBelowDuty,
|
||||||
|
@ -73,6 +83,9 @@ void GppwmChannel::setOutput(float result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_output->setValue(m_state);
|
m_output->setValue(m_state);
|
||||||
|
|
||||||
|
// Return the actual output value with hysteresis
|
||||||
|
return m_state ? 100 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +123,5 @@ float GppwmChannel::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
float output = getOutput();
|
float output = getOutput();
|
||||||
setOutput(output);
|
return setOutput(output);
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,9 @@ public:
|
||||||
void init(bool usePwm, IPwm* pwm, OutputPin* outputPin, const ValueProvider3D* table, const gppwm_channel* config);
|
void init(bool usePwm, IPwm* pwm, OutputPin* outputPin, const ValueProvider3D* table, const gppwm_channel* config);
|
||||||
float update();
|
float update();
|
||||||
percent_t getOutput() const;
|
percent_t getOutput() const;
|
||||||
void setOutput(float result);
|
|
||||||
|
// Returns actual output duty, with hysteresis applied
|
||||||
|
float setOutput(float result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Store the current state so we can apply hysteresis
|
// Store the current state so we can apply hysteresis
|
||||||
|
|
|
@ -547,6 +547,10 @@ typedef enum __attribute__ ((__packed__)) {
|
||||||
GPPWM_EthanolPercent = 15,
|
GPPWM_EthanolPercent = 15,
|
||||||
GPPWM_AuxLinear1 = 16,
|
GPPWM_AuxLinear1 = 16,
|
||||||
GPPWM_AuxLinear2 = 17,
|
GPPWM_AuxLinear2 = 17,
|
||||||
|
GPPWM_GppwmOutput1 = 18,
|
||||||
|
GPPWM_GppwmOutput2 = 19,
|
||||||
|
GPPWM_GppwmOutput3 = 20,
|
||||||
|
GPPWM_GppwmOutput4 = 21,
|
||||||
} gppwm_channel_e;
|
} gppwm_channel_e;
|
||||||
|
|
||||||
typedef enum __attribute__ ((__packed__)) {
|
typedef enum __attribute__ ((__packed__)) {
|
||||||
|
|
|
@ -347,7 +347,7 @@ struct spi_pins
|
||||||
end_struct
|
end_struct
|
||||||
|
|
||||||
|
|
||||||
#define gppwm_channel_e_enum "Zero", "TPS", "MAP", "CLT", "IAT", "Fuel Load", "Ignition Load", "Aux Temp 1", "Aux Temp 2", "Accel Pedal", "Battery Voltage", "VVT 1 I", "VVT 1 E", "VVT 2 I", "VVT 2 E", "Ethanol (Flex) %", "Aux Linear 1", "Aux Linear 2"
|
#define gppwm_channel_e_enum "Zero", "TPS", "MAP", "CLT", "IAT", "Fuel Load", "Ignition Load", "Aux Temp 1", "Aux Temp 2", "Accel Pedal", "Battery Voltage", "VVT 1 I", "VVT 1 E", "VVT 2 I", "VVT 2 E", "Ethanol (Flex) %", "Aux Linear 1", "Aux Linear 2", "GPPWM Output 1", "GPPWM Output 2", "GPPWM Output 3", "GPPWM Output 4"
|
||||||
custom gppwm_channel_e 1 bits, U08, @OFFSET@, [0:4], @@gppwm_channel_e_enum@@
|
custom gppwm_channel_e 1 bits, U08, @OFFSET@, [0:4], @@gppwm_channel_e_enum@@
|
||||||
|
|
||||||
struct gppwm_channel
|
struct gppwm_channel
|
||||||
|
|
Loading…
Reference in New Issue