Nick wonders if DC wastegate is still FUBAR #5075
This commit is contained in:
parent
dabea9b4ad
commit
d31344a019
|
@ -55,6 +55,7 @@
|
||||||
#include "dynoview.h"
|
#include "dynoview.h"
|
||||||
#include "frequency_sensor.h"
|
#include "frequency_sensor.h"
|
||||||
#include "digital_input_exti.h"
|
#include "digital_input_exti.h"
|
||||||
|
#include "dc_motors.h"
|
||||||
|
|
||||||
extern bool main_loop_started;
|
extern bool main_loop_started;
|
||||||
|
|
||||||
|
@ -662,6 +663,11 @@ void updateTunerStudioState() {
|
||||||
tsOutputChannels->tsConfigVersion = TS_FILE_VERSION;
|
tsOutputChannels->tsConfigVersion = TS_FILE_VERSION;
|
||||||
static_assert(offsetof (TunerStudioOutputChannels, tsConfigVersion) == TS_FILE_VERSION_OFFSET);
|
static_assert(offsetof (TunerStudioOutputChannels, tsConfigVersion) == TS_FILE_VERSION_OFFSET);
|
||||||
|
|
||||||
|
DcHardware *getdcHardware();
|
||||||
|
|
||||||
|
DcHardware *dc = getdcHardware();
|
||||||
|
engine->dc_motors.dcOutput0 = dc->dcMotor.get();
|
||||||
|
|
||||||
#if EFI_SHAFT_POSITION_INPUT
|
#if EFI_SHAFT_POSITION_INPUT
|
||||||
|
|
||||||
// offset 0
|
// offset 0
|
||||||
|
|
|
@ -10,54 +10,8 @@
|
||||||
#include "periodic_task.h"
|
#include "periodic_task.h"
|
||||||
|
|
||||||
#include "dc_motors.h"
|
#include "dc_motors.h"
|
||||||
#include "dc_motor.h"
|
|
||||||
|
|
||||||
// Simple wrapper to use an OutputPin as "PWM" that can only do 0 or 1
|
void DcHardware::start(bool useTwoWires,
|
||||||
struct PwmWrapper : public IPwm {
|
|
||||||
OutputPin& m_pin;
|
|
||||||
|
|
||||||
PwmWrapper(OutputPin& pin) : m_pin(pin) { }
|
|
||||||
|
|
||||||
void setSimplePwmDutyCycle(float dutyCycle) override {
|
|
||||||
m_pin.setValue(dutyCycle > 0.5f);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class DcHardware {
|
|
||||||
private:
|
|
||||||
OutputPin m_pinEnable;
|
|
||||||
OutputPin m_pinDir1;
|
|
||||||
OutputPin m_pinDir2;
|
|
||||||
OutputPin m_disablePin;
|
|
||||||
|
|
||||||
PwmWrapper wrappedEnable{m_pinEnable};
|
|
||||||
PwmWrapper wrappedDir1{m_pinDir1};
|
|
||||||
PwmWrapper wrappedDir2{m_pinDir2};
|
|
||||||
|
|
||||||
SimplePwm m_pwm1;
|
|
||||||
SimplePwm m_pwm2;
|
|
||||||
|
|
||||||
bool isStarted = false;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DcHardware() : dcMotor(m_disablePin) {}
|
|
||||||
|
|
||||||
TwoPinDcMotor dcMotor;
|
|
||||||
|
|
||||||
void setFrequency(int frequency) {
|
|
||||||
m_pwm1.setFrequency(frequency);
|
|
||||||
m_pwm2.setFrequency(frequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *msg() {
|
|
||||||
return dcMotor.msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void stop() {
|
|
||||||
// todo: replace 'isStarted' with 'stop'
|
|
||||||
}
|
|
||||||
|
|
||||||
void start(bool useTwoWires,
|
|
||||||
brain_pin_e pinEnable,
|
brain_pin_e pinEnable,
|
||||||
brain_pin_e pinDir1,
|
brain_pin_e pinDir1,
|
||||||
brain_pin_e pinDir2,
|
brain_pin_e pinDir2,
|
||||||
|
@ -127,10 +81,13 @@ public:
|
||||||
dcMotor.configure(m_pwm1, wrappedDir1, wrappedDir2, isInverted);
|
dcMotor.configure(m_pwm1, wrappedDir1, wrappedDir2, isInverted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
static DcHardware dcHardware[ETB_COUNT + DC_PER_STEPPER];
|
static DcHardware dcHardware[ETB_COUNT + DC_PER_STEPPER];
|
||||||
|
|
||||||
|
DcHardware *getdcHardware() {
|
||||||
|
return &dcHardware[0];
|
||||||
|
}
|
||||||
|
|
||||||
DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires) {
|
DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires) {
|
||||||
auto& hw = dcHardware[index];
|
auto& hw = dcHardware[index];
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef>
|
#include "dc_motor.h"
|
||||||
|
|
||||||
class DcMotor;
|
#include <cstddef>
|
||||||
|
|
||||||
DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires);
|
DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires);
|
||||||
DcMotor* initDcMotor(brain_pin_e coil_p, brain_pin_e coil_m, size_t index);
|
DcMotor* initDcMotor(brain_pin_e coil_p, brain_pin_e coil_m, size_t index);
|
||||||
|
@ -20,3 +20,58 @@ void setDcMotorDuty(size_t index, float duty);
|
||||||
|
|
||||||
void showDcMotorInfo(int i);
|
void showDcMotorInfo(int i);
|
||||||
|
|
||||||
|
// Simple wrapper to use an OutputPin as "PWM" that can only do 0 or 1
|
||||||
|
struct PwmWrapper : public IPwm {
|
||||||
|
OutputPin& m_pin;
|
||||||
|
|
||||||
|
PwmWrapper(OutputPin& pin) : m_pin(pin) { }
|
||||||
|
|
||||||
|
void setSimplePwmDutyCycle(float dutyCycle) override {
|
||||||
|
m_pin.setValue(dutyCycle > 0.5f);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class DcHardware {
|
||||||
|
private:
|
||||||
|
OutputPin m_pinEnable;
|
||||||
|
OutputPin m_pinDir1;
|
||||||
|
OutputPin m_pinDir2;
|
||||||
|
OutputPin m_disablePin;
|
||||||
|
|
||||||
|
PwmWrapper wrappedEnable{m_pinEnable};
|
||||||
|
PwmWrapper wrappedDir1{m_pinDir1};
|
||||||
|
PwmWrapper wrappedDir2{m_pinDir2};
|
||||||
|
|
||||||
|
SimplePwm m_pwm1;
|
||||||
|
SimplePwm m_pwm2;
|
||||||
|
|
||||||
|
bool isStarted = false;
|
||||||
|
public:
|
||||||
|
|
||||||
|
DcHardware() : dcMotor(m_disablePin) {}
|
||||||
|
|
||||||
|
void start(bool useTwoWires,
|
||||||
|
brain_pin_e pinEnable,
|
||||||
|
brain_pin_e pinDir1,
|
||||||
|
brain_pin_e pinDir2,
|
||||||
|
brain_pin_e pinDisable,
|
||||||
|
bool isInverted,
|
||||||
|
ExecutorInterface* executor,
|
||||||
|
int frequency);
|
||||||
|
|
||||||
|
TwoPinDcMotor dcMotor;
|
||||||
|
|
||||||
|
void setFrequency(int frequency) {
|
||||||
|
m_pwm1.setFrequency(frequency);
|
||||||
|
m_pwm2.setFrequency(frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *msg() {
|
||||||
|
return dcMotor.msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop() {
|
||||||
|
// todo: replace 'isStarted' with 'stop'
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue