Giter Site home page Giter Site logo

libpca9685's People

Contributors

edlins avatar jmagers avatar pvint avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

libpca9685's Issues

Channels

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);

Readme.md update - required modules on Pi Zero W

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. ;)

Exclude examples from default make

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 netinst.sh for netinst

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.

Running the example code locks up my PCA9685

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

setting MODE1 options (ALLCALL)

MUST HAVE

  • Provide a mechanism for setting PCA9685 MODE1 ALLCALL bit.
  • Correct PCA9685_initPWM() to clear _PCA9685_ALLCALLBIT by default.

NICE TO HAVE

  • Include all options in MODE1 and MODE2.
  • Leverage existing bit definitions.

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);

examples shutdowns

turn off all pwm when olaclient dies
turn off all pwm when systemd stops services

ALLCALL=0 leads to lockup in some env's

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.

multiple buses/devices

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.

make test

HIGH priority (test is god)
IN PROGRESS status

Implement test cases.

  • Modify library to run on Travis CI VM (without i2c or a pca9685).
    • Provide library variables that put the library into test mode and hold an fd for test output.
    • Test mode will not open() the i2c fd but will log the attempt.
    • Test mode will not call ioctl() but will log the attempt.
  • Provide a test application containing unit tests.
    • Test application will run library either in test or for real and put it "through its paces".
  • cmake test invocation will run test application.
    • cmake invocation will redirect stdout to a file.
    • cmake will compare the actual output file to an expected output file, generated offline in dev.

remove non-debug stdout output

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.

stderr

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.

LEDs never fully turn off

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

fix handling of fd and addr

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.

types changes

cleanup the types of variables. prefer types in this order:

  1. bool (stdbool.h in c99)
  2. unsigned char
  3. int

olaclient tests

Implement test mode in olaclient
Run olaclient in test mode
Diff test mode output

Docs

are now a bit out of date (eg removed olac and olac_wrapper). Review all documentation and ensure it's accurate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.