![]() |
RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
|
A DC motor driven through an H-bridge, with an optional enable pin and a wheel alignment used when steering. More...
#include <Motor.h>
Public Member Functions | |
| Motor (const unsigned int driveOnePinNumber, const unsigned int driveTwoPinNumber, const MotorAlignment alignment=MotorAlignment::None) | |
| Builds a motor driven by two drive pins, assuming the enable pin is always powered. More... | |
| Motor (const unsigned int enablePinNumber, const unsigned int driveOnePinNumber, const unsigned int driveTwoPinNumber, const MotorAlignment alignment=MotorAlignment::None) | |
| Builds a motor driven by two drive pins and gated by an explicit enable pin. More... | |
| virtual | ~Motor () override |
| Destroys the motor, turning it off first. More... | |
| virtual void | TurnOn () override |
| Turns the motor on by enabling the H-bridge chip (no motion until a Move call). More... | |
| virtual void | TurnOff () override |
| Turns the motor off by disabling the enable pin and driving both drive pins low. More... | |
| virtual void | ProcessRawValues () override |
| No-op: a motor is an output device with no raw values to process. More... | |
| virtual std::string | ToString () const override |
| Serializes the motor's enable/drive pins and alignment to a string. More... | |
| virtual void | MoveForward () |
| Drives the motor forward, enabling the H-bridge first. More... | |
| virtual void | MoveBackward () |
| Drives the motor backward, enabling the H-bridge first. More... | |
| unsigned int | GetEnablePinNumber () const |
| Gets the H-bridge enable pin (UINT_MAX if the enable pin is always powered). More... | |
| unsigned int | GetDriveOnePinNumber () const |
| Gets the first H-bridge drive pin. More... | |
| unsigned int | GetDriveTwoPinNumber () const |
| Gets the second H-bridge drive pin. More... | |
| MotorAlignment | GetAlignment () const |
| Gets this motor's alignment on the vehicle. More... | |
Public Member Functions inherited from RumPi::BaseComponent | |
| BaseComponent () | |
| Builds a base component with an unknown type and an empty name. More... | |
| virtual | ~BaseComponent () |
| Virtual destructor so deleting a component through a BaseComponent* also cleans up the concrete subclass. More... | |
| virtual void | TurnOn ()=0 |
| Turns the component on (e.g. More... | |
| virtual void | TurnOff ()=0 |
| Turns the component off. More... | |
| virtual std::string | ToString () const =0 |
| Serializes the component's current readings to a string (usually JSON). More... | |
| virtual void | ProcessRawValues ()=0 |
| Reads and processes the component's latest raw values (called once per poll). More... | |
| virtual EComponentType | GetComponentType () const |
| Gets the component's type. More... | |
| const std::string & | GetName () const |
| Gets the component's unique per-instance name. More... | |
| void | SetName (const std::string &name) |
| Sets the component's unique per-instance name. More... | |
Private Attributes | |
| unsigned int | myEnablePinNumber |
| The H-bridge enable pin (UINT_MAX if the enable pin is always powered). More... | |
| unsigned int | myDriveOnePinNumber |
| The first H-bridge drive pin. More... | |
| unsigned int | myDriveTwoPinNumber |
| The second H-bridge drive pin. More... | |
| MotorAlignment | myAlignment |
| This motor's alignment on the vehicle (used when steering). More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from RumPi::BaseComponent | |
| static std::string | ComponentTypeToString (const EComponentType theComponentTypeToConvert) |
| Maps an EComponentType to its string name. More... | |
| static EComponentType | StringToComponentType (const std::string &theComponentTypeName) |
| Maps a type name back to its EComponentType (the inverse of ComponentTypeToString), so the client can turn the type carried on the wire back into a value it can look an icon up with. More... | |
Protected Attributes inherited from RumPi::BaseComponent | |
| EComponentType | myComponentType |
| The kind of component this is (set by each concrete subclass). More... | |
| std::string | myName |
| A unique per-instance name, assigned when the component is added to the manager. More... | |
A DC motor driven through an H-bridge, with an optional enable pin and a wheel alignment used when steering.
| RumPi::Motor::Motor | ( | const unsigned int | driveOnePinNumber, |
| const unsigned int | driveTwoPinNumber, | ||
| const MotorAlignment | alignment = MotorAlignment::None |
||
| ) |
Builds a motor driven by two drive pins, assuming the enable pin is always powered.
| [in] | driveOnePinNumber | The first H-bridge drive pin. |
| [in] | driveTwoPinNumber | The second H-bridge drive pin. |
| [in] | alignment | This motor's alignment on the vehicle. |
| RumPi::Motor::Motor | ( | const unsigned int | enablePinNumber, |
| const unsigned int | driveOnePinNumber, | ||
| const unsigned int | driveTwoPinNumber, | ||
| const MotorAlignment | alignment = MotorAlignment::None |
||
| ) |
Builds a motor driven by two drive pins and gated by an explicit enable pin.
| [in] | enablePinNumber | The H-bridge enable pin. |
| [in] | driveOnePinNumber | The first H-bridge drive pin. |
| [in] | driveTwoPinNumber | The second H-bridge drive pin. |
| [in] | alignment | This motor's alignment on the vehicle. |
|
overridevirtual |
Destroys the motor, turning it off first.
| MotorAlignment RumPi::Motor::GetAlignment | ( | ) | const |
Gets this motor's alignment on the vehicle.
| unsigned int RumPi::Motor::GetDriveOnePinNumber | ( | ) | const |
Gets the first H-bridge drive pin.
| unsigned int RumPi::Motor::GetDriveTwoPinNumber | ( | ) | const |
Gets the second H-bridge drive pin.
| unsigned int RumPi::Motor::GetEnablePinNumber | ( | ) | const |
Gets the H-bridge enable pin (UINT_MAX if the enable pin is always powered).
|
virtual |
Drives the motor backward, enabling the H-bridge first.
|
virtual |
Drives the motor forward, enabling the H-bridge first.
|
overridevirtual |
No-op: a motor is an output device with no raw values to process.
Implements RumPi::BaseComponent.
|
overridevirtual |
Serializes the motor's enable/drive pins and alignment to a string.
Implements RumPi::BaseComponent.
|
overridevirtual |
Turns the motor off by disabling the enable pin and driving both drive pins low.
Implements RumPi::BaseComponent.
|
overridevirtual |
Turns the motor on by enabling the H-bridge chip (no motion until a Move call).
Implements RumPi::BaseComponent.
|
private |
This motor's alignment on the vehicle (used when steering).
|
private |
The first H-bridge drive pin.
|
private |
The second H-bridge drive pin.
|
private |
The H-bridge enable pin (UINT_MAX if the enable pin is always powered).