adamlm / tb9051ftg-motor-carrier-arduino

This is an Arduino library for the Pololu TB9051FTG single brushed DC motor driver carrier.
MIT License
1 stars 1 forks source link

Error Compiling for ESP32 Dev module #6

Open ggarman opened 3 years ago

ggarman commented 3 years ago

Trying to compile simple_control using Arduino IDE 1.8.15 for ESP32 dev module, getting this error:

C:\Users\ggarm\Documents\Arduino\Robots\TankControl\simple_control\simple_control.ino: In function 'void setup()': simple_control:13:17: error: passing 'const TB9051FTGMotorCarrier' as 'this' argument discards qualifiers [-fpermissive] driver.enable(); ^ In file included from C:\Users\ggarm\Documents\Arduino\Robots\TankControl\simple_control\simple_control.ino:1: C:\Users\ggarm\Documents\Arduino\libraries\TB9051FTGMotorCarrier\src/TB9051FTGMotorCarrier.h:31:10: note: in call to 'void TB9051FTGMotorCarrier::enable()' void enable(void); ^~ exit status 1 passing 'const TB9051FTGMotorCarrier' as 'this' argument discards qualifiers [-fpermissive]

Thanks!

adamlm commented 3 years ago

Thanks for making an issue!

The problem is that the enable() function modifies the object's internal enabled variable, but the driver variable from the example sketch is declared as const. Removing the const keyword resolves that problem. I will update the example sketch a bit later this week.

Here's my testing setup:

Another more serious issue is that analogWrite() does not seem to be defined for ESP32 devices (see related issue). Until that function is implemented, I don't think this library in its current form will work with ESP32 devices.