Skip to content

Commit

Permalink
0.1.2 TLC5947
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Nov 22, 2023
1 parent 56dc45a commit 9267104
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 16 deletions.
6 changes: 6 additions & 0 deletions libraries/TLC5947/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 19 additions & 9 deletions libraries/TLC5947/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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,


6 changes: 4 additions & 2 deletions libraries/TLC5947/TLC5947.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}

Expand All @@ -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));
}

Expand Down
6 changes: 4 additions & 2 deletions libraries/TLC5947/TLC5947.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
//
// 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"


#define TLC5947_MAX_CHANNELS 24

#define TLC5947_CHANNEL_ERROR 0xFFFF


class TLC5947
{
Expand Down
3 changes: 3 additions & 0 deletions libraries/TLC5947/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ setPercentage KEYWORD2
getPercentage KEYWORD2
setPercentageAll KEYWORD2

write KEYWORD2

enable KEYWORD2
disable KEYWORD2

Expand All @@ -26,4 +28,5 @@ disable KEYWORD2
# Constants (LITERAL1)
TLC5947_LIB_VERSION LITERAL1

TLC5947_CHANNEL_ERROR LITERAL1

4 changes: 2 additions & 2 deletions libraries/TLC5947/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion libraries/TLC5947/library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TLC5947
version=0.1.1
version=0.1.2
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for TLC5947 24 channel 12 bit PWM.
Expand Down

0 comments on commit 9267104

Please sign in to comment.