Skip to content

Commit

Permalink
✨ Add analogWrite for ESP
Browse files Browse the repository at this point in the history
Signed-off-by: 0x6f736f646f <[email protected]>
  • Loading branch information
rodneyosodo committed Oct 23, 2022
1 parent 0ea8b65 commit dd4dc84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 1 addition & 2 deletions arduino/src/DRV8870.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "DRV8870.h"
#include "Arduino.h"

DRV8870::DRV8870(int motor_pin_1, int motor_pin_2)
{
Expand All @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions arduino/src/DRV8870.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,6 +20,14 @@
#define CLOCKWISE 1
#define COUNTERCLOCKWISE 0

#include "Arduino.h"
#if defined(ESP32)
#include <analogWrite.h>
#endif
#if defined(ESP8266)
#include <analogWrite.h>
#endif

class DRV8870
{
private:
Expand All @@ -34,7 +42,7 @@ class DRV8870
int _motor_pin_2;
int _motor_pin_3;
int _motor_pin_4;

// Motor count
int _motor_count;

Expand Down

0 comments on commit dd4dc84

Please sign in to comment.