Skip to content

Commit

Permalink
update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Nov 22, 2023
1 parent 630d7b6 commit dafc549
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 45 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand All @@ -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

Expand Down
106 changes: 77 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -231,31 +240,60 @@ If a key is pressed, then the values are as follows:
</TR>
</TABLE>
</CENTER>
<P>
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.
</P>
<P>
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.
</P>
<P>
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.
</P>
The unmodified generic TM1637 board (front and back).</br>


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).

<IMG src="images/unmodified.jpg">
</br>
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.</br>


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.

<IMG src="images/modified.jpg">
</br>
The 4 button keyboard plugged into the TM1637 board.</br>
<IMG src="images/disp_plus_kbd.jpg"></br>
</br>
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.</br>
<IMG src="images/slow_rise.jpg"></br>
</br>
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.</br>
<IMG src="images/fast_rise.jpg"></br>

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.

<IMG src="images/disp_plus_kbd.jpg">


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.

<IMG src="images/slow_rise.jpg">


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.

<IMG src="images/fast_rise.jpg">

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
Expand Down Expand Up @@ -286,7 +324,6 @@ See examples
- **setLeadingZeros(bool on = false)** leading zeros flag, set data array to 0.
- **getLeadingZeros()**


#### Should

- testing other platforms.
Expand All @@ -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)

Expand All @@ -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,

12 changes: 6 additions & 6 deletions TM1637.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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, ' ', '-', '°'
};


Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
16 changes: 11 additions & 5 deletions TM1637.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
// 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()


#include "Arduino.h"

#define TM1637_LIB_VERSION (F("0.3.8"))
#define TM1637_LIB_VERSION (F("0.3.9"))


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


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

Expand Down
4 changes: 2 additions & 2 deletions 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/TM1637_RT"
},
"version": "0.3.8",
"version": "0.3.9",
"license": "MIT",
"frameworks": "arduino",
"frameworks": "*",
"platforms": "*",
"headers": "TM1637.h"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TM1637_RT
version=0.3.8
version=0.3.9
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=TM1637 Library for Arduino.
Expand Down

0 comments on commit dafc549

Please sign in to comment.