Public Member Functions | Private Attributes | List of all members
diffbot::AdafruitMotorController Class Reference

Implementation of the MotorControllerIntf for the Adafruit_MotorShield. More...

#include <adafruit_feather_wing.h>

Inheritance diagram for diffbot::AdafruitMotorController:
Inheritance graph
[legend]

Public Member Functions

 AdafruitMotorController (uint8_t motor_num, uint8_t addr=0x60)
 Construct an AdafruitMotorController for a single motor. More...
 
void begin (uint16_t freq=1600)
 Initializes the communication with the motor driver. More...
 
void setSpeed (int value) override
 Set the speed of the motor pMotor_. More...
 

Private Attributes

Adafruit_DCMotor * pMotor_
 

Additional Inherited Members

- Protected Attributes inherited from diffbot::MotorControllerIntf< Adafruit_MotorShield >
Adafruit_MotorShield motor_driver_
 

Detailed Description

Implementation of the MotorControllerIntf for the Adafruit_MotorShield.

Implements the abstract setSpeed method from the MotorControllerIntf

The class makes use of the adafruit-stepper-dc-motor-featherwing library.

Note
for more details see https://learn.adafruit.com/adafruit-stepper-dc-motor-featherwing/library-reference

Definition at line 28 of file adafruit_feather_wing.h.

Constructor & Destructor Documentation

◆ AdafruitMotorController()

diffbot::AdafruitMotorController::AdafruitMotorController ( uint8_t  motor_num,
uint8_t  addr = 0x60 
)

Construct an AdafruitMotorController for a single motor.

Specify the motor to control motor_num (use 3 or 4 for diffbot). Specify the i2c address to be used. The default address is 0x60 but it can be changed by soldering different address switches on the bottom of the PCB.

Parameters
motor_numNumber of the motor to control (one of 1, 2, 3, 4). Diffbot uses motors 3 and 4.
addri2c address used to communicate with the motor driver.

Definition at line 4 of file adafruit_feather_wing.cpp.

Member Function Documentation

◆ begin()

void diffbot::AdafruitMotorController::begin ( uint16_t  freq = 1600)

Initializes the communication with the motor driver.

must be called in setup() to initialize the shield. An optional frequency parameter can be used to specify something other than the default maximum: 1.6KHz PWM frequency.

Definition at line 11 of file adafruit_feather_wing.cpp.

◆ setSpeed()

void diffbot::AdafruitMotorController::setSpeed ( int  value)
overridevirtual

Set the speed of the motor pMotor_.

Concrete implementation of the setSpeed interface method to control a single motor connected to the Adafruit_MotorShield. The input parameter value ranges from -255 to 255. Inside this method the value is mapped between 0 to 255 and the sign is used to set the direction. A positive value results in the motor spinning forward. Negative value rotates the motor backward and a zero value stops the motor (releases the current).

Note
for more details see https://learn.adafruit.com/adafruit-stepper-dc-motor-featherwing/library-reference
Parameters
valuepositive or negative value to set the direction and speed of the motor.

Implements diffbot::MotorControllerIntf< Adafruit_MotorShield >.

Definition at line 16 of file adafruit_feather_wing.cpp.

Member Data Documentation

◆ pMotor_

Adafruit_DCMotor* diffbot::AdafruitMotorController::pMotor_
private

Definition at line 73 of file adafruit_feather_wing.h.


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


diffbot_base
Author(s):
autogenerated on Thu Sep 7 2023 02:35:23