Rename classes and constructors from EncoderMotor to DriveMotor.
This commit is contained in:
parent
937cb85141
commit
c036aad6cb
|
@ -8,7 +8,8 @@ class ContactPrinter {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
EncoderMotor drive_motor;
|
//use default drive motor pins
|
||||||
|
DriveMotor drive_motor;
|
||||||
|
|
||||||
const uint16_t serial_delay = 5;
|
const uint16_t serial_delay = 5;
|
||||||
const uint16_t baud = 115200;
|
const uint16_t baud = 115200;
|
||||||
|
|
|
@ -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;
|
enable_pin = e_pin;
|
||||||
forward_pin = f_pin;
|
forward_pin = f_pin;
|
||||||
backward_pin = b_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;
|
encoder_b_pin = eb_pin;
|
||||||
};
|
};
|
||||||
|
|
||||||
void EncoderMotor::Setup () {
|
void DriveMotor::Setup () {
|
||||||
pinMode(enable_pin, OUTPUT);
|
pinMode(enable_pin, OUTPUT);
|
||||||
pinMode(forward_pin, OUTPUT);
|
pinMode(forward_pin, OUTPUT);
|
||||||
pinMode(backward_pin, OUTPUT);
|
pinMode(backward_pin, OUTPUT);
|
||||||
|
@ -25,21 +25,21 @@ void EncoderMotor::Setup () {
|
||||||
digitalWrite(backward_pin, LOW);
|
digitalWrite(backward_pin, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncoderMotor::Start() {
|
void DriveMotor::Start() {
|
||||||
ledcWrite(pwm_channel, pwm_duty_cycle);
|
ledcWrite(pwm_channel, pwm_duty_cycle);
|
||||||
digitalWrite(forward_pin, HIGH);
|
digitalWrite(forward_pin, HIGH);
|
||||||
digitalWrite(backward_pin, LOW);
|
digitalWrite(backward_pin, LOW);
|
||||||
}
|
}
|
||||||
void EncoderMotor::Stop() {
|
void DriveMotor::Stop() {
|
||||||
pwm_duty_cycle = 0;
|
pwm_duty_cycle = 0;
|
||||||
digitalWrite(forward_pin, LOW);
|
digitalWrite(forward_pin, LOW);
|
||||||
digitalWrite(backward_pin, LOW);
|
digitalWrite(backward_pin, LOW);
|
||||||
ledcWrite(pwm_channel, pwm_duty_cycle);
|
ledcWrite(pwm_channel, pwm_duty_cycle);
|
||||||
}
|
}
|
||||||
void EncoderMotor::SetSpeed() {
|
void DriveMotor::SetSpeed() {
|
||||||
pwm_duty_cycle = 255;
|
pwm_duty_cycle = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncoderMotor::Loop () {
|
void DriveMotor::Loop () {
|
||||||
//monitor speed
|
//monitor speed
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef ENCODER_MOTOR
|
#ifndef DRIVE_MOTOR
|
||||||
#define ENCODER_MOTOR
|
#define DRIVE_MOTOR
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
class EncoderMotor {
|
class DriveMotor {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ class EncoderMotor {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EncoderMotor();
|
DriveMotor();
|
||||||
EncoderMotor(uint8_t e_pin, uint8_t f_pin, uint8_t b_pin, uint8_t ea_pin, uint8_t eb_pin);
|
DriveMotor(uint8_t e_pin, uint8_t f_pin, uint8_t b_pin, uint8_t ea_pin, uint8_t eb_pin);
|
||||||
void Setup();
|
void Setup();
|
||||||
void Loop();
|
void Loop();
|
||||||
void Start();
|
void Start();
|
||||||
|
|
Loading…
Reference in New Issue