@@ -14,29 +14,55 @@ Library for TM1637 driven displays and keyscans.
1414
1515The TM1637 drives 7 segment displays and can also scan a 16 key keyboard.
1616
17- Library is tested with Arduino UNO and a 6 digits display.
17+ Library is tested with Arduino UNO and a 6 digits display and 4 digit (clock) display .
1818
1919ESP32 is supported since 0.2.0 see https://github.com/RobTillaart/TM1637_RT/pull/5
2020
2121
2222## Interface
2323
24+ ``` cpp
25+ #include " TM1637.h"
26+ ```
27+
28+ #### Core
29+
2430- ** TM1637()** constructor
25- - ** void begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)** set up the connection of the pins to the display.
26- As the display is only tested with a 6 digit display, this is used as the default of the digits parameter.
27- - ** void displayPChar(char \* buff)** display the buffer. Experimental - Tested on STM32 and Arduino Nano
31+ - ** void begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)**
32+ set up the connection of the pins to the display.
33+ As the display is only tested with a 6 digit display,
34+ this is used as the default of the digits parameter.
35+
36+ #### Display functions
37+
38+ - ** void displayPChar(char \* buff)** display the buffer.
39+ Experimental - Tested on STM32 and Arduino Nano
2840- ** void displayRaw(uint8_t \* data, uint8_t pointPos)** low level write function.
2941- ** void displayInt(long value)** idem
30- - ** void displayFloat(float value)** idem
42+ - ** void displayFloat(float value)** idem, position of point may vary!
3143- ** void displayFloat(float value, uint8_t fixedPoint)** display float with fixed point position.
3244- ** void displayHex(uint32_t value)** idem
3345- ** void displayClear()** writes spaces to all positions, effectively clearing the display.
46+ - ** void displayTime(uint8_t hh, uint8_t mm, bool colon)** displays time format.
47+ The function does not check for overflow e.g. hh > 59 or mm > 59.
48+ Works only on 4 digit display.
49+ - hours + minutes HH: MM
50+ - minutes + seconds MM: SS
51+ - can also be used for temperature + humidity TT: HH or any pair of ints side by side.
52+
53+ #### Brightness
54+
3455- ** void setBrightness(uint8_t b)** brightness = 0 .. 7 default = 3.
3556- ** uint8_t getBrightness()** returns value set.
57+
58+ #### KeyScan
59+
3660- ** uint8_t keyscan(void)** scans the keyboard once and return result.
3761The keyscan() function cannot detect multiple keys.
3862
3963
64+ #### DisplayRaw explained
65+
4066** displayRaw()** can display multiple decimal points, by setting the high bit (0x80)
4167in each character for which you wish to have a decimal lit.
4268Or you can use the pointPos argument to light just one decimal at that position.
@@ -47,7 +73,10 @@ Or you can use the pointPos argument to light just one decimal at that position.
4773 - a-f are coded as 0x0a-0x0f
4874 - g-z are coded as 0x12-0x25. Characters that cannot be represented in 7 segments render as blank.
4975So "hello " is coded as 0x13, 0x0e, 0x17, 0x17, 0x1a, 0x10
50-
76+
77+
78+ #### displayPChar explained
79+
5180** void displayPChar(char \* buff)** Attempts to display every ASCII character 0x30 to 0x5F.
5281See example TM1637_custom.ino to insert your own 7 segment patterns.
5382Also displayed are ' ' , '.' and '-' . Decimal points may also be displayed by setting the character sign bit.
@@ -63,7 +92,7 @@ Routine **button_poll()** in the same example shows one way of polling and de-bo
6392- ** void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)** replaced by begin().
6493
6594
66- ### Display support
95+ #### Display support
6796
6897The library is tested with a 6 (=2x3) digit - decimal point - display and a 4 (=1x4) digit - clock - display.
6998At low level these displays differ in the order the digits have to be clocked in.
@@ -75,25 +104,26 @@ If you have a (7 segment) display that is not supported by the library,
75104please open an issue on GitHub so it can be build in.
76105
77106
78- ### Tuning function
107+ #### Tuning function
79108
80- To tune the timing of writing bytes.
109+ To tune the timing of writing bytes.
110+ An UNO can gain ~ 100 micros per call by setting it to 0.
81111
82- - ** void setBitDelay(uint8_t bitDelay = 10)**
112+ - ** void setBitDelay(uint8_t bitDelay = 10)**
83113- ** uint8_t getBitDelay()**
84114
85115
86- ### Tuning minimum pulse length
116+ #### Tuning minimum pulse length
87117
88118The class has a conditional code part in writeSync to guarantee the length of pulses
89119when the library is used with an ESP32. The function called there ** nanoDelay(n)**
90120needs manual adjustment depending upon processor frequency and time needed for a digitalWrite.
91121Feel free to file an issue to get your processor supported.
92122
93- ### Keyboard Scanner usage and notes
94123
124+ ## Keyboard Scanner usage and notes
95125
96- Calling keyscan() returns a uint8_t, whose value is 0xff if no keys are being pressed at the time.
126+ Calling ** keyscan()** returns a uint8_t, whose value is 0xff if no keys are being pressed at the time.
97127The TM1637 can only see one key press at a time, and there is no "rollover".
98128If a key is pressed, then the values are as follows:
99129
@@ -168,18 +198,22 @@ See examples
168198
169199#### Must
170200
171- - remove obsolete ** init()** from code (0.4.0)
201+ - (0.4.0)
202+ - remove obsolete ** init()** from code
203+ - ** setLeadingZeros(bool on = false)** leading zeros flag, set data array to 0.
204+ - ** getLeadingZeros()**
205+
172206
173207#### Should
174208
175209- investigate if code can be optimized
176210 - performance measurement
177211- testing other platforms.
178212- move code from .h to .cpp
179- - ** setLeadingZeros(bool on = false )** leading zeros flag
180- - getter.
181- - set data array to 0.
182- - 0.4.0
213+ - add ** void displayTwoInt(uint8_t x, uint8_t y, bool colon )**
214+ - should work for 4 and 6 digit displays
215+ - refactor readme.md
216+
183217
184218#### Could
185219
0 commit comments