mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.4.1 PCA9685_RT
This commit is contained in:
parent
219271f0d6
commit
7fdc79cf82
@ -1,3 +1,18 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
@ -9,3 +24,5 @@ compile:
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
||||
|
64
libraries/PCA9685_RT/CHANGELOG.md
Normal file
64
libraries/PCA9685_RT/CHANGELOG.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Change Log PCA9685
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [0.4.1] - 2022-11-19
|
||||
- add RP2040 in build-CI
|
||||
- add changelog.md
|
||||
|
||||
|
||||
## [0.4.0] - 2022-06-09
|
||||
- breaking changes (sync with pca9634)
|
||||
- rename reset() to configure()
|
||||
- add mode1 and mode2 parameter to configure.
|
||||
- add SUB CALL and ALL CALL functions.
|
||||
- update documentation.
|
||||
- renamed PCA9685_MODE2_STOP to PCA9685_MODE2_ACK
|
||||
- add mode parameters to begin()
|
||||
|
||||
----
|
||||
|
||||
## [0.3.4] - 2022-01-03
|
||||
- add channelCount()
|
||||
|
||||
## [0.3.3] - 2021-12-23
|
||||
- update library.json
|
||||
- license
|
||||
- readme
|
||||
- minor edits
|
||||
|
||||
## [0.3.2] - 2021-01-14
|
||||
- WireN support
|
||||
|
||||
## [0.3.1] - 2021-01-05
|
||||
- Arduino-CI + unit test
|
||||
|
||||
## [0.3.0] - 2020-11-22
|
||||
- fix setting frequency
|
||||
|
||||
----
|
||||
|
||||
## [0.2.3] - 2020-11-21
|
||||
- fix digitalWrite (internal version only)
|
||||
|
||||
## [0.2.2] - 2020-09-21
|
||||
- fix #1
|
||||
- add getFrequency()
|
||||
|
||||
## [0.2.1] - 2020-06-19
|
||||
- fix library.json
|
||||
|
||||
## [0.2.0] - 2020-05-25
|
||||
- refactor; ESP32 begin(sda,scl)
|
||||
|
||||
----
|
||||
|
||||
## [0.1.1] - 2019-01-30
|
||||
- testing && fixing
|
||||
|
||||
## [0.1.0] - 2021-12-02
|
||||
- initial BETA version
|
||||
|
@ -2,41 +2,17 @@
|
||||
// FILE: PCA9685.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 24-apr-2016
|
||||
// VERSION: 0.4.0
|
||||
// VERSION: 0.4.1
|
||||
// PURPOSE: Arduino library for I2C PCA9685 16 channel PWM
|
||||
// URL: https://github.com/RobTillaart/PCA9685_RT
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 2016-04-24 initial BETA version
|
||||
// 0.1.1 2019-01-30 testing && fixing
|
||||
|
||||
// 0.2.0 2020-05-25 refactor; ESP32 begin(sda,scl)
|
||||
// 0.2.1 2020-06-19 fix library.json
|
||||
// 0.2.2 2020-09-21 fix #1 + add getFrequency()
|
||||
// 0.2.3 2020-11-21 fix digitalWrite (internal version only)
|
||||
|
||||
// 0.3.0 2020-11-22 fix setting frequency
|
||||
// 0.3.1 2021-01-05 Arduino-CI + unit test
|
||||
// 0.3.2 2021-01-14 WireN support
|
||||
// 0.3.3 2021-12-23 update library.json, license, readme, minor edits
|
||||
// 0.3.4 2022-01-03 add channelCount()
|
||||
|
||||
// 0.4.0 2022-06-09 breaking changes (sync with pca9634)
|
||||
// rename reset() to configure()
|
||||
// add mode1 and mode2 parameter to configure.
|
||||
// add SUB CALL and ALL CALL functions.
|
||||
// update documentation.
|
||||
// renamed PCA9685_MODE2_STOP to PCA9685_MODE2_ACK
|
||||
// add mode parameters to begin()
|
||||
|
||||
|
||||
#include "PCA9685.h"
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constructor
|
||||
// Constructor
|
||||
//
|
||||
PCA9685::PCA9685(const uint8_t deviceAddress, TwoWire *wire)
|
||||
{
|
||||
@ -115,7 +91,7 @@ uint8_t PCA9685::readMode(uint8_t reg)
|
||||
}
|
||||
|
||||
|
||||
// write value to single PWM channel
|
||||
// write value to single PWM channel
|
||||
void PCA9685::setPWM(uint8_t channel, uint16_t onTime, uint16_t offTime)
|
||||
{
|
||||
_error = PCA9685_OK;
|
||||
@ -130,14 +106,14 @@ void PCA9685::setPWM(uint8_t channel, uint16_t onTime, uint16_t offTime)
|
||||
}
|
||||
|
||||
|
||||
// write value to single PWM channel
|
||||
// write value to single PWM channel
|
||||
void PCA9685::setPWM(uint8_t channel, uint16_t offTime)
|
||||
{
|
||||
setPWM(channel, 0, offTime);
|
||||
}
|
||||
|
||||
|
||||
// read value from single PWM channel
|
||||
// read value from single PWM channel
|
||||
void PCA9685::getPWM(uint8_t channel, uint16_t* onTime, uint16_t* offTime)
|
||||
{
|
||||
_error = PCA9685_OK;
|
||||
@ -162,7 +138,7 @@ void PCA9685::getPWM(uint8_t channel, uint16_t* onTime, uint16_t* offTime)
|
||||
}
|
||||
|
||||
|
||||
// set update frequency for all channels
|
||||
// set update frequency for all channels
|
||||
void PCA9685::setFrequency(uint16_t freq, int offset)
|
||||
{
|
||||
_error = PCA9685_OK;
|
||||
@ -170,9 +146,9 @@ void PCA9685::setFrequency(uint16_t freq, int offset)
|
||||
// limits frequency see page 25 datasheet
|
||||
if (_freq < PCA9685_MIN_FREQ) _freq = PCA9685_MIN_FREQ;
|
||||
if (_freq > PCA9685_MAX_FREQ) _freq = PCA9685_MAX_FREQ;
|
||||
// removed float operation for speed
|
||||
// faster and equal accurate
|
||||
// uint8_t scaler = round(25e6 / (_freq * 4096)) - 1;
|
||||
// removed float operation for speed
|
||||
// faster and equal accurate
|
||||
// uint8_t scaler = round(25e6 / (_freq * 4096)) - 1;
|
||||
uint8_t scaler = 48828 / (_freq * 8) - 1;
|
||||
|
||||
uint8_t mode1 = readMode(PCA9685_MODE1);
|
||||
@ -197,9 +173,9 @@ int PCA9685::getFrequency(bool cache)
|
||||
}
|
||||
|
||||
|
||||
// datasheet P.18 - fig. 9:
|
||||
// Note: bit[11-0] ON should NOT equal timer OFF in ON mode
|
||||
// in OFF mode it doesn't matter.
|
||||
// datasheet P.18 - fig. 9:
|
||||
// Note: bit[11-0] ON should NOT equal timer OFF in ON mode
|
||||
// in OFF mode it doesn't matter.
|
||||
void PCA9685::digitalWrite(uint8_t channel, uint8_t mode)
|
||||
{
|
||||
_error = PCA9685_OK;
|
||||
@ -231,7 +207,7 @@ int PCA9685::lastError()
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// SUB CALL - ALL CALL
|
||||
// SUB CALL - ALL CALL
|
||||
//
|
||||
bool PCA9685::enableSubCall(uint8_t nr)
|
||||
{
|
||||
@ -332,7 +308,7 @@ uint8_t PCA9685::getAllCallAddress()
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PRIVATE
|
||||
// PRIVATE
|
||||
//
|
||||
void PCA9685::writeReg(uint8_t reg, uint8_t value)
|
||||
{
|
||||
@ -369,4 +345,6 @@ uint8_t PCA9685::readReg(uint8_t reg)
|
||||
return _data;
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// FILE: PCA9685.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 24-apr-2016
|
||||
// VERSION: 0.4.0
|
||||
// VERSION: 0.4.1
|
||||
// PURPOSE: Arduino library for I2C PCA9685 16 channel PWM
|
||||
// URL: https://github.com/RobTillaart/PCA9685_RT
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define PCA9685_LIB_VERSION (F("0.4.0"))
|
||||
#define PCA9685_LIB_VERSION (F("0.4.1"))
|
||||
|
||||
// ERROR CODES
|
||||
#define PCA9685_OK 0x00
|
||||
|
@ -205,8 +205,13 @@ See examples
|
||||
|
||||
## Future
|
||||
|
||||
#### must
|
||||
- improve documentation
|
||||
|
||||
#### should
|
||||
- add unit tests (if possible)
|
||||
|
||||
#### could
|
||||
- investigate int vs uint16_t ?
|
||||
- **setFrequency(), getFrequency(), \_freq**
|
||||
- sync with PCA9634/35/85 where possible
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/PCA9685_RT.git"
|
||||
},
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=PCA9685_RT
|
||||
version=0.4.0
|
||||
version=0.4.1
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for I2C PCA9685 16 channel PWM
|
||||
|
Loading…
Reference in New Issue
Block a user