PetCare
Loading...
Searching...
No Matches
Public Member Functions | List of all members
MotorController Class Reference

Controller for a stepper motor that supports basic directional commands. More...

Collaboration diagram for MotorController:
Collaboration graph

Public Member Functions

 MotorController (int pin1, int pin2, int pin3, int pin4)
 Constructor for MotorController.
 
 ~MotorController ()
 Destructor for MotorController.
 
void rotateForward (int steps)
 Rotate the motor forward by a specific number of steps.
 
void rotateBackward (int steps)
 Rotate the motor backward by a specific number of steps.
 
void stop ()
 Stop the motor immediately.
 
void reset ()
 Reset the direction flags of the motor to false.
 
bool hasRotatedForward () const
 Check if the motor has rotated forward.
 
bool hasRotatedBackward () const
 Check if the motor has rotated backward.
 

Detailed Description

Controller for a stepper motor that supports basic directional commands.

This class provides functionality to control a stepper motor with forward, backward, and stop commands. It directly interacts with the hardware using GPIO operations.

Constructor & Destructor Documentation

◆ MotorController()

MotorController::MotorController ( int pin1,
int pin2,
int pin3,
int pin4 )

Constructor for MotorController.

Parameters
pin1GPIO pin number connected to the first motor pin.
pin2GPIO pin number connected to the second motor pin.
pin3GPIO pin number connected to the third motor pin.
pin4GPIO pin number connected to the fourth motor pin.

Member Function Documentation

◆ hasRotatedBackward()

bool MotorController::hasRotatedBackward ( ) const

Check if the motor has rotated backward.

Returns
True if the motor has rotated backward, otherwise false.

◆ hasRotatedForward()

bool MotorController::hasRotatedForward ( ) const

Check if the motor has rotated forward.

Returns
True if the motor has rotated forward, otherwise false.

◆ rotateBackward()

void MotorController::rotateBackward ( int steps)

Rotate the motor backward by a specific number of steps.

Parameters
stepsNumber of steps to rotate backward.

◆ rotateForward()

void MotorController::rotateForward ( int steps)

Rotate the motor forward by a specific number of steps.

Parameters
stepsNumber of steps to rotate forward.

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