edlins / libPCA9685

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

Fixes PCA9685 lockup during Init #2

Closed pvint closed 6 years ago

pvint commented 6 years ago

as discussed in Issue #1

After 0x20 was written to mode1reg my PCA9685 device became inaccessible. Enabling the SUB[1-3] and ALLCALL bits fixed the issue for me.

While I was at it I added definitions for the remaining couple bits (currently unused).

Thanks!

edlins commented 6 years ago

Hells ya. Was not expecting to ever get a PR on this repo.. I'm going to have to test this on my rig and then I'll probably setup a changelog and increment the version number. That will all take some time, but just please leave this PR open until I can merge. I wonder if my Adafruit board just auto-set these for me.. How fast can you crank it with this vs Python?

pvint commented 6 years ago

Ha! You just never know when someone might stumble upon something like this. ;)

I must say, I'm rather confused as to why it would have worked on your Adafruit board and not on my board... they are pretty much the same except I added drivers on the outputs so I could push an amp or two. (When I got the urge to do this, I saw the Adafruit boards, but decided that since I would have to make my own output drivers for it I would just make a whole new board)

Good idea on the changelog and versioning - I'm in no rush!

I haven't really experimented with it yet... I think my next step is to set up a program to accept CLI args for freq, channel, fade rate etc (like https://github.com/pvint/CHIP-Scripts/blob/master/PCA9685_PWM.py ). In the Python script the loop to fade to a new level was more than fast enough, but it was different on different platforms, and I think the speed of C will solve that little problem! Once I get something going I will do some experimenting with bus speed.

This is going to be awesome - I am SO glad to be free of a cumbersome python lib, and while I could have rolled my own in C, you saved me a ton of time and I like your implementation.

Fun stuff - and if I use this like I think I will, I owe you a beer!

edlins commented 6 years ago

:smile: In case you're curious, I used QLC+ (running on the Pi) with a custom fixture for 5 RGB LEDs to send DMX data to olad (also running on the Pi) for which I wrote a custom client that drove the PCA which used three sinks for each of my custom current-limited driver boards to drive 3W RGB LEDs. I used this for a Halloween display where I plugged a USB keyboard into the Pi and pressed space bar to progress through different custom lighting and sound scenes. The entire works (except the LEDs) are housed in a transparent Lexan case running off a reclaimed ATX power supply. Fun project, learned a lot, took a ton of time. I'll see if I can dust that off to test your commit..

edlins commented 6 years ago

So... I logged into my Pi for the first time in quite a while and found that my current source had gotten ahead of the repo here. Apparently my executive assistant forgot to commit and push the latest changes. I fired her today without severance. Do you mind pulling my "update" branch (in PR #3) and giving that a go? I'd like to merge that, and I think it's got some nice enhancements IIRC. The automatic mode in the example is setup for 12 LEDs configured like R0 G0 B0 R1 G1 B1.. but it should cycle any LEDs on the first 12 channels.