![]() |
Smart Car Controller
1.0
Library to manage a two wheeled robotic vehicle (DC Motors)
|
#include <SC_DCMotor.h>
Public Types | |
Enumerated values and Typedefs. | |
enum | runCmd_t { DIR_FWD , DIR_REV } |
Public Member Functions | |
Methods for core object control. | |
virtual bool | begin (void)=0 |
virtual void | run (runCmd_t cmd, uint8_t speed)=0 |
virtual void | setSpeed (uint16_t s)=0 |
uint16_t | getSpeed () |
Protected Attributes | |
runCmd_t | _mode |
The current mode for the motor. | |
uint16_t | _speed |
The current speed setting for the motor. | |
Core object for the SC_DCMotor class
This class is a simple abstraction for PWM motor controllers that use 2 digital pins for direction control and PWM for speed control.
enum SC_DCMotor::runCmd_t |
|
pure virtual |
Initialize the object.
Initialize the object data. This needs to be called during setup() to reset new data for the class that cannot be done during the object creation.
Implemented in SC_DCMotor_MX1508, and SC_DCMotor_L29x.
uint16_t SC_DCMotor::getSpeed | ( | ) |
Get the currently set speed for the motor.
Returns the current speed setting
|
pure virtual |
Run/Stop the motor with speed.
This controls how the motor runs/stops. This is a convenience wrapper for the run() and setSpeed() methods. The command specified is one of the runCmd_t values and the speed must be suitable for the setSpeed() method.
cmd | the run/stop mode. |
speed | the speed to run at. |
Implemented in SC_DCMotor_MX1508, and SC_DCMotor_L29x.
|
pure virtual |
Set the speed for the motor.
This controls the speed setting for the motor. This is replaced with a method to implement the specifics for the derived class.
s | the speed setting appropriate for the controller type. |
Implemented in SC_DCMotor_MX1508, and SC_DCMotor_L29x.