Rename classes and constructors from EncoderMotor to DriveMotor.

This commit is contained in:
Matt McWilliams 2024-02-17 13:09:20 +00:00
parent 937cb85141
commit c036aad6cb
3 changed files with 15 additions and 14 deletions

View File

@ -8,7 +8,8 @@ class ContactPrinter {
private:
EncoderMotor drive_motor;
//use default drive motor pins
DriveMotor drive_motor;
const uint16_t serial_delay = 5;
const uint16_t baud = 115200;

View File

@ -1,10 +1,10 @@
#include "EncoderMotor.h"
#include "DriveMotor.h"
EncoderMotor::EncoderMotor () {
DriveMotor::DriveMotor () {
};
EncoderMotor::EncoderMotor (uint8_t e_pin, uint8_t f_pin, uint8_t b_pin, uint8_t ea_pin, uint8_t eb_pin) {
DriveMotor::DriveMotor (uint8_t e_pin, uint8_t f_pin, uint8_t b_pin, uint8_t ea_pin, uint8_t eb_pin) {
enable_pin = e_pin;
forward_pin = f_pin;
backward_pin = b_pin;
@ -12,7 +12,7 @@ EncoderMotor::EncoderMotor (uint8_t e_pin, uint8_t f_pin, uint8_t b_pin, uint8_t
encoder_b_pin = eb_pin;
};
void EncoderMotor::Setup () {
void DriveMotor::Setup () {
pinMode(enable_pin, OUTPUT);
pinMode(forward_pin, OUTPUT);
pinMode(backward_pin, OUTPUT);
@ -25,21 +25,21 @@ void EncoderMotor::Setup () {
digitalWrite(backward_pin, LOW);
}
void EncoderMotor::Start() {
void DriveMotor::Start() {
ledcWrite(pwm_channel, pwm_duty_cycle);
digitalWrite(forward_pin, HIGH);
digitalWrite(backward_pin, LOW);
}
void EncoderMotor::Stop() {
void DriveMotor::Stop() {
pwm_duty_cycle = 0;
digitalWrite(forward_pin, LOW);
digitalWrite(backward_pin, LOW);
ledcWrite(pwm_channel, pwm_duty_cycle);
}
void EncoderMotor::SetSpeed() {
void DriveMotor::SetSpeed() {
pwm_duty_cycle = 255;
}
void EncoderMotor::Loop () {
void DriveMotor::Loop () {
//monitor speed
}

View File

@ -1,9 +1,9 @@
#ifndef ENCODER_MOTOR
#define ENCODER_MOTOR
#ifndef DRIVE_MOTOR
#define DRIVE_MOTOR
#include <Arduino.h>
class EncoderMotor {
class DriveMotor {
private:
@ -28,8 +28,8 @@ class EncoderMotor {
public:
EncoderMotor();
EncoderMotor(uint8_t e_pin, uint8_t f_pin, uint8_t b_pin, uint8_t ea_pin, uint8_t eb_pin);
DriveMotor();
DriveMotor(uint8_t e_pin, uint8_t f_pin, uint8_t b_pin, uint8_t ea_pin, uint8_t eb_pin);
void Setup();
void Loop();
void Start();