AStar32U4 library
Static Public Member Functions | List of all members
AStar32U4Motors Class Reference

Controls motor speed and direction on the A-Star 32U4 Robot Controller. More...

#include <AStar32U4Motors.h>

Static Public Member Functions

static void flipM1 (bool flip)
 Flips the direction of motor 1. More...
 
static void flipM2 (bool flip)
 Flips the direction of motor 2. More...
 
static void setM1Speed (int16_t speed)
 Sets the speed for motor 1. More...
 
static void setM2Speed (int16_t speed)
 Sets the speed for motor 2. More...
 
static void setSpeeds (int16_t m2Speed, int16_t m1Speed)
 Sets the speed for both motors. More...
 

Detailed Description

Controls motor speed and direction on the A-Star 32U4 Robot Controller.

By default, positive speed arguments ("forward") correspond to current flowing from motor driver output A to B, while negative speed arguments ("reverse") correspond to current flowing from B to A. Calling flipM1() or flipM2() with an argument of true flips the correspondence for that motor (that is, it flips the meaning of "forward" and "reverse").

This library uses Timer 1, so it will conflict with any other libraries using that timer.

Definition at line 20 of file AStar32U4Motors.h.

Member Function Documentation

◆ flipM1()

void AStar32U4Motors::flipM1 ( bool  flip)
static

Flips the direction of motor 1.

You can call this function with an argument of true if you want to flip the effect that positive and negative speeds have on the direction of motor 1.

Parameters
flipIf true, then positive motor speeds will correspond to current flowing from B to A. If false, then positive motor speeds will correspond to current flowing from A to B.

Definition at line 39 of file AStar32U4Motors.cpp.

◆ flipM2()

void AStar32U4Motors::flipM2 ( bool  flip)
static

Flips the direction of motor 2.

You can call this function with an argument of true if you want to flip the effect that positive and negative speeds have on the direction of motor 2.

Parameters
flipIf true, then positive motor speeds will correspond to current flowing from B to A. If false, then positive motor speeds will correspond to current flowing from A to B.

Definition at line 45 of file AStar32U4Motors.cpp.

◆ setM1Speed()

void AStar32U4Motors::setM1Speed ( int16_t  speed)
static

Sets the speed for motor 1.

Parameters
speedA number from -400 to 400 representing the speed and direction of motor 1. Values of -400 or less result in full speed reverse, and values of 400 or more result in full speed forward.

Definition at line 51 of file AStar32U4Motors.cpp.

◆ setM2Speed()

void AStar32U4Motors::setM2Speed ( int16_t  speed)
static

Sets the speed for motor 2.

Parameters
speedA number from -400 to 400 representing the speed and direction of motor 2. Values of -400 or less result in full speed reverse, and values of 400 or more result in full speed forward.

Definition at line 73 of file AStar32U4Motors.cpp.

◆ setSpeeds()

void AStar32U4Motors::setSpeeds ( int16_t  m2Speed,
int16_t  m1Speed 
)
static

Sets the speed for both motors.

Parameters
m1SpeedA number from -400 to 400 representing the speed and direction of motor 1. Values of -400 or less result in full speed reverse, and values of 400 or more result in full speed forward.
m2SpeedA number from -400 to 400 representing the speed and direction of motor 2. Values of -400 or less result in full speed reverse, and values of 400 or more result in full speed forward.

Definition at line 95 of file AStar32U4Motors.cpp.


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