Simple motor controller library, using DIR, PWM, nSLP pin like pololu.
Diff: MotorControler.cpp
- Revision:
- 4:a60052db674c
- Parent:
- 3:7acc824ca344
- Child:
- 5:b46d1e179eb7
diff -r 7acc824ca344 -r a60052db674c MotorControler.cpp --- a/MotorControler.cpp Tue Feb 02 13:51:29 2021 +0000 +++ b/MotorControler.cpp Tue Feb 02 14:05:05 2021 +0000 @@ -1,19 +1,30 @@ #include "MotorControler.h" -MotorControler::MotorControler(PinName DIR, PinName PWM, PinName SLP, DriverType) : DIR_(DIR), PWM_(PWM), nSLP_(SLP) +MotorControler::MotorControler(PinName DIR, PinName PWM, PinName nSLP, DriverType md_type) : DIR_(DIR), PWM_(PWM), nSLP_(nSLP) { - nSLP_ = 0; + disableDriver(); reverse_direction_ = 0; + md_type_ = md_type; } void MotorControler::enableDriver() { - nSLP_ = 1; + if(md_type_ == POLOLU) + { + nSLP_ = 1; + } + else if(md_type_ == TEXNITIS) + { + // do nothing; + } } void MotorControler::disableDriver() { - nSLP_ = 0; + if(md_type_ == POLOLU) + nSLP_ = 0; + else if(md_type_ == TEXNITIS) + PWM_ = 0; } void MotorControler::setSpeed(float speed)