diff --git a/ino/contact_printer/ContactPrinter.h b/ino/contact_printer/ContactPrinter.h index 5322fb7..31e2660 100644 --- a/ino/contact_printer/ContactPrinter.h +++ b/ino/contact_printer/ContactPrinter.h @@ -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; diff --git a/ino/contact_printer/DriveMotor.cpp b/ino/contact_printer/DriveMotor.cpp index b3b73a2..249dde9 100644 --- a/ino/contact_printer/DriveMotor.cpp +++ b/ino/contact_printer/DriveMotor.cpp @@ -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 } diff --git a/ino/contact_printer/DriveMotor.h b/ino/contact_printer/DriveMotor.h index 65d5157..55dfe1b 100644 --- a/ino/contact_printer/DriveMotor.h +++ b/ino/contact_printer/DriveMotor.h @@ -1,9 +1,9 @@ -#ifndef ENCODER_MOTOR -#define ENCODER_MOTOR +#ifndef DRIVE_MOTOR +#define DRIVE_MOTOR #include -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();