From af8ba8c24e7185055678cfc7d81b900810533e2d Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Sat, 6 Jan 2024 16:57:38 +0100 Subject: [PATCH] remove init() and keyscan() (#32) - remove init() and keyscan() - minor edits --- CHANGELOG.md | 7 ++++++- LICENSE | 2 +- README.md | 12 +++++------- TM1637.cpp | 9 +-------- TM1637.h | 19 +++++-------------- examples/TM1637_HEX/TM1637_HEX.ino | 7 ++++--- examples/TM1637_alpha/TM1637_alpha.ino | 3 +-- .../TM1637_clock_4digits.ino | 4 ++-- examples/TM1637_custom/TM1637_custom.ino | 18 +++++++++++------- .../TM1637_displayCelsius.ino | 2 +- .../TM1637_displayTime/TM1637_displayTime.ino | 2 +- .../TM1637_displayTime2.ino | 6 +++--- .../TM1637_displayTwoInt.ino | 2 +- examples/TM1637_float/TM1637_float.ino | 4 ++-- .../TM1637_float_point/TM1637_float_point.ino | 4 ++-- .../TM1637_hide_segment.ino | 2 +- examples/TM1637_int/TM1637_int.ino | 4 ++-- .../TM1637_keyscan_cooked.ino | 1 - .../TM1637_keyscan_raw/TM1637_keyscan_raw.ino | 1 - examples/TM1637_pchar/TM1637_pchar.ino | 11 ++++++----- library.json | 2 +- library.properties | 2 +- test/unit_test_001.cpp | 6 +++--- 23 files changed, 60 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21e3921..a2a39b8 100644 --- a/CHANGELOG.md +++ b/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.4.0] - 2023-11-22 +- remove init() and keyscan() +- minor edits + +---- + ## [0.3.9] - 2023-11-22 - update readme.md - section about hardware performance (Kudos to SteveMicroCode #29) @@ -16,7 +22,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - patched examples. - minor edits - ## [0.3.8] - 2023-07-15 - fix #27 - replaced function data\[8] with a class level data\[8]. diff --git a/LICENSE b/LICENSE index 1d37494..b653d12 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019-2023 Rob Tillaart +Copyright (c) 2019-2024 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a6f7df7..56e8a13 100644 --- a/README.md +++ b/README.md @@ -356,24 +356,22 @@ See examples #### Must -- (0.4.0) - - remove obsolete **init()** from code - - remove keyscan() => keyScan() - - **setLeadingZeros(bool on = false)** leading zeros flag, set data array to 0. - - **getLeadingZeros()** +- refactor readme.md +- **setLeadingZeros(bool on = false)** leading zeros flag, set data array to 0. +- **getLeadingZeros()** #### Should - testing other platforms. -- refactor readme.md - remove degree sign from **displayCelsius()** - would allow one extra digit. - **displayFahrenheit()** idem. - could be optional when needed e.g. below -9 or above 99 + - code complexity? #### Could -- add parameter for **hideSegement(idx, character == SPACE)** to overrule hide char. +- add parameter for **hideSegment(idx, character == SPACE)** to overrule hide char. - space underscore or - are possible. - add **TM1637_UNDERSCORE** to char set. ```seg[19] == 0x08``` - add **TM1637_UPPERSCORE** to char set. ```seg[20] == 0x01``` diff --git a/TM1637.cpp b/TM1637.cpp index 63cf9a6..0076a16 100644 --- a/TM1637.cpp +++ b/TM1637.cpp @@ -2,7 +2,7 @@ // FILE: TM1637.cpp // AUTHOR: Rob Tillaart // DATE: 2019-10-28 -// VERSION: 0.3.9 +// VERSION: 0.4.0 // PURPOSE: TM1637 library for Arduino // URL: https://github.com/RobTillaart/TM1637_RT @@ -76,13 +76,6 @@ TM1637::TM1637() } -// wrapper, init() 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) { _clockPin = clockPin; diff --git a/TM1637.h b/TM1637.h index 69450db..1645bef 100644 --- a/TM1637.h +++ b/TM1637.h @@ -3,8 +3,8 @@ // FILE: TM1637.h // AUTHOR: Rob Tillaart // DATE: 2019-10-28 -// VERSION: 0.3.9 -// PUPROSE: TM1637 library for Arduino +// VERSION: 0.4.0 +// PURPOSE: TM1637 library for Arduino // URL: https://github.com/RobTillaart/TM1637_RT // NOTE: @@ -20,7 +20,7 @@ #include "Arduino.h" -#define TM1637_LIB_VERSION (F("0.3.9")) +#define TM1637_LIB_VERSION (F("0.4.0")) class TM1637 @@ -28,7 +28,7 @@ class TM1637 public: TM1637(); - // replaces init() + // begin replaces init() void begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6); @@ -87,16 +87,7 @@ class TM1637 void dumpCache(); - // OBSOLETE - // init() => begin() in 0.4.0 - [[deprecated("Use begin() instead")]] - void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6); - // keyscan() => keyScan() in 0.4.0 - [[deprecated("Use keyScan() instead => camelCase!")]] - uint8_t keyscan(void) { return keyScan(); }; - - -private: +protected: uint8_t _clockPin = -1; uint8_t _dataPin = -1; uint8_t _digits = 6; diff --git a/examples/TM1637_HEX/TM1637_HEX.ino b/examples/TM1637_HEX/TM1637_HEX.ino index 4b4f96c..ea6af08 100644 --- a/examples/TM1637_HEX/TM1637_HEX.ino +++ b/examples/TM1637_HEX/TM1637_HEX.ino @@ -3,9 +3,10 @@ // AUTHOR: Rob Tillaart // PURPOSE: demo TM1637 library // URL: https://github.com/RobTillaart/TM1637 - +// // test with 6 digits (decimal) display + #include "TM1637.h" TM1637 TM; @@ -20,7 +21,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(2, 3, 6); // clockpin, datapin, #digits + TM.begin(2, 3, 6); // clock pin, data pin, #digits TM.displayClear(); delay(2000); @@ -43,7 +44,7 @@ void test() start = millis(); for (int i = 0; i < 1000; i++) { - TM.displayHex(val); // there is loop overhead etc + TM.displayHex(val); // there is loop overhead etc. val++; } stop = millis(); diff --git a/examples/TM1637_alpha/TM1637_alpha.ino b/examples/TM1637_alpha/TM1637_alpha.ino index 410945a..a0a6466 100644 --- a/examples/TM1637_alpha/TM1637_alpha.ino +++ b/examples/TM1637_alpha/TM1637_alpha.ino @@ -1,7 +1,6 @@ // // FILE: TM1637_alpha.ino // AUTHOR: William F. Dudley Jr. -// VERSION: 0.1.0 // PURPOSE: demo TM1637 library // DATE: 2021-10-12 // URL: https://github.com/RobTillaart/TM1637 @@ -17,7 +16,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(2, 3); // clockpin, datapin + TM.begin(2, 3); // clockPin, dataPin TM.setBrightness(2); } diff --git a/examples/TM1637_clock_4digits/TM1637_clock_4digits.ino b/examples/TM1637_clock_4digits/TM1637_clock_4digits.ino index 9db55d2..e4ec9e4 100644 --- a/examples/TM1637_clock_4digits/TM1637_clock_4digits.ino +++ b/examples/TM1637_clock_4digits/TM1637_clock_4digits.ino @@ -23,7 +23,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(7, 6, 4); // clockpin, datapin, #digits + TM.begin(7, 6, 4); // clockPin, dataPin, #digits TM.displayClear(); delay(2000); @@ -45,7 +45,7 @@ void setup() delay(2000); } -// mimick clock, not ok under 10 seconds +// mimic clock, not OK under 10 seconds // left as exercise for the programmer ;) void loop() { diff --git a/examples/TM1637_custom/TM1637_custom.ino b/examples/TM1637_custom/TM1637_custom.ino index 43175c1..3ff677e 100644 --- a/examples/TM1637_custom/TM1637_custom.ino +++ b/examples/TM1637_custom/TM1637_custom.ino @@ -1,18 +1,20 @@ // // FILE: TM1637_custom.ino // AUTHOR: Richard Jones -// VERSION: 0.1.0 // PURPOSE: demo TM1637 library // DATE: 3 October 2022 // URL: https://github.com/radionerd +// URL: https://github.com/RobTillaart/TM1637_RT + +// Demonstration of how to display char *buff and override the TM1637 library asciiTo7Segment virtual function +// to create a custom 7 segment character set. +// The letter 'A' becomes swapped with @ in this trivial example +// Status: Experimental. Tested on STM32F103C8T6 Blue Pill and Arduino Nano only -// Demonstration of how to display char *buff and override the TM1637 library asciiTo7Segment virtual function -// to create a custom 7 segment character set. -// The letter 'A' becomes swapped with @ in this trivial example -// Status: Experimental. Tested on STM32F103C8T6 Blue Pill and Arduino Nano only #include "TM1637.h" + const int DISPLAY_DIGITS_6 = 6; // This example shows how to override the TM1637_RT library 7 segment patterns and copy the display output @@ -61,17 +63,19 @@ class myTM1637 : TM1637 { } }; + myTM1637 myTM; + void setup() { Serial.begin(115200); delay(1000); Serial.println(__FILE__); - // set clockpin, datapin to your own board pin names + // set clock pin, data pin to your own board pin names // e.g. myTM.begin(PB8, PB9 , DISPLAY_DIGITS_6 ); - myTM.begin( 14, 15 , DISPLAY_DIGITS_6 ); // clockpin, datapin, and digits + myTM.begin( 14, 15 , DISPLAY_DIGITS_6 ); // clock pin, data pin, and digits myTM.setBrightness(2); diff --git a/examples/TM1637_displayCelsius/TM1637_displayCelsius.ino b/examples/TM1637_displayCelsius/TM1637_displayCelsius.ino index de03e5d..4293a2d 100644 --- a/examples/TM1637_displayCelsius/TM1637_displayCelsius.ino +++ b/examples/TM1637_displayCelsius/TM1637_displayCelsius.ino @@ -16,7 +16,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(7, 6, 4); // clockpin, datapin, #digits + TM.begin(7, 6, 4); // clock pin, data pin, #digits } diff --git a/examples/TM1637_displayTime/TM1637_displayTime.ino b/examples/TM1637_displayTime/TM1637_displayTime.ino index 6ba784b..7096a30 100644 --- a/examples/TM1637_displayTime/TM1637_displayTime.ino +++ b/examples/TM1637_displayTime/TM1637_displayTime.ino @@ -16,7 +16,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(7, 6, 4); // clockpin, datapin, #digits + TM.begin(7, 6, 4); // clock pin, data pin, #digits delay(10); start = micros(); diff --git a/examples/TM1637_displayTime2/TM1637_displayTime2.ino b/examples/TM1637_displayTime2/TM1637_displayTime2.ino index 837ce9d..7c26cef 100644 --- a/examples/TM1637_displayTime2/TM1637_displayTime2.ino +++ b/examples/TM1637_displayTime2/TM1637_displayTime2.ino @@ -16,10 +16,10 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(7, 6, 4); // clockpin, datapin, #digits + TM.begin(7, 6, 4); // clock pin, data pin, #digits - // AVR UNO - // BITDELAY displayTime() + // AVR UNO + // BITDELAY displayTime() // 0 1352 // 2 1364 // 4 1384 diff --git a/examples/TM1637_displayTwoInt/TM1637_displayTwoInt.ino b/examples/TM1637_displayTwoInt/TM1637_displayTwoInt.ino index 29b6c3f..61497af 100644 --- a/examples/TM1637_displayTwoInt/TM1637_displayTwoInt.ino +++ b/examples/TM1637_displayTwoInt/TM1637_displayTwoInt.ino @@ -17,7 +17,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(7, 6, 4); // clockpin, datapin, #digits + TM.begin(7, 6, 4); // clock pin, data pin, #digits } diff --git a/examples/TM1637_float/TM1637_float.ino b/examples/TM1637_float/TM1637_float.ino index 303c760..e3fc589 100644 --- a/examples/TM1637_float/TM1637_float.ino +++ b/examples/TM1637_float/TM1637_float.ino @@ -19,7 +19,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(2, 3); // clockpin, datapin + TM.begin(2, 3); // clock pin, data pin TM.displayFloat(1.42425); // TM.dumpCache(); @@ -47,7 +47,7 @@ void test() start = millis(); for (int i = 0; i < 1000; i++) { - TM.displayFloat(f); // there is loop overhead etc + TM.displayFloat(f); // there is loop overhead etc. f += 1; } stop = millis(); diff --git a/examples/TM1637_float_point/TM1637_float_point.ino b/examples/TM1637_float_point/TM1637_float_point.ino index 6e865d3..13eb8e7 100644 --- a/examples/TM1637_float_point/TM1637_float_point.ino +++ b/examples/TM1637_float_point/TM1637_float_point.ino @@ -19,7 +19,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(2, 3); // clockpin, datapin + TM.begin(2, 3); // clock pin, data pin TM.displayFloat(1.42425); delay(2000); @@ -46,7 +46,7 @@ void test() start = millis(); for (int i = 0; i < 1000; i++) { - TM.displayFloat(f, 2); // there is loop overhead etc + TM.displayFloat(f, 2); // there is loop overhead etc. f += 1; } stop = millis(); diff --git a/examples/TM1637_hide_segment/TM1637_hide_segment.ino b/examples/TM1637_hide_segment/TM1637_hide_segment.ino index fb0c149..26df002 100644 --- a/examples/TM1637_hide_segment/TM1637_hide_segment.ino +++ b/examples/TM1637_hide_segment/TM1637_hide_segment.ino @@ -16,7 +16,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(7, 6, 4); // clockpin, datapin, #digits + TM.begin(7, 6, 4); // clock pin, data pin, #digits delay(10); start = micros(); diff --git a/examples/TM1637_int/TM1637_int.ino b/examples/TM1637_int/TM1637_int.ino index 6195a17..8490f11 100644 --- a/examples/TM1637_int/TM1637_int.ino +++ b/examples/TM1637_int/TM1637_int.ino @@ -19,7 +19,7 @@ void setup() Serial.begin(115200); Serial.println(__FILE__); - TM.begin(2, 3); // clockpin, datapin + TM.begin(2, 3); // clock pin, data pin TM.displayClear(); delay(1000); @@ -45,7 +45,7 @@ void test() start = millis(); for (int i = 0; i < 1000; i++) { - TM.displayInt(val); // there is loop overhead etc + TM.displayInt(val); // there is loop overhead etc. val++; } stop = millis(); diff --git a/examples/TM1637_keyscan_cooked/TM1637_keyscan_cooked.ino b/examples/TM1637_keyscan_cooked/TM1637_keyscan_cooked.ino index 0fc89b7..f486688 100644 --- a/examples/TM1637_keyscan_cooked/TM1637_keyscan_cooked.ino +++ b/examples/TM1637_keyscan_cooked/TM1637_keyscan_cooked.ino @@ -1,7 +1,6 @@ // // FILE: TM1637_keypress_cooked.ino // AUTHOR: William F. Dudley Jr. -// VERSION: 0.1.0 // PURPOSE: demo TM1637 library - keyScan() cooked output // DATE: 2021-10-26 // URL: https://github.com/RobTillaart/TM1637 diff --git a/examples/TM1637_keyscan_raw/TM1637_keyscan_raw.ino b/examples/TM1637_keyscan_raw/TM1637_keyscan_raw.ino index 581a668..54d89d7 100644 --- a/examples/TM1637_keyscan_raw/TM1637_keyscan_raw.ino +++ b/examples/TM1637_keyscan_raw/TM1637_keyscan_raw.ino @@ -1,7 +1,6 @@ // FILE: TM1637_keypress_raw.ino // AUTHOR: William F. Dudley Jr. -// VERSION: 0.1.0 // PURPOSE: demo TM1637 library - keyScan() raw output // DATE: 2021-10-26 // URL: https://github.com/RobTillaart/TM1637 diff --git a/examples/TM1637_pchar/TM1637_pchar.ino b/examples/TM1637_pchar/TM1637_pchar.ino index 3da94ac..4bc9f10 100644 --- a/examples/TM1637_pchar/TM1637_pchar.ino +++ b/examples/TM1637_pchar/TM1637_pchar.ino @@ -1,13 +1,13 @@ // // FILE: TM1637_pchar.ino // AUTHOR: Richard Jones -// VERSION: 0.1.0 // PURPOSE: demo TM1637 library // DATE: 4 October 2022 // URL: https://github.com/radionerd -// Demonstration of how to display char *buff -// Status: Experimental. Tested on STM32F103C8T6 Blue Pill and Arduino Nano only +// Demonstration of how to display char *buff +// Status: Experimental. Tested on STM32F103C8T6 Blue Pill and Arduino Nano only + #include "TM1637.h" @@ -15,15 +15,16 @@ const int DISPLAY_DIGITS_6 = 6; TM1637 TM; + void setup() { Serial.begin(115200); delay(1000); Serial.println(__FILE__); - // set clockpin, datapin to your own board pin names + // set clock pin, data pin to your own board pin names // e.g. myTM.begin(PB8, PB9 , DISPLAY_DIGITS_6 ); - TM.begin( 14, 15 , DISPLAY_DIGITS_6 ); // clockpin, datapin, and digits + TM.begin( 14, 15 , DISPLAY_DIGITS_6 ); // clock pin, data pin, and digits TM.setBrightness(2); diff --git a/library.json b/library.json index 9e41ed8..0463772 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/TM1637_RT" }, - "version": "0.3.9", + "version": "0.4.0", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/library.properties b/library.properties index 46dfe67..563a952 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TM1637_RT -version=0.3.9 +version=0.4.0 author=Rob Tillaart maintainer=Rob Tillaart sentence=TM1637 Library for Arduino. diff --git a/test/unit_test_001.cpp b/test/unit_test_001.cpp index 3a6fec0..ac7aeed 100644 --- a/test/unit_test_001.cpp +++ b/test/unit_test_001.cpp @@ -51,7 +51,7 @@ unittest_teardown() unittest(test_begin) { TM1637 TM; - TM.init(2, 3, 6); + TM.begin(2, 3, 6); TM.displayClear(); // TODO real tests.... @@ -62,7 +62,7 @@ unittest(test_begin) unittest(test_brightness) { TM1637 TM; - TM.init(2, 3, 6); + TM.begin(2, 3, 6); for (uint8_t b = 0; b < 8; b++) { @@ -82,7 +82,7 @@ unittest(test_brightness) unittest(test_set_bit_delay) { TM1637 TM; - TM.init(2, 3, 6); + TM.begin(2, 3, 6); for (uint8_t b = 0; b < 100; b += 10) {