diff --git a/libraries/TLC5947/CHANGELOG.md b/libraries/TLC5947/CHANGELOG.md index 60c5ac52e..323f248bc 100644 --- a/libraries/TLC5947/CHANGELOG.md +++ b/libraries/TLC5947/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.1.2] - 2023-11-22 +- update readme.md +- add **TLC5947_CHANNEL_ERROR** +- catch negative percentages. + + ## [0.1.1] - 2023-06-21 - improve performance AVR - add percentage wrappers diff --git a/libraries/TLC5947/README.md b/libraries/TLC5947/README.md index 5f7fda3d0..4658665c7 100644 --- a/libraries/TLC5947/README.md +++ b/libraries/TLC5947/README.md @@ -2,8 +2,11 @@ [![Arduino CI](https://github.com/RobTillaart/TLC5947/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) [![Arduino-lint](https://github.com/RobTillaart/TLC5947/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/TLC5947/actions/workflows/arduino-lint.yml) [![JSON check](https://github.com/RobTillaart/TLC5947/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/TLC5947/actions/workflows/jsoncheck.yml) +[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/TLC5947.svg)](https://github.com/RobTillaart/TLC5947/issues) + [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/TLC5947/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/RobTillaart/TLC5947.svg?maxAge=3600)](https://github.com/RobTillaart/TLC5947/releases) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/TLC5947.svg)](https://registry.platformio.org/libraries/robtillaart/TLC5947) # TLC5947 @@ -34,7 +37,7 @@ The data can be shared (to be tested) as data won't be clocked in if the **clock** line is not shared. -#### Links +#### Related - https://www.adafruit.com/product/1429 - https://github.com/RobTillaart/TLC5947 @@ -54,8 +57,8 @@ Defines the pins used for uploading / writing the PWM data to the module. The blank pin is explained in more detail below. - **~TLC5947()** destructor - **bool begin()** set the pinModes of the pins and their initial values. -- **bool setPWM(uint8_t channel, uint16_t PWM)**. set a PWM value to the buffer to -be written later. +- **bool setPWM(uint8_t channel, uint16_t PWM)**. set a PWM value to +the buffer to be written later. channel = 0..23, PWM = 0..4095 Returns true if successful. - **void setAll(uint16_t PWM)** set the same PWM value for all channels to the buffer, and writes them to device. @@ -118,9 +121,10 @@ Measured with **TLC5947_performance.ino**. - buy hardware - test test test - #### Should +- **setPWM()** should return set value or error + - revisit all functions.. - add examples - extend performance sketch - test if partial write (e.g. first N channels) works. @@ -129,19 +133,25 @@ Measured with **TLC5947_performance.ino**. - set by **setPWM()** if value changes. - would speed up unneeded **write()** too. - #### Could - add unit-tests -- add **void setPercentage(float perc)** and **float getPercentage()** wrappers. - investigate how to reduce memory usage (now 48 bytes) - - could be 36 (12 bits / channel) or even 24 (8 bits/channel) - - derived class? + - could be 36 (12 bits / channel) + - or even 24 (8 bits/channel) = derived class? - add **setRGB(LED, R, G, B)** wrapper (channel 0..7) 24 channels == 3 x 8 RGB LEDs - return value for **setPWM()** ? +#### Wont + + +## Support + +If you appreciate my libraries, you can support the development and maintenance. +Improve the quality of the libraries by providing issues and Pull Requests, or +donate through PayPal or GitHub sponsors. -#### Won't +Thank you, diff --git a/libraries/TLC5947/TLC5947.cpp b/libraries/TLC5947/TLC5947.cpp index 843b7b3b9..4e8ff17d7 100644 --- a/libraries/TLC5947/TLC5947.cpp +++ b/libraries/TLC5947/TLC5947.cpp @@ -1,7 +1,7 @@ // // FILE: TLC5947.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 +// VERSION: 0.1.2 // DATE: 2023-06-17 // PURPOSE: Arduino library for the TLC5947 24 channel PWM device // URL: https://github.com/RobTillaart/TLC5947 @@ -50,7 +50,7 @@ bool TLC5947::setPWM(uint8_t channel, uint16_t PWM) uint16_t TLC5947::getPWM(uint8_t channel) { - if (channel >= 24) return 0xFFFF; + if (channel >= 24) return TLC5947_CHANNEL_ERROR; return _buffer[channel] & 0x0FFF; } @@ -68,12 +68,14 @@ void TLC5947::setAll(uint16_t PWM) bool TLC5947::setPercentage(uint8_t channel, float perc) { + if (perc < 0) perc = 0; return setPWM(channel, round(perc * 40.95)); } void TLC5947::setPercentageAll(float perc) { + if (perc < 0) perc = 0; setAll(round(perc * 40.95)); } diff --git a/libraries/TLC5947/TLC5947.h b/libraries/TLC5947/TLC5947.h index 8148988c3..304e5352a 100644 --- a/libraries/TLC5947/TLC5947.h +++ b/libraries/TLC5947/TLC5947.h @@ -2,13 +2,13 @@ // // FILE: TLC5947.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 +// VERSION: 0.1.2 // DATE: 2023-06-17 // PURPOSE: Arduino library for the TLC5947 24 channel PWM device // URL: https://github.com/RobTillaart/TLC5947 -#define TLC5947_LIB_VERSION (F("0.1.1")) +#define TLC5947_LIB_VERSION (F("0.1.2")) #include "Arduino.h" @@ -16,6 +16,8 @@ #define TLC5947_MAX_CHANNELS 24 +#define TLC5947_CHANNEL_ERROR 0xFFFF + class TLC5947 { diff --git a/libraries/TLC5947/keywords.txt b/libraries/TLC5947/keywords.txt index 251c0f768..0bfd5a2aa 100644 --- a/libraries/TLC5947/keywords.txt +++ b/libraries/TLC5947/keywords.txt @@ -16,6 +16,8 @@ setPercentage KEYWORD2 getPercentage KEYWORD2 setPercentageAll KEYWORD2 +write KEYWORD2 + enable KEYWORD2 disable KEYWORD2 @@ -26,4 +28,5 @@ disable KEYWORD2 # Constants (LITERAL1) TLC5947_LIB_VERSION LITERAL1 +TLC5947_CHANNEL_ERROR LITERAL1 diff --git a/libraries/TLC5947/library.json b/libraries/TLC5947/library.json index 3d9456141..ff41371a4 100644 --- a/libraries/TLC5947/library.json +++ b/libraries/TLC5947/library.json @@ -15,9 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/TLC5947.git" }, - "version": "0.1.1", + "version": "0.1.2", "license": "MIT", - "frameworks": "arduino", + "frameworks": "*", "platforms": "*", "headers": "TLC5947.h" } diff --git a/libraries/TLC5947/library.properties b/libraries/TLC5947/library.properties index 95a80339a..ab1c04349 100644 --- a/libraries/TLC5947/library.properties +++ b/libraries/TLC5947/library.properties @@ -1,5 +1,5 @@ name=TLC5947 -version=0.1.1 +version=0.1.2 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for TLC5947 24 channel 12 bit PWM.