Open kostyay opened 2 years ago
Fixed ur comments
First of all, thanks for working on this.
SO if you look at both the L293x and the BTS7960, it can be noted that they are both H-bridges and as a result have essentially the same sort of way that you connect to them and use them.
As the Wikipedia page says:
These circuits are often used in robotics and other applications to allow DC motors to run forwards or backwards.
The only difference is that the BTS7960 has a connection to enable separately the forward direction from the reverse direction.
I would suggest basically copy the structure/format of the L293x driver. Of course rename the pins, and then implement the same API in the manner that the BTS7960 requires. I propose that we define Motoring
interface:
type Motoring interface {
Forward()
ForwardWithSpeed(speed uint32)
Backward()
BackwardWithSpeed(speed uint32)
Stop()
}
In the case of the Forward()
and Backward()
methods, a device with PWM would use full speed.
In the case of the ForwardWithSpeed()
and BackwardWithSpeed()
methods, a device without PWM would ignore the params and use full speed.
This will make it possible to use either the BTS7960 or the L293X with a minimal amount of code changes.
Last comment, the L293X driver does not try to configure the PWM for the user: https://github.com/tinygo-org/drivers/blob/release/l293x/l293x.go#L88-L89
This is part because not every board has the same PWM implementation, even though they expose the same interface. Just seems like it simplifies things for users.
What do you think? If it seems like a good idea, I can go back to the L293x and make sure it is doing the same thing.
Hey Sounds good, I will do it :)
Added support for bts 7960 motor driver. It is based on the C++ code from this library: https://github.com/luisllamasbinaburo/Arduino-BTS7960