edlins / libPCA9685

superfast PCA9685 library for Debian platforms. developed on Raspbian on a Pi B+.
MIT License
13 stars 8 forks source link

setting MODE1 options (ALLCALL) #15

Closed edlins closed 6 years ago

edlins commented 6 years ago

MUST HAVE

NICE TO HAVE

Right now, develop is hardcoded to set ALLCALL. It should change to clear ALLCALL. Add a new function int PCA9685_MODE1_opts(unsigned char) where the unsigned char represents the options in MODE1 as defined in PCA9685.h. PCA9685_initPWM(int, unsigned char, unsigned int) should use reasonable defaults when PCA9685_MODE1_opts() is not called. _PCA9685_AUTOINCBIT should always be set (that's half the point of the lib).

int ret = PCA9685_MODE1_opts(0x00 | _PCA9685_SUB1BIT | _PCA9685_ALLCALLBIT);
edlins commented 6 years ago

Alternately this could be done with an extern unsigned char _PCA9685_MODE1_OPTIONS that is set directly from applications instead of adding a function.

pvint commented 6 years ago

int ret = PCA9685_MODE1_opts(0x00 | _PCA9685_SUB1BIT | _PCA9685_ALLCALLBIT);

I like this! I would like the ability to use it to clear the AUTOINC bit if I so choose, however. (Although off the top of my head I cannot think of a situation where it would really be hurting anything)

I think I will look at this tonight, but if I don't get to it tonight it's highly unlikely that I will have time over the weekend so if you don't see anything tonight you won't see anything for a few days at least.

pvint commented 6 years ago

Added the PR #20 for this.

If there's anything you don't like about the implementation feel free to let me know (just don't dock my pay). :)

Edit: Just committed the change to remove setting the ALLCALL bit by default.

edlins commented 6 years ago

Added PR #24 for my solution. Please test this before I merge into develop. Also LMK if you have any feedback on the code changes. Thanks!

edlins commented 6 years ago

This got a little ugly with unrelated changes that I didn't branch out, but I'm confident so I merged it. If there's a problem, please open a new issue.