Main Page
Namespaces
Namespace List
Namespace Members
All
Variables
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
~
Functions
a
b
c
d
e
g
i
j
l
m
n
o
p
r
s
t
u
w
~
Variables
a
c
d
e
f
g
h
i
j
k
l
m
n
o
p
s
t
u
v
w
Typedefs
Files
File List
File Members
All
a
b
c
e
k
l
m
n
p
r
s
t
u
Functions
Variables
Typedefs
Macros
scripts
base_controller
lib
motor_controllers
adafruit_feather_wing
adafruit_feather_wing.cpp
Go to the documentation of this file.
1
#include "
adafruit_feather_wing/adafruit_feather_wing.h
"
2
3
4
diffbot::AdafruitMotorController::AdafruitMotorController
(uint8_t motor_num, uint8_t addr)
5
{
6
motor_driver_
= Adafruit_MotorShield(addr);
7
// Select which 'port' (motor pin) M1, M2, M3 or M4.
8
pMotor_
=
motor_driver_
.getMotor(motor_num);
9
}
10
11
void
diffbot::AdafruitMotorController::begin
(uint16_t freq)
12
{
13
motor_driver_.begin(freq);
14
}
15
16
void
diffbot::AdafruitMotorController::setSpeed
(
int
value)
17
{
18
if
(value > 0)
19
{
20
pMotor_->run(FORWARD);
21
}
22
else
if
(value < 0)
23
{
24
pMotor_->run(BACKWARD);
25
// AdafruAdafruit_MotorShield requires uint8 values from 0 to 255
26
// Make sure to convert the negative value to a positive one
27
value = value * -1;
28
}
29
else
// zero speed
30
{
31
// Cut power to the motor
32
pMotor_->run(RELEASE);
33
}
34
35
pMotor_->setSpeed(value);
36
}
diffbot::AdafruitMotorController::pMotor_
Adafruit_DCMotor * pMotor_
Definition:
adafruit_feather_wing.h:73
diffbot::AdafruitMotorController::setSpeed
void setSpeed(int value) override
Set the speed of the motor pMotor_.
Definition:
adafruit_feather_wing.cpp:16
adafruit_feather_wing.h
diffbot::AdafruitMotorController::AdafruitMotorController
AdafruitMotorController(uint8_t motor_num, uint8_t addr=0x60)
Construct an AdafruitMotorController for a single motor.
Definition:
adafruit_feather_wing.cpp:4
diffbot::MotorControllerIntf< Adafruit_MotorShield >::motor_driver_
Adafruit_MotorShield motor_driver_
Definition:
motor_controller_interface.h:35
diffbot::AdafruitMotorController::begin
void begin(uint16_t freq=1600)
Initializes the communication with the motor driver.
Definition:
adafruit_feather_wing.cpp:11
diffbot_base
Author(s):
autogenerated on Thu Sep 7 2023 02:35:23