edlins / libpca9685 Goto Github PK
View Code? Open in Web Editor NEWsuperfast PCA9685 library for Debian platforms. developed on Raspbian on a Pi B+.
License: MIT License
superfast PCA9685 library for Debian platforms. developed on Raspbian on a Pi B+.
License: MIT License
Hello,
I would like to know how to connect only one channel of PCA9685 through this code.
I am using "PCA9685_setAllPWM", and connect all channels, I would like to control the independent channels.
Test like that and it did not work.
setPWMVals (_pca, 0x40, 0, 1, 2000);
On my Pi Zero Wireless I needed to add to /etc/modules.conf:
i2c-dev
i2c-bcm2708
I'm not certain I needed both of those, and I have to set up another one so I will will confirm and submit a PR for the readme update.
I cannot assign this to me, but consider this self-assigned. ;)
I've been gone for a long time. It seems during that time that Travis-CI no longer supports free accounts.
I could use some assistance migrating my Travis-CI configuration to a new free CI service but I have limited time.
I can offer a small payment for this work, maybe enough to buy a beer. Any takers?
The result must have the same or equivalent functionality as this: https://github.com/edlins/libPCA9685/blob/develop/.travis.yml
Forgive me if it's already the case and it's a RTFM issue, but I am short on time and wanted to document this:
Compiling on a fresh Pi and getting the following error:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
^~~~~~~
/usr/local/src/libPCA9685/examples/PCA9685demo/PCA9685demo.c:10:21: fatal error: ncurses.h: No such file or directory
#include <ncurses.h>
I will just install ncurses (apt-get install libncurses5-dev
) which stops the issue, but I just want the lib and it is only required for the demo.
Cheers!
Paul
Provide a netinst.sh
script for {raspbian, raspberrypi}-ua-netinst that will deploy to a netinst host during provisioning. Script will be downloaded and executed from post-install.txt
via chroot /rootfs/<script>
.
Initially just the lib is required to be built, tested, and installed. Eventually would be nice to have all examples but that could be unwieldy due to dependencies.
From https://travis-ci.org/edlins/libPCA9685/builds/489310992 (build 268):
$ cat /var/log/olaclient.log
cat: /var/log/olaclient.log: No such file or directory
The command "cat /var/log/olaclient.log" exited with 1.
Current work-around is commenting out the cat
command from .travis.yml
.
Hi!
First off - I was very glad to find this! This is exactly what I wanted... I've been using and modifying the Adafruit Python libs for this, and while it works fine I find that it's pretty bloated and slow, and you have saved me the bother of writing this in C. Thanks!
When I try to run the PCA9685demo in examples it's locking up my device and i2cdetect -y 1
doesn't even see it after running this. A power cycle of my board clears it up, and my Python scripts then work again.
I'm about out of time to try to debug this right now, and I am really just adding this issue for my own records and I will look at it more.
Here is what I see on the console when I run ./PCA9685demo with #define DEBUG
set:
PCA9685_openI2C(): opened /dev/i2c-1 as fd 3
_PCA9685_readI2CReg(): 70:00:46 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
_PCA9685_readI2CReg(): 70:fa:05 00 00 00 00 00
00 00 00 00 00
_PCA9685_writeI2CRaw: 00: 06
PCA9685_setPWMVal(): reg fa, on 00, off 00
_PCA9685_writeI2CReg(): 70:fa:01 00
_PCA9685_writeI2CRaw: 70: fa 00
_PCA9685_writeI2CReg(): 70:fb:01 00
_PCA9685_writeI2CRaw: 70: fb 00
_PCA9685_writeI2CReg(): 70:fc:01 00
_PCA9685_writeI2CRaw: 70: fc 00
_PCA9685_writeI2CReg(): 70:fd:01 00
_PCA9685_writeI2CRaw: 70: fd 00
_PCA9685_readI2CReg(): 70:00:01 11
_PCA9685_writeI2CReg(): 70:00:01 11
_PCA9685_writeI2CRaw: 70: 00 11
_PCA9685_writeI2CReg(): 70:fe:01 1e
_PCA9685_writeI2CRaw: 70: fe 1e
_PCA9685_writeI2CReg(): 70:00:01 01
_PCA9685_writeI2CRaw: 70: 00 01
_PCA9685_writeI2CReg(): 70:00:01 81
_PCA9685_writeI2CRaw: 70: 00 81
_PCA9685_writeI2CReg(): 70:00:01 20
_PCA9685_writeI2CRaw: 70: 00 20
_PCA9685_readI2CReg(): ioctl() returned -1 on addr 70 start 00
PCA9685_dumpAllRegs(): _PCA9685_readI2CReg() returned -1
initHardware(): PCA9685_dumpAllRegs() returned -1
PCA9685_setPWMVal(): reg fa, on 00, off 00
_PCA9685_writeI2CReg(): 70:fa:01 00
_PCA9685_writeI2CRaw: 70: fa 00
_PCA9685_writeI2CRaw(): ioctl() returned -1 on addr 70
_PCA9685_writeI2CRaw(): len = 2, buf = fa 00
_PCA9685_writeI2CReg(): _PCA9685_writeI2CRaw() returned -1 on addr 70 reg fa
PCA9685_setPWMVal(): _PCA9685_writeI2CReg() returned -1 on addr 70 reg fa val 00
PCA9685_setAllPWM(): PCA9685_setPWMVal() returned -1
main(): initHardware() returned -1 for adpt 1 at addr 70
root@raspberrypi:/usr/local/src/libPCA9685/examples # ```
After that I can no longer see the device on my I²C bus until I power cycle it. Note that this is a board of my own design, so it's conceivable that there's a hardware issue, however I have been using it a lot with the Python scripts and have never run into an issue.
I will look at this more (and the debugging output is nice, btw), but if I cannot figure out anything from the software side I will put my scope on the bus and do some tests to see if I can see what might be different.
Thanks again!
Paul
autoconf'd PCA9685demo and libPCA9685.
Travis CI hacked into operation via fake configure script and fake Makefile at top level.
still need to autoconf quickstart and fix CI hack.
https://travis-ci.org/edlins/libPCA9685
MUST HAVE
PCA9685
MODE1
ALLCALL
bit.PCA9685_initPWM()
to clear _PCA9685_ALLCALLBIT
by default.NICE TO HAVE
MODE1
and MODE2
.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);
turn off all pwm when olaclient dies
turn off all pwm when systemd stops services
Follow-up issue to investigate why having the ALLCALL
bit in MODE1
set to zero causes a lockup for @pvint but not on my Adafruit board. Please enable#define DEBUG
in both the library and the demo and include the output here. Also please disable //#define VALIDATE
and //#define NCMODE
in the demo.
LOW priority (not requested, can't test)
IDLE status (not a WIP)
Add support for multiple i2c buses.
Add support for multiple PCA9685s, on the same or different buses.
I'm just parking this here in case somebody comes along with multiple devices but it's not currently in progress.
HIGH priority (test is god)
IN PROGRESS status
Implement test cases.
dumpAllRegs()
prints the values to stdout. Better to fetchAllRegs()
into one or more arrays and return those to the apps which are responsible for displaying the values however they want.
EDIT: or both.
Add key commands to the demo to adjust the PWM frequency on the fly.
HIGH priority (not a bug but easy and important)
SCHEDULED status (after #15 )
Consistently use fprintf(stderr
through the lib in all error conditions. Return value checking is comprehensive but use of stderr is not.
I'm using LEDs with the PCA9685 as a current sink and can't get them to fully turn off. LEDs are very dim but still on.
I would expect that when using PCA9685_setPWMVals with onVals all set to zeros and offVals all set to 4095 then all LEDs would be completely off.
After some googling I found that there is a special value for this chip, 4096, for setting a channel to completely off but could not get this to work either.
https://forums.adafruit.com/viewtopic.php?f=22&t=52817
PRIORITY: LOW (not a bug, transparent change)
STATUS: NOT SCHEDULED (whenever it's convenient)
All messed up. Rename lib globals to "_fd" and "_addr" to avoid confusion. Assign their values in _openI2C(). Use "_fd" and "_addr" throughout.
cleanup the types of variables. prefer types in this order:
Add a spectrum analyzer example app.
USB audio input
optionally use GPU_FFT for fast fourier transform
optionally 16 channels = 16 frequency bins (directly set PWM levels),
or 5 RGBs = 5 frequency bins = 15 channels (HSV dim blue to bright red) + 1 channel BPM detection
Resources:
https://stackoverflow.com/questions/4364823/how-do-i-obtain-the-frequencies-of-each-value-in-an-fft
instead of different vars for each component.
Implement test mode in olaclient
Run olaclient in test mode
Diff test mode output
are now a bit out of date (eg removed olac
and olac_wrapper
). Review all documentation and ensure it's accurate.
parameterize the adapter and address in the examples
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.