Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added methods to use a custom driver for PWM and GPIO; #15

Closed
wants to merge 1 commit into from

Conversation

beestarbush
Copy link
Contributor

With this change it is possible to override the pinMode(), digitalWrite() and analogWrite() methods in order to use a different type of GPIO or PWM output. For example: the analogWrite() can be overriden by a analogWrite() method using an external PWM driver such as PCA9685. Or the digitalWrite() method can be overriden to use a GPIO expander like the PCF8574.

@AndreaLombardo
Copy link
Owner

Hi @beestarbush, it's a great idea, but I think it can clashes with the library naming and the "easy to use" philosophy.
Unfortunaly at the moment I can't dedicate any time of mine to this project but in the future I'would like to improve the compatibility with other boards, such ESP32 and similars, and to add two new methods in the L298NX2 class to manages the rotation ( #9 ) .

The idea is:

turnLeft(ratio)
turnRight(ratio)

where ratio is a constant from -10 to 10 which determine the speed of the opposite motor in relation to other.
Negative numbers inverts the rotation, and the value determines the percentage (0 to 100 stepped by 10) relative to other motor's speed so thinking at a war tank like movements, it will be possible to achieve different degree of rotation.

Hope you understand my reasons and always thanks for your precius support.

@beestarbush
Copy link
Contributor Author

Hello Andrea,
I understand the philosophy of the library, that is also why I really like it. Regarding the improvement of compatibility with other boards, I was just browsing through the issue list and saw that in issue #13 it doesn't have the analogWrite()/digitalWrite() method but that an alternative should be provided. If we could think of a solution of this, then maybe I can also use this as an alternative. For example: create a method to set function pointers for the write/read methods, defaulting to analogWrite()/digitalWrite().
I would love to implement this if you agree with a solution as such.

@AndreaLombardo
Copy link
Owner

Yes you are right, but I think the solution is much easy implementing compiler directives such:

#ifndef ARDUINO_ESP32
    ledcWrite(...);
#elif
    analogWrite(...);
#endif

as viewed in other libraries.

To implement this I need to make searches and tests (also buy an ESP32) to make sure it works.
But as I told, I'm very busy and have no time for that, so I prefer leave a stable version for users until can dedicate more time to it ;-)

@beestarbush beestarbush deleted the customwrite branch July 23, 2021 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants