This commit is contained in:
parent
7e95c2c672
commit
d6f8590cbf
|
@ -37,6 +37,8 @@ private:
|
||||||
SimplePwm m_pwm1;
|
SimplePwm m_pwm1;
|
||||||
SimplePwm m_pwm2;
|
SimplePwm m_pwm2;
|
||||||
|
|
||||||
|
bool isStarted = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DcHardware() : dcMotor(m_disablePin) {}
|
DcHardware() : dcMotor(m_disablePin) {}
|
||||||
|
|
||||||
|
@ -47,6 +49,10 @@ public:
|
||||||
m_pwm2.setFrequency(frequency);
|
m_pwm2.setFrequency(frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stop() {
|
||||||
|
// todo: replace 'isStarted' with 'stop'
|
||||||
|
}
|
||||||
|
|
||||||
void start(bool useTwoWires,
|
void start(bool useTwoWires,
|
||||||
brain_pin_e pinEnable,
|
brain_pin_e pinEnable,
|
||||||
brain_pin_e pinDir1,
|
brain_pin_e pinDir1,
|
||||||
|
@ -55,6 +61,13 @@ public:
|
||||||
bool isInverted,
|
bool isInverted,
|
||||||
ExecutorInterface* executor,
|
ExecutorInterface* executor,
|
||||||
int frequency) {
|
int frequency) {
|
||||||
|
|
||||||
|
if (isStarted) {
|
||||||
|
// actually implement stop()
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isStarted = true;
|
||||||
|
|
||||||
dcMotor.setType(useTwoWires ? TwoPinDcMotor::ControlType::PwmDirectionPins : TwoPinDcMotor::ControlType::PwmEnablePin);
|
dcMotor.setType(useTwoWires ? TwoPinDcMotor::ControlType::PwmDirectionPins : TwoPinDcMotor::ControlType::PwmEnablePin);
|
||||||
|
|
||||||
// Configure the disable pin first - ensure things are in a safe state
|
// Configure the disable pin first - ensure things are in a safe state
|
||||||
|
|
Loading…
Reference in New Issue