GithubHelp home page GithubHelp logo

nickvantholen / pca9634-lib Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 22 KB

This repository is made for the NXP PCA9634 IC. It's an usefull chip for interfacing with multiple LED's. That's why I created this library to take full advantage of the chip's capabilities!

License: GNU General Public License v3.0

C++ 100.00%
arduino-library arduino nxp pca9634 i2c i2c-protocol i2c-device i2c-library

pca9634-lib's Introduction

README

This is the readme for the PCA9634 library, it contains some usefull information on how to use the libraray.

INFO

This is the library that is used to control the PCA9634 chip from NXP semiconductors. It is based on the I2C protocol and contains some usefull functions.

Functions

Setup

The only thing that you will need to include is the Wire.h library, this library will start the I2C protocol automaticly on the standard I2C pins of the microcontroller.

Actual functions

  • Constructor - PCA9634 your_name(adress, oePin), adress is the I2C adress, oePin is the pin where output enable (OE) is connected.
  • Begin - your_name.begin(), set up and begin the I2C connection, set OE as output and enables the chip, sets the register to the right values.
  • Enabled - your_name.enabled(state), sets the OE to turn on or off the outputs, requires a boolean value, if true the chip is enabled, if false the chip is disabled.
  • WriteReg - your_name.writeReg(reg, val), enables you to write costum values to a register in the chip, reg is the hex value of the register you want to write to. The val is the value you want to write to the specified register. Also returns the I2C status as an integer for debuging purposes.
  • ReadReg - your_name.readReg(reg), enables you to read the contents of a register to use in the programm, reg is the hex value of the register you want to read from. It returns the content of the register as one byte of data.
  • On - your_name.on(pin), enables you to turn on a channel, pin variable needs to be an value between 0 and 7.
  • Off - your_name.off(pin), enables you to turn off a channel, pin variable needs to be an value between 0 and 7.
  • allOn - your_name.allOn(), enables you to turn all channels on.
  • allOf - your_name.allOff(), enables you to turn all channels off.
  • Pwm - your_name.pwm(pin, value), enables you to write a pwm value to a single channel, pin variable needs to be an value between 0 and 7, value variable uses one byte.
  • FadeIn - your_name.fadeIn(pin, time, brightness), enables you to fade in a led channel, pin variable needs to be an value between 0 and 7. The time variable is the total time for the fade in in milliseconds, it expects a whole number. The brightness variable is the brightness to fade to, it expects a one byte of data and defaults to 255 if no value is given.
  • FadeOut - your_name.fadeOut(pin, time, brightness), enables you to fade out a led channel, pin variable needs to be an value between 0 and 7. The time variable is the total time for the fade out in milliseconds, it expects a whole number. The brightness variable is the brightness to fade to, it expects a one byte of data and defaults to 0 if no value is given.
  • ledStatus - your_name.ledStatus(pin), this function enables you to check if a certain channel is off, on or on pwm modus. The pin variable needs to be an value between 0 and 7. The function returns a 0 if the channel is off, a 1 if the channel is on or a 2 if the channel is using pwm.
  • pwmStatus - your_name.pwmStatus(pin), this function enabels you to check the pwm value of a channel. The pin variable needs to be an value between 0 and 7. The function returns one byte of data respresenting the pwm value of the channel.
  • SoftReset - your_name.softReset(), this function enables the software resetting of the PCA9634 chip. Be careful with this function as it will reset all registers!

Removed functions

  • PinType - your_name.pinType(type, pin, all), enables you to set all or a single output to off, on or pwm-mode. To set all outputs set the all value to true, if nothing is enterd here it defaults to false. Type selects the mode for the pin, it uses the int value after the mode off(0), on(1), pwm(2). The pin variable needs a value between 0 and 7 to select the pin you want to control. Removed
  • ChanPWM - your_name.chanPwm(channel, value), enables you to set the pwm value for each channel individualy. The channel variable needs a value between 0 and 7 to select the pin you want to control. The value variable needs one byte of data to set the dutycycle of the selected led channel. Removed

Changelog

  • 07-06-2020 The initial setup of this library.
  • 07-06-2020 Added a keywords.txt file and example for blinking leds with the pintype function.
  • 09-06-2020 Moved pintype and ChanPWM function to private and added some new functions like: on, off, allOn, allOff, pwm, fadeIn & fadeOut. Also added some basic comments to the cpp file. Added removed functions to readme and added new functions to keywords file.
  • 23-06-2020 Added the readReg, ledStatus & pwmStatus functions and fixed some issues in allOn and allOff functions not working properly.

Future updates

  • Fade in/out function Done
  • Group pwm
  • Blinking of leds
  • Write different value to all leds
  • Read register function Done
  • Read led status from pca9634 Done

pca9634-lib's People

Contributors

nickvantholen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

tokuhira

pca9634-lib's Issues

Request for License Change from GNU License to MIT License for MakeCode Library Derived from Your Repository

We recently came across your repository while searching for a functional library for the PCA9634. We are currently developing a TypeScript library for the MakeCode platform based on your "pca9634-lib".

Our intention is to publish this library as a repository. However, we are facing an issue with regard to licensing. We are unable to use the GNU License. The MakeCode platform requires the use of the MIT License when uploading repositories as MakeCode extensions.

In light of this, we kindly request permission to change the license of our specific repository from the GNU License to the MIT License. This license change would allow us to comply with the licensing requirements of the MakeCode platform. We are also willing to put a link to your repository in our README file as the very first point.

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.