From 342c1d0c755300b2823cc0dee728410c6d289927 Mon Sep 17 00:00:00 2001 From: rob tillaart Date: Sun, 25 Sep 2022 09:59:53 +0200 Subject: [PATCH] 0.3.3 TM1637_RT --- libraries/TM1637_RT/CHANGELOG.md | 54 ++++++++++++++ libraries/TM1637_RT/README.md | 26 +++++-- libraries/TM1637_RT/TM1637.cpp | 23 ++---- libraries/TM1637_RT/TM1637.h | 74 ++++++++++--------- .../examples/TM1637_HEX/TM1637_HEX.ino | 4 +- .../examples/TM1637_alpha/TM1637_alpha.ino | 3 +- .../TM1637_clock_4digits.ino | 3 +- .../examples/TM1637_float/TM1637_float.ino | 4 +- .../examples/TM1637_int/TM1637_int.ino | 5 +- .../TM1637_keyscan_cooked.ino | 4 +- .../TM1637_keyscan_raw/TM1637_keyscan_raw.ino | 7 +- libraries/TM1637_RT/keywords.txt | 3 +- libraries/TM1637_RT/library.json | 2 +- libraries/TM1637_RT/library.properties | 2 +- 14 files changed, 141 insertions(+), 73 deletions(-) create mode 100644 libraries/TM1637_RT/CHANGELOG.md diff --git a/libraries/TM1637_RT/CHANGELOG.md b/libraries/TM1637_RT/CHANGELOG.md new file mode 100644 index 00000000..8db05841 --- /dev/null +++ b/libraries/TM1637_RT/CHANGELOG.md @@ -0,0 +1,54 @@ +# Change Log TM1637 + +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.3.3] - 2022-09-24 + +- added CHANGELOG.md +- added **begin()** to replace **init()** in due time. +- updated documentation + +## [0.3.2] - 2022-04-16 + +- fix #15 support for 4 digits. +- tested on 4 digit (clock) display. + +## [0.3.1] - 2021-12-29 + +- update library.json +- update license +- update readme.md +- minor edits +- tested on 6 digits display (with decinal point). + +## [0.3.0] - 2021-10-27 + +- improved keyscan - kudos to wfdudley +- update documentation + +## [0.2.1] - 2021-10-07 + +- add support for letters g-z; added keyscan() +- tested on ESP8266 + +## [0.2.0] - 2021-09-26 + +- add ESP32 support - kudos to alexthomazo + +## [0.1.2] - 2021-04-16 + +- update readme +- fix default values + +## [0.1.1] - 2021-02-15 + +- first release +- added examples + +## [0.1.0] - 2019-10-28 + +- initial version + diff --git a/libraries/TM1637_RT/README.md b/libraries/TM1637_RT/README.md index efa4d673..bd2c63c6 100644 --- a/libraries/TM1637_RT/README.md +++ b/libraries/TM1637_RT/README.md @@ -1,8 +1,8 @@ [![Arduino CI](https://github.com/robtillaart/TM1637_RT/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) [![Arduino-lint](https://github.com/RobTillaart/TM1637_RT/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/TM1637_RT/actions/workflows/arduino-lint.yml) [![JSON check](https://github.com/RobTillaart/TM1637_RT/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/TM1637_RT/actions/workflows/jsoncheck.yml) -[![GitHub release](https://img.shields.io/github/release/RobTillaart/TM1637_RT.svg?maxAge=3600)](https://github.com/RobTillaart/TM1637_RT/releases) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/TM1637_RT/blob/master/LICENSE) +[![GitHub release](https://img.shields.io/github/release/RobTillaart/TM1637_RT.svg?maxAge=3600)](https://github.com/RobTillaart/TM1637_RT/releases) # TM1637 @@ -22,7 +22,7 @@ ESP32 is supported since 0.2.0 see https://github.com/RobTillaart/TM1637_RT/pull ## Interface - **TM1637()** constructor -- **void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)** set up the connection of the pins to the display. +- **void begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)** set up the connection of the pins to the display. As the display is only tested with a 6 digit display, this is used as the default of the digits parameter. - **void displayRaw(uint8_t \* data, uint8_t pointPos)** low level write function. - **void displayInt(long value)** idem @@ -49,6 +49,12 @@ See routine **ascii_to_7segment()** in the example TM1637_keyscan_cooked.ino. I Routine **button_poll()** in the same example shows one way of polling and de-bouncing button presses. +#### Obsolete (0.4.0) + +- **void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)** replaced by begin(). + + + ### Display support The library is tested with a 6 (=2x3) digit - decimal point - display and a 4 (=1x4) digit - clock - display. @@ -150,9 +156,15 @@ See examples ## Future -- elaborate documentation -- testing -- rename **init()** to **begin()** ? -- **keyScan()** camelCase ? -- separate CHANGELOG.md +### 0.4.0 + +- remove obsolete **init()** from code + +### other + +- testing platforms. +- investigate if code can be optimized + - performance measurement +- **keyScan()** camelCase ? + diff --git a/libraries/TM1637_RT/TM1637.cpp b/libraries/TM1637_RT/TM1637.cpp index 7e2e1540..2f623ed2 100644 --- a/libraries/TM1637_RT/TM1637.cpp +++ b/libraries/TM1637_RT/TM1637.cpp @@ -2,23 +2,9 @@ // FILE: TM1637.cpp // AUTHOR: Rob Tillaart // DATE: 2019-10-28 -// VERSION: 0.3.2 +// VERSION: 0.3.3 // PURPOSE: TM1637 library for Arduino // URL: https://github.com/RobTillaart/TM1637_RT -// -// HISTORY: -// 0.1.0 2019-10-28 initial version -// 0.1.1 2021-02-15 first release + examples. -// 0.1.2 2021-04-16 update readme, fix default values. -// 0.2.0 2021-09-26 add ESP32 support - kudos to alexthomazo -// 2021-10-07 add support for letters g-z; added keyscan() -// tested on ESP8266 -// 0.3.0 2021-10-27 improved keyscan + documentation - kudos to wfdudley -// 0.3.1 2021-12-29 update library.json, license, readme, minor edits -// tested on 6 digits (decimal point) display -// 0.3.2 2022-04-16 fix #15 support for 4 digits. -// tested on 4 digit (clock) display. - // NOTE: // on the inexpensive TM1637 boards @wfdudley has used, keyscan @@ -84,7 +70,14 @@ TM1637::TM1637() } +// wrapper, will become obsolete 0.4.0. void TM1637::init(uint8_t clockPin, uint8_t dataPin, uint8_t digits) +{ + begin(clockPin, dataPin, digits); +} + + +void TM1637::begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits) { _clock = clockPin; _data = dataPin; diff --git a/libraries/TM1637_RT/TM1637.h b/libraries/TM1637_RT/TM1637.h index 8bb3991f..2d65a986 100644 --- a/libraries/TM1637_RT/TM1637.h +++ b/libraries/TM1637_RT/TM1637.h @@ -3,61 +3,67 @@ // FILE: TM1637.h // AUTHOR: Rob Tillaart // DATE: 2019-10-28 -// VERSION: 0.3.2 +// VERSION: 0.3.3 // PUPROSE: TM1637 library for Arduino // URL: https://github.com/RobTillaart/TM1637_RT -// only tested on 6 digit display yet +// tested on 6 digit display + 4 digit (clock) display #include "Arduino.h" -#define TM1637_LIB_VERSION (F("0.3.2")) +#define TM1637_LIB_VERSION (F("0.3.3")) class TM1637 { - public: - TM1637(); +public: + TM1637(); - void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6); + // replaces init() + void begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6); - void displayRaw(uint8_t * data, uint8_t pointPos); - void displayInt(long value); - void displayFloat(float value); - void displayHex(uint32_t value); - void displayClear(); + void displayRaw(uint8_t * data, uint8_t pointPos); + void displayInt(long value); + void displayFloat(float value); + void displayHex(uint32_t value); + void displayClear(); - void setBrightness(uint8_t b); - uint8_t getBrightness() { return _brightness; }; + void setBrightness(uint8_t b); + uint8_t getBrightness() { return _brightness; }; - // tune the timing of writing bytes. - void setBitDelay(uint8_t bitDelay = 10) { _bitDelay = bitDelay; }; - uint8_t getBitDelay() { return _bitDelay; }; - uint8_t keyscan(void); + // tune the timing of writing bytes. + void setBitDelay(uint8_t bitDelay = 10) { _bitDelay = bitDelay; }; + uint8_t getBitDelay() { return _bitDelay; }; + uint8_t keyscan(void); - // the order the individual digits must be sent to the display. - void setDigitOrder(uint8_t a = 0, uint8_t b = 1, - uint8_t c = 2, uint8_t d = 3, - uint8_t e = 4, uint8_t f = 5, - uint8_t g = 6, uint8_t h = 7); + // the order the individual digits must be sent to the display. + void setDigitOrder(uint8_t a = 0, uint8_t b = 1, + uint8_t c = 2, uint8_t d = 3, + uint8_t e = 4, uint8_t f = 5, + uint8_t g = 6, uint8_t h = 7); - private: - uint8_t _clock = -1; - uint8_t _data = -1; - uint8_t _digits = 4; - uint8_t _brightness = 3; - uint8_t _bitDelay = 10; + // OBSOLETE + // init will be replaced by begin() in the future (0.4.0) + void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6); - uint8_t _digitOrder[8]; - uint8_t writeByte(uint8_t data); - void start(); - void stop(); +private: + uint8_t _clock = -1; + uint8_t _data = -1; + uint8_t _digits = 4; + uint8_t _brightness = 3; + uint8_t _bitDelay = 10; - void writeSync(uint8_t pin, uint8_t val); - void nanoDelay(uint16_t n); + uint8_t _digitOrder[8]; + + uint8_t writeByte(uint8_t data); + void start(); + void stop(); + + void writeSync(uint8_t pin, uint8_t val); + void nanoDelay(uint16_t n); }; diff --git a/libraries/TM1637_RT/examples/TM1637_HEX/TM1637_HEX.ino b/libraries/TM1637_RT/examples/TM1637_HEX/TM1637_HEX.ino index 036dc89d..c845ef6e 100644 --- a/libraries/TM1637_RT/examples/TM1637_HEX/TM1637_HEX.ino +++ b/libraries/TM1637_RT/examples/TM1637_HEX/TM1637_HEX.ino @@ -2,7 +2,6 @@ // FILE: TM1637_HEX.ino // AUTHOR: Rob Tillaart // PURPOSE: demo TM1637 library -// DATE: 2021-02-15 // URL: https://github.com/RobTillaart/TM1637 // test with 6 digits (decimal) display @@ -21,7 +20,8 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.init(2, 3, 6); + TM.begin(2, 3, 6); // clockpin, datapin, #digits + TM.displayClear(); delay(2000); diff --git a/libraries/TM1637_RT/examples/TM1637_alpha/TM1637_alpha.ino b/libraries/TM1637_RT/examples/TM1637_alpha/TM1637_alpha.ino index e28cdd68..5fb3c307 100644 --- a/libraries/TM1637_RT/examples/TM1637_alpha/TM1637_alpha.ino +++ b/libraries/TM1637_RT/examples/TM1637_alpha/TM1637_alpha.ino @@ -17,7 +17,8 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.init(2, 3); + TM.begin(2, 3); // clockpin, datapin + TM.setBrightness(2); } diff --git a/libraries/TM1637_RT/examples/TM1637_clock_4digits/TM1637_clock_4digits.ino b/libraries/TM1637_RT/examples/TM1637_clock_4digits/TM1637_clock_4digits.ino index 04555b61..2d195acc 100644 --- a/libraries/TM1637_RT/examples/TM1637_clock_4digits/TM1637_clock_4digits.ino +++ b/libraries/TM1637_RT/examples/TM1637_clock_4digits/TM1637_clock_4digits.ino @@ -20,7 +20,8 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.init(7, 6, 4); + TM.begin(7, 6, 4); // clockpin, datapin, #digits + TM.displayClear(); delay(2000); diff --git a/libraries/TM1637_RT/examples/TM1637_float/TM1637_float.ino b/libraries/TM1637_RT/examples/TM1637_float/TM1637_float.ino index bc05496b..b23b35f8 100644 --- a/libraries/TM1637_RT/examples/TM1637_float/TM1637_float.ino +++ b/libraries/TM1637_RT/examples/TM1637_float/TM1637_float.ino @@ -2,7 +2,6 @@ // FILE: TM1637_float.ino // AUTHOR: Rob Tillaart // PURPOSE: demo TM1637 library -// DATE: 2021-02-15 // URL: https://github.com/RobTillaart/TM1637 @@ -20,7 +19,8 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.init(2, 3); + TM.begin(2, 3); // clockpin, datapin + TM.displayFloat(1.42425); delay(2000); TM.displayFloat(-1.42425); diff --git a/libraries/TM1637_RT/examples/TM1637_int/TM1637_int.ino b/libraries/TM1637_RT/examples/TM1637_int/TM1637_int.ino index 0df6ac39..6ac78130 100644 --- a/libraries/TM1637_RT/examples/TM1637_int/TM1637_int.ino +++ b/libraries/TM1637_RT/examples/TM1637_int/TM1637_int.ino @@ -2,7 +2,6 @@ // FILE: TM1637_int.ino // AUTHOR: Rob Tillaart // PURPOSE: demo TM1637 library -// DATE: 2021-02-15 // URL: https://github.com/RobTillaart/TM1637 @@ -20,8 +19,8 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.init(2, 3); - + TM.begin(2, 3); // clockpin, datapin + TM.displayClear(); delay(1000); diff --git a/libraries/TM1637_RT/examples/TM1637_keyscan_cooked/TM1637_keyscan_cooked.ino b/libraries/TM1637_RT/examples/TM1637_keyscan_cooked/TM1637_keyscan_cooked.ino index 311c08d7..ec260c04 100644 --- a/libraries/TM1637_RT/examples/TM1637_keyscan_cooked/TM1637_keyscan_cooked.ino +++ b/libraries/TM1637_RT/examples/TM1637_keyscan_cooked/TM1637_keyscan_cooked.ino @@ -36,8 +36,8 @@ void setup() Serial.println(__TIME__); Serial.println(__FILE__); - // TM.init(2, 3); - TM.init(dispCLOCK, dispDATA); + TM.begin(dispCLOCK, dispDATA); + TM.setBrightness(1); TM.displayClear(); bptr = 0; diff --git a/libraries/TM1637_RT/examples/TM1637_keyscan_raw/TM1637_keyscan_raw.ino b/libraries/TM1637_RT/examples/TM1637_keyscan_raw/TM1637_keyscan_raw.ino index 6892184e..a46e410d 100644 --- a/libraries/TM1637_RT/examples/TM1637_keyscan_raw/TM1637_keyscan_raw.ino +++ b/libraries/TM1637_RT/examples/TM1637_keyscan_raw/TM1637_keyscan_raw.ino @@ -40,7 +40,8 @@ void setup() Serial.println(__TIME__); Serial.println(__FILE__); - TM.init(dispCLOCK, dispDATA); + TM.begin(dispCLOCK, dispDATA); + #ifdef TRIGGER pinMode(TRIGGER, OUTPUT); digitalWrite(TRIGGER, LOW); @@ -68,8 +69,8 @@ char button_poll(void) { void loop() { -char c; - c = button_poll(); + button_poll(); + #ifndef TRIGGER // for oscilloscope testing, don't delay for faster repetition rate delay(50); diff --git a/libraries/TM1637_RT/keywords.txt b/libraries/TM1637_RT/keywords.txt index 44b97da6..ef130973 100644 --- a/libraries/TM1637_RT/keywords.txt +++ b/libraries/TM1637_RT/keywords.txt @@ -6,7 +6,8 @@ TM1637 KEYWORD1 # Methods and Functions (KEYWORD2) -init KEYWORD2 +begin KEYWORD2 + displayRaw KEYWORD2 displayInt KEYWORD2 diff --git a/libraries/TM1637_RT/library.json b/libraries/TM1637_RT/library.json index 0f3f3f99..3167419a 100644 --- a/libraries/TM1637_RT/library.json +++ b/libraries/TM1637_RT/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/TM1637_RT" }, - "version": "0.3.2", + "version": "0.3.3", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/libraries/TM1637_RT/library.properties b/libraries/TM1637_RT/library.properties index 206f8e89..0713539d 100644 --- a/libraries/TM1637_RT/library.properties +++ b/libraries/TM1637_RT/library.properties @@ -1,5 +1,5 @@ name=TM1637_RT -version=0.3.2 +version=0.3.3 author=Rob Tillaart maintainer=Rob Tillaart sentence=TM1637 Library for Arduino.