wpi-32u4-library
Public Member Functions | Protected Member Functions
LeftMotor Class Reference

#include <Romi32U4Motors.h>

Inherits Romi32U4Motor.

Public Member Functions

void setMotorEffort (int16_t effort)
 
- Public Member Functions inherited from Romi32U4Motor
 Romi32U4Motor (void)
 
void setPIDCoeffients (float kp, float ki)
 
void allowTurbo (bool turbo)
 Turns turbo mode on or off. More...
 
void handleISR (bool newA, bool newB)
 

Protected Member Functions

void setEffort (int16_t effort)
 
- Protected Member Functions inherited from Romi32U4Motor
virtual void setEffort (int16_t effort)=0
 Sets the effort for the motor directly. Overloaded for the left and right motors. Use Chassis::setEfforts() from the user code to control motor efforts directly. More...
 
int16_t getCount (void)
 
int16_t getAndResetCount (void)
 
void setTargetSpeed (float targetSpeed)
 
void moveFor (int16_t amount)
 
bool checkComplete (void)
 
void update (void)
 
void calcEncoderDelta (void)
 

Additional Inherited Members

- Static Public Member Functions inherited from Romi32U4Motor
static void init ()
 
- Protected Types inherited from Romi32U4Motor
enum  CTRL_MODE : uint8_t { CTRL_DIRECT , CTRL_SPEED , CTRL_POS }
 
- Static Protected Member Functions inherited from Romi32U4Motor
static void initMotors ()
 
static void initEncoders ()
 
- Protected Attributes inherited from Romi32U4Motor
volatile CTRL_MODE ctrlMode = CTRL_DIRECT
 
volatile int16_t speed = 0
 
float targetSpeed = 0
 
int16_t targetPos = 0
 
int16_t maxEffort = 300
 
volatile int16_t prevCount = 0
 
volatile int16_t count = 0
 
volatile int16_t lastA = 0
 
volatile int16_t lastB = 0
 
PIDController pidCtrl
 

Detailed Description

A derived class for the left motor.

Definition at line 130 of file Romi32U4Motors.h.

Member Function Documentation

◆ setEffort()

void LeftMotor::setEffort ( int16_t  effort)
protectedvirtual

Because the Pololu library is based on the FastGPIO library, we don't/can't use analogWrite. Instead, we set the duty cycle directly at the register level.

We also have to have separate classes for the left and right motors to avoid the complex mapping of speeds to registers.

Implements Romi32U4Motor.

Definition at line 62 of file Romi32U4Motors.cpp.

References Romi32U4Motor::maxEffort, and FastGPIO::Pin< pin >::setOutput().

Referenced by setMotorEffort().

◆ setMotorEffort()

void LeftMotor::setMotorEffort ( int16_t  effort)
inline

Used to set the motor effort directly. It will properly control the mode.

Definition at line 137 of file Romi32U4Motors.h.

References Romi32U4Motor::CTRL_DIRECT, Romi32U4Motor::ctrlMode, and setEffort().

Referenced by Chassis::setMotorEfforts().


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