@@ -14,29 +14,55 @@ Library for TM1637 driven displays and keyscans.
14
14
15
15
The TM1637 drives 7 segment displays and can also scan a 16 key keyboard.
16
16
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 .
18
18
19
19
ESP32 is supported since 0.2.0 see https://github.com/RobTillaart/TM1637_RT/pull/5
20
20
21
21
22
22
## Interface
23
23
24
+ ``` cpp
25
+ #include " TM1637.h"
26
+ ```
27
+
28
+ #### Core
29
+
24
30
- ** 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
28
40
- ** void displayRaw(uint8_t \* data, uint8_t pointPos)** low level write function.
29
41
- ** void displayInt(long value)** idem
30
- - ** void displayFloat(float value)** idem
42
+ - ** void displayFloat(float value)** idem, position of point may vary!
31
43
- ** void displayFloat(float value, uint8_t fixedPoint)** display float with fixed point position.
32
44
- ** void displayHex(uint32_t value)** idem
33
45
- ** 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
+
34
55
- ** void setBrightness(uint8_t b)** brightness = 0 .. 7 default = 3.
35
56
- ** uint8_t getBrightness()** returns value set.
57
+
58
+ #### KeyScan
59
+
36
60
- ** uint8_t keyscan(void)** scans the keyboard once and return result.
37
61
The keyscan() function cannot detect multiple keys.
38
62
39
63
64
+ #### DisplayRaw explained
65
+
40
66
** displayRaw()** can display multiple decimal points, by setting the high bit (0x80)
41
67
in each character for which you wish to have a decimal lit.
42
68
Or 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.
47
73
- a-f are coded as 0x0a-0x0f
48
74
- g-z are coded as 0x12-0x25. Characters that cannot be represented in 7 segments render as blank.
49
75
So "hello " is coded as 0x13, 0x0e, 0x17, 0x17, 0x1a, 0x10
50
-
76
+
77
+
78
+ #### displayPChar explained
79
+
51
80
** void displayPChar(char \* buff)** Attempts to display every ASCII character 0x30 to 0x5F.
52
81
See example TM1637_custom.ino to insert your own 7 segment patterns.
53
82
Also 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
63
92
- ** void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)** replaced by begin().
64
93
65
94
66
- ### Display support
95
+ #### Display support
67
96
68
97
The library is tested with a 6 (=2x3) digit - decimal point - display and a 4 (=1x4) digit - clock - display.
69
98
At 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,
75
104
please open an issue on GitHub so it can be build in.
76
105
77
106
78
- ### Tuning function
107
+ #### Tuning function
79
108
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.
81
111
82
- - ** void setBitDelay(uint8_t bitDelay = 10)**
112
+ - ** void setBitDelay(uint8_t bitDelay = 10)**
83
113
- ** uint8_t getBitDelay()**
84
114
85
115
86
- ### Tuning minimum pulse length
116
+ #### Tuning minimum pulse length
87
117
88
118
The class has a conditional code part in writeSync to guarantee the length of pulses
89
119
when the library is used with an ESP32. The function called there ** nanoDelay(n)**
90
120
needs manual adjustment depending upon processor frequency and time needed for a digitalWrite.
91
121
Feel free to file an issue to get your processor supported.
92
122
93
- ### Keyboard Scanner usage and notes
94
123
124
+ ## Keyboard Scanner usage and notes
95
125
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.
97
127
The TM1637 can only see one key press at a time, and there is no "rollover".
98
128
If a key is pressed, then the values are as follows:
99
129
@@ -168,18 +198,22 @@ See examples
168
198
169
199
#### Must
170
200
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
+
172
206
173
207
#### Should
174
208
175
209
- investigate if code can be optimized
176
210
- performance measurement
177
211
- testing other platforms.
178
212
- 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
+
183
217
184
218
#### Could
185
219
0 commit comments