diff --git a/CHANGELOG.md b/CHANGELOG.md index 180de92..63e675f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.3.9] - 2023-11-22 +- update readme.md + - incl badges to platformIO + + ## [0.3.8] - 2023-07-15 - fix #27 - replaced function data\[8] with a class level data\[8]. @@ -17,12 +22,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - fix bug in **displayRaw()** (add bool hasPoint). - update readme.md - ## [0.3.7] - 2023-04-17 - move code from .h to .cpp - add **displayTwoInt(int ll, int rr, bool colon = true)** - add **displayCelsius(int temp, bool colon = false)** -- add '°' degree character (18) +- add '°' degree character (18) - add examples - update readme.md diff --git a/README.md b/README.md index 6e4bbfe..9e94093 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ -[![Arduino CI](https://github.com/robtillaart/TM1637_RT/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) + +[![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 issues](https://img.shields.io/github/issues/RobTillaart/TM1637_RT.svg)](https://github.com/RobTillaart/TM1637_RT/issues) + [![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) +[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/TM1637_RT.svg)](https://registry.platformio.org/libraries/robtillaart/TM1637_RT) # TM1637 @@ -24,6 +28,8 @@ ESP32 is supported since 0.2.0 see https://github.com/RobTillaart/TM1637_RT/pull - https://docs.wokwi.com/parts/wokwi-tm1637-7segment#simulator-examples + + ## Interface ```cpp @@ -79,12 +85,12 @@ Applications include: - feet + inches FF:II - any pair of integers (-9 .. 99) side by side. - **void displayCelsius(int temp, bool colon = false)** print temperature in **Celsius** format. -The function allows a range from -9 .. 99 + °C. +The function allows a range from -9 .. 99 + °C. The colon is default false. Works only on a 4 digit display. Colon can be used e.g. to indicate under- or overflow, or any other threshold. - **void displayFahrenheit(int temp, bool colon = false)** print temperature in **Fahrenheit** format. -The function allows a range from -9 .. 99 + °F. +The function allows a range from -9 .. 99 + °F. The colon is default false. Works only on a 4 digit display. Colon can be used e.g. to indicate under- or overflow, or any other threshold. @@ -206,6 +212,9 @@ Feel free to file an issue to get your processor supported. ## Keyboard Scanner usage and notes +- Kudos to wfdudley for this section - See #11 +- + Calling **keyscan()** returns a uint8_t, whose value is 0xff if no keys are being pressed at the time. The TM1637 can only see one key press at a time, and there is no "rollover". If a key is pressed, then the values are as follows: @@ -231,31 +240,60 @@ If a key is pressed, then the values are as follows: -
-To modify a "generic" TM1637 board for use with a keyboard, you must add connections to either or both of pins 19 and 20 (these are the "row" selects) and then to as many of pins 2 through 9 (the "columns") as needed. It is easiest to connect to the "column pins" (2-9) by picking them up where they connect to the LED displays (see second photo). Generic keyboards that are a 4x4 matrix won't work; the TM1637 can only scan a 2x8 matrix. Of course, fewer keys are acceptable; I use a 1x4 keyboard in my projects. -
--Further, the TM1637 chip needs a fairly hefty pull-up on the DIO pin for the keyscan() routine to work. There is no pull-up in the TM1637 itself, and the clone boards don't seem to have one either, despite the data sheet calling for 10K ohms pull-ups on DIO and CLOCK. 10K is too weak anyway. The slow rise-time of the DIO signal means that the "true/high" value isn't reached fast enough and reliably enough for the processor to read it correctly. The new pull-up reduces the rise time of the signal, so that true/high values are achieved in a few microseconds. I find that a 1K (1000) ohm resistor from DIO to 3.3 v works well. This is perfect with a 3.3 volt processor like the ESP8266 or ESP32, and a 5V Atmega 328 ("Arduino UNO") family processor is happy with that as well. -
--The TM1637 boards want to be run off of 5 volts, regardless of what the processor voltage is. Their logic levels are compatible with 3.3 volt processors, and they need 5 volts to make sure the LEDs light up. -
-The unmodified generic TM1637 board (front and back). + + +To modify a "generic" TM1637 board for use with a keyboard, you must add connections to either +or both of pins 19 and 20 (these are the "row" selects) and then to as many of pins 2 through 9 +(the "columns") as needed. It is easiest to connect to the "column pins" (2-9) by picking them +up where they connect to the LED displays (see second photo). +Generic keyboards that are a 4x4 matrix won't work; the TM1637 can only scan a 2x8 matrix. +Of course, fewer keys are acceptable; I use a 1x4 keyboard in my projects. + +Further, the TM1637 chip needs a fairly hefty pull-up on the DIO pin for the keyscan() routine to work. +There is no pull-up in the TM1637 itself, and the clone boards don't seem to have one either, +despite the data sheet calling for 10K ohms pull-ups on DIO and CLOCK. 10K is too weak anyway. +The slow rise-time of the DIO signal means that the "true/high" value isn't reached fast enough and +reliably enough for the processor to read it correctly. The new pull-up reduces the rise time of the signal, +so that true/high values are achieved in a few microseconds. +I find that a 1K (1000) ohm resistor from DIO to 3.3 v works well. This is perfect with a 3.3 volt processor +like the ESP8266 or ESP32, and a 5V Atmega 328 ("Arduino UNO") family processor is happy with that as well. + +The TM1637 boards want to be run off of 5 volts, regardless of what the processor voltage is. +Their logic levels are compatible with 3.3 volt processors, and they need 5 volts to make sure the LEDs light up. + + +The unmodified generic TM1637 board (front and back). + - -The modified generic TM1637 board with connector for 1x4 keyboard. The blue wire is bringing out pin 19 (k1). Four segments/columns are picked up from the LEDs. + + +The modified generic TM1637 board with connector for 1x4 keyboard. +The blue wire is bringing out pin 19 (k1). +Four segments/columns are picked up from the LEDs. + - -The 4 button keyboard plugged into the TM1637 board. - - -Scope photo showing slow rise time of DIO pin (upper trace) on the unmodified TM1637. The lower trace is the CLK. The 8 fast CLK pulses on the left represent the 0x42 command to read keyboard being sent to the TM1637. - - -Scope photo showing faster rise time of DIO pin (upper trace) with 1000 ohm pull-up on DIO. In both scope photos, the F5 key is pressed; the bits are least significant bit (LSB) first, so read as 10101111 left to right. - -The scope photos were taken using the TM1637_keyscan_raw example, with the scope trigger hooked to the TRIGGER pin, and the two channel probes hooked to DIO and CLK. Vertical sensitivity is 2v/division, horizontal timebase is 20usec/division. +The 4 button keyboard plugged into the TM1637 board. + + + + +Scope photo showing slow rise time of DIO pin (upper trace) on the unmodified TM1637. +The lower trace is the CLK. The 8 fast CLK pulses on the left represent the 0x42 command +to read keyboard being sent to the TM1637. + + + + +Scope photo showing faster rise time of DIO pin (upper trace) with 1000 ohm pull-up on DIO. +In both scope photos, the F5 key is pressed; the bits are least significant bit (LSB) first, +so read as 10101111 left to right. + + + +The scope photos were taken using the TM1637_keyscan_raw example, with the scope trigger +hooked to the TRIGGER pin, and the two channel probes hooked to DIO and CLK. +Vertical sensitivity is 2v/division, horizontal timebase is 20usec/division. ## Keyscan @@ -286,7 +324,6 @@ See examples - **setLeadingZeros(bool on = false)** leading zeros flag, set data array to 0. - **getLeadingZeros()** - #### Should - testing other platforms. @@ -296,19 +333,22 @@ See examples - **displayFahrenheit()** idem. - could be optional when needed e.g. below -9 or above 99 - #### Could - **keyScan()** camelCase ? - add parameter for **hideSegement(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``` - return bytes written as return value for display functions. + - like print(); or write(); - **void displayHumidity(int hum, bool colon = false)** print humidity in **percent** format. The function allows a range from 0.00H .. 99.9H or 00.0H ? Colon to indicate rising / falling ???? - generic function that displays three digits and one char ACDEFH ??? - - common for celsius and fahrenheit and humidity? + - common for Celsius and Fahrenheit and Humidity? +- **void displayAmpere(float amps)** Ampere 0.00 - 999 A + #### Wont (unless requested) @@ -328,8 +368,16 @@ Colon to indicate rising / falling ???? - is now commented code, good enough + dumpcache() - extend some functions to 6 digit display too? - time(hh.mm.ss) - - Celsius (nn.nn°C) + - Celsius (nn.nn°C) - twoInt => threeInt - on request only +## 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. + +Thank you, + diff --git a/TM1637.cpp b/TM1637.cpp index b734097..cc82109 100644 --- a/TM1637.cpp +++ b/TM1637.cpp @@ -2,7 +2,7 @@ // FILE: TM1637.cpp // AUTHOR: Rob Tillaart // DATE: 2019-10-28 -// VERSION: 0.3.8 +// VERSION: 0.3.9 // PURPOSE: TM1637 library for Arduino // URL: https://github.com/RobTillaart/TM1637_RT @@ -54,7 +54,7 @@ static uint8_t seg[] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, // 0 - 9 - 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x00, 0x40, 0x63 // A - F, ' ', '-', '°' + 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x00, 0x40, 0x63 // A - F, ' ', '-', '°' }; @@ -99,7 +99,7 @@ void TM1637::begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits) { setDigitOrder(3, 2, 1, 0); } - else // (_digits == 6 ) // default + else // (_digits == 6 ) // default { setDigitOrder(3, 4, 5, 0, 1, 2); } @@ -181,7 +181,7 @@ void TM1637::displayFloat(float value, uint8_t fixedPoint) last--; } // v += 0.0001; // Bug fix for 12.999 <> 13.000 - v += 0.001; // Bug fix for 12.99 <> 13.00 + v += 0.001; // Bug fix for 12.99 <> 13.00 while (v >= 10) { @@ -276,7 +276,7 @@ void TM1637::displayCelsius(int temp, bool colon) if (_digits != 4) return; for (int i = 0; i < 8; i++) _data[i] = TM1637_SPACE; // 16 _data[0] = 12; // C - _data[1] = TM1637_DEGREE; // ° degreee sign + _data[1] = TM1637_DEGREE; // ° degreee sign if (temp < -9) temp = -9; if (temp > 99) temp = 99; @@ -299,7 +299,7 @@ void TM1637::displayFahrenheit(int temp, bool colon) if (_digits != 4) return; for (int i = 0; i < 8; i++) _data[i] = TM1637_SPACE; // 16 _data[0] = 15; // F - _data[1] = TM1637_DEGREE; // ° degreee sign + _data[1] = TM1637_DEGREE; // ° degreee sign if (temp < -9) temp = -9; if (temp > 99) temp = 99; diff --git a/TM1637.h b/TM1637.h index c992885..7a97cda 100644 --- a/TM1637.h +++ b/TM1637.h @@ -3,10 +3,16 @@ // FILE: TM1637.h // AUTHOR: Rob Tillaart // DATE: 2019-10-28 -// VERSION: 0.3.8 +// VERSION: 0.3.9 // PUPROSE: TM1637 library for Arduino // URL: https://github.com/RobTillaart/TM1637_RT +// NOTE: +// on the inexpensive TM1637 boards @wfdudley has used, keyscan +// works if you add a 1000 ohm pull-up resistor from DIO to 3.3v +// This reduces the rise time of the DIO signal when reading the key info. +// If one only uses the pull-up inside the microcontroller, +// the rise time is too long for the data to be read reliably. // tested on 6 digit display // tested on 4 digit (clock) display esp. displayTime() @@ -14,7 +20,7 @@ #include "Arduino.h" -#define TM1637_LIB_VERSION (F("0.3.8")) +#define TM1637_LIB_VERSION (F("0.3.9")) class TM1637 @@ -38,9 +44,9 @@ class TM1637 // next 3 only tested on 4 digit display with colon void displayTime(uint8_t hh, uint8_t mm, bool colon); void displayTwoInt(int ll, int rr, bool colon = true); - // Celsius -9..99°C + // Celsius -9..99°C void displayCelsius(int temp, bool colon = false); - // Fahrenheit -9..99°F + // Fahrenheit -9..99°F void displayFahrenheit(int temp, bool colon = false); @@ -104,7 +110,7 @@ class TM1637 void writeSync(uint8_t pin, uint8_t val); void nanoDelay(uint16_t n); - // Override in your own derived class for custom character translation + // Override in your own derived class for custom character translation virtual uint8_t asciiTo7Segment ( char c ) ; }; diff --git a/library.json b/library.json index a1ff773..9e41ed8 100644 --- a/library.json +++ b/library.json @@ -15,9 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/TM1637_RT" }, - "version": "0.3.8", + "version": "0.3.9", "license": "MIT", - "frameworks": "arduino", + "frameworks": "*", "platforms": "*", "headers": "TM1637.h" } diff --git a/library.properties b/library.properties index 6bed583..46dfe67 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TM1637_RT -version=0.3.8 +version=0.3.9 author=Rob Tillaart