DC not ETB refactoring
This commit is contained in:
parent
cd7cefb669
commit
014cae25db
|
@ -94,22 +94,9 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static DcHardware dcHardware[ETB_COUNT * 2];
|
static DcHardware dcHardware[ETB_COUNT + DC_PER_STEPPER];
|
||||||
|
|
||||||
// We needed more H-bridge configs - so the IO configs are split
|
DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
// across two arrays of settings to preserve config compatibility
|
|
||||||
const dc_io& getConfigForMotor(size_t index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|
||||||
size_t firstSize = efi::size(engineConfiguration->etbIo);
|
|
||||||
|
|
||||||
if (index < firstSize) {
|
|
||||||
return engineConfiguration->etbIo[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
return engineConfiguration->stepperDcIo[index - firstSize];
|
|
||||||
}
|
|
||||||
|
|
||||||
DcMotor* initDcMotor(size_t index, bool useTwoWires DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|
||||||
const auto& io = getConfigForMotor(index PASS_ENGINE_PARAMETER_SUFFIX);
|
|
||||||
auto& hw = dcHardware[index];
|
auto& hw = dcHardware[index];
|
||||||
|
|
||||||
hw.start(
|
hw.start(
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
class DcMotor;
|
class DcMotor;
|
||||||
class Logger;
|
class Logger;
|
||||||
|
|
||||||
DcMotor* initDcMotor(size_t index, bool useTwoWires DECLARE_ENGINE_PARAMETER_SUFFIX);
|
DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
// Manual control of motors for use by console commands
|
// Manual control of motors for use by console commands
|
||||||
void setDcMotorFrequency(size_t index, int hz);
|
void setDcMotorFrequency(size_t index, int hz);
|
||||||
|
|
|
@ -841,7 +841,7 @@ void doInitElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
bool anyEtbConfigured = false;
|
bool anyEtbConfigured = false;
|
||||||
|
|
||||||
for (int i = 0 ; i < ETB_COUNT; i++) {
|
for (int i = 0 ; i < ETB_COUNT; i++) {
|
||||||
auto motor = initDcMotor(i, CONFIG(etb_use_two_wires) PASS_ENGINE_PARAMETER_SUFFIX);
|
auto motor = initDcMotor(engineConfiguration->etbIo[i], i, CONFIG(etb_use_two_wires) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
// If this motor is actually set up, init the etb
|
// If this motor is actually set up, init the etb
|
||||||
if (motor)
|
if (motor)
|
||||||
|
|
|
@ -139,8 +139,8 @@ void initIdleHardware(Logging* sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
StepperHw* hw;
|
StepperHw* hw;
|
||||||
|
|
||||||
if (CONFIG(useHbridges)) {
|
if (CONFIG(useHbridges)) {
|
||||||
auto motorA = initDcMotor(2, /*useTwoWires*/ true PASS_ENGINE_PARAMETER_SUFFIX);
|
auto motorA = initDcMotor(engineConfiguration->stepperDcIo[0], 2, /*useTwoWires*/ true PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
auto motorB = initDcMotor(3, /*useTwoWires*/ true PASS_ENGINE_PARAMETER_SUFFIX);
|
auto motorB = initDcMotor(engineConfiguration->stepperDcIo[1], 3, /*useTwoWires*/ true PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
if (motorA && motorB) {
|
if (motorA && motorB) {
|
||||||
iacHbridgeHw.initialize(
|
iacHbridgeHw.initialize(
|
||||||
|
|
Loading…
Reference in New Issue