From dd4dc841dc078500564d4d0e2e529de2a7ff6fc4 Mon Sep 17 00:00:00 2001 From: 0x6f736f646f Date: Sun, 23 Oct 2022 20:54:02 +0300 Subject: [PATCH] :sparkles: Add analogWrite for ESP Signed-off-by: 0x6f736f646f --- arduino/src/DRV8870.cpp | 3 +-- arduino/src/DRV8870.h | 12 ++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arduino/src/DRV8870.cpp b/arduino/src/DRV8870.cpp index 14b7f09..565ee45 100644 --- a/arduino/src/DRV8870.cpp +++ b/arduino/src/DRV8870.cpp @@ -1,5 +1,4 @@ #include "DRV8870.h" -#include "Arduino.h" DRV8870::DRV8870(int motor_pin_1, int motor_pin_2) { @@ -15,7 +14,7 @@ DRV8870::DRV8870(int motor_pin_1, int motor_pin_2, int motor_pin_3, int motor_pi this->_motor_pin_1 = motor_pin_1; this->_motor_pin_2 = motor_pin_2; this->_motor_pin_3 = motor_pin_3; - this->_motor_pin_4 = motor_pin_4; + this->_motor_pin_4 = motor_pin_4; pinMode(this->_motor_pin_1, OUTPUT); pinMode(this->_motor_pin_2, OUTPUT); pinMode(this->_motor_pin_3, OUTPUT); diff --git a/arduino/src/DRV8870.h b/arduino/src/DRV8870.h index 8d63c4b..3b4d462 100644 --- a/arduino/src/DRV8870.h +++ b/arduino/src/DRV8870.h @@ -4,7 +4,7 @@ * Original library (1.0.0) by Rodney Osodo. * * The moded the DRV8870 motor driver can run are listed below: - * + * * x_PWM1 x_PWM2 Mode * 0 0 Coast/Fast decay * 0 1 Reverse @@ -20,6 +20,14 @@ #define CLOCKWISE 1 #define COUNTERCLOCKWISE 0 +#include "Arduino.h" +#if defined(ESP32) +#include +#endif +#if defined(ESP8266) +#include +#endif + class DRV8870 { private: @@ -34,7 +42,7 @@ class DRV8870 int _motor_pin_2; int _motor_pin_3; int _motor_pin_4; - + // Motor count int _motor_count;