Smart Car Controller  1.0
Library to manage a two wheeled robotic vehicle (DC Motors)
SC_DCMotor Class Referenceabstract

#include <SC_DCMotor.h>

Inheritance diagram for SC_DCMotor:

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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ runCmd_t

Define the different motor commands/states

These commands are used to direct the different modes of running the DC motors allowed by the controller.

Enumerator
DIR_FWD 

Rotate in forward direction.

DIR_REV 

Rotate in reverse direction (opposite of DIR_FWD).

Member Function Documentation

◆ begin()

virtual bool SC_DCMotor::begin ( void  )
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.

Returns
true if initialization succeeded

Implemented in SC_DCMotor_MX1508, and SC_DCMotor_L29x.

◆ getSpeed()

uint16_t SC_DCMotor::getSpeed ( )

Get the currently set speed for the motor.

Returns the current speed setting

Returns
the speed setting.

◆ run()

virtual void SC_DCMotor::run ( runCmd_t  cmd,
uint8_t  speed 
)
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.

See also
setSpeed(), run()
Parameters
cmdthe run/stop mode.
speedthe speed to run at.

Implemented in SC_DCMotor_MX1508, and SC_DCMotor_L29x.

◆ setSpeed()

virtual void SC_DCMotor::setSpeed ( uint16_t  s)
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.

Parameters
sthe speed setting appropriate for the controller type.

Implemented in SC_DCMotor_MX1508, and SC_DCMotor_L29x.


The documentation for this class was generated from the following file: