-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
78 lines (64 loc) · 2.76 KB
/
examples.py
File metadata and controls
78 lines (64 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import time
from tm1637i2c import TM1637I2C
dev = TM1637I2C("/dev/i2c-0")
print('inited.')
time.sleep(2)
dev.brightness(TM1637I2C.BRIGHTNESS_LEVEL_4)
print('brightness level to 4.')
time.sleep(2)
dev.display(TM1637I2C.DIGIT_0,TM1637I2C.DIGIT_3,TM1637I2C.DIGIT_5,TM1637I2C.DIGIT_9)
print('display [0359].')
time.sleep(2)
dev.display(TM1637I2C.DIGIT_0,TM1637I2C.DIGIT_3|TM1637I2C.SEGMENT_DECIMAL_POINT,TM1637I2C.DIGIT_5,TM1637I2C.DIGIT_9)
print('display [0359] with colon.')
time.sleep(2)
dev.show(1234)
print('show [1234].')
time.sleep(2)
dev.show(1234,colon=True)
print('show [1234] with colon.')
time.sleep(2)
dev.display(TM1637I2C.DISPLY_BLANK,TM1637I2C.DISPLY_BLANK,TM1637I2C.DISPLY_BLANK,TM1637I2C.DISPLY_BLANK)
print('display blank.')
time.sleep(2)
print('A small animation effect')
'''
--a--
| |
f b
| |
--g--
| |
e c
| |
--d-- (dp)
'''
frames = [
[TM1637I2C.SEGMENT_F|TM1637I2C.SEGMENT_A, TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK],
[TM1637I2C.SEGMENT_A ,TM1637I2C.SEGMENT_A, TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK],
[TM1637I2C.DISPLY_BLANK, TM1637I2C.SEGMENT_A, TM1637I2C.SEGMENT_A, TM1637I2C.DISPLY_BLANK],
[TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK, TM1637I2C.SEGMENT_A, TM1637I2C.SEGMENT_A],
[TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK, TM1637I2C.SEGMENT_A|TM1637I2C.SEGMENT_B],
[TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK, TM1637I2C.SEGMENT_B|TM1637I2C.SEGMENT_C],
[TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK, TM1637I2C.SEGMENT_C|TM1637I2C.SEGMENT_D],
[TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK, TM1637I2C.SEGMENT_D, TM1637I2C.SEGMENT_D],
[TM1637I2C.DISPLY_BLANK, TM1637I2C.SEGMENT_D, TM1637I2C.SEGMENT_D, TM1637I2C.DISPLY_BLANK],
[TM1637I2C.SEGMENT_D, TM1637I2C.SEGMENT_D, TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK],
[TM1637I2C.SEGMENT_D|TM1637I2C.SEGMENT_E, TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK,TM1637I2C.DISPLY_BLANK],
[TM1637I2C.SEGMENT_E|TM1637I2C.SEGMENT_F, TM1637I2C.DISPLY_BLANK, TM1637I2C.DISPLY_BLANK,TM1637I2C.DISPLY_BLANK],
]
for i in range(1, 5):
for frame in frames:
dev.display(frame[0], frame[1], frame[2], frame[3])
time.sleep(0.07)
# show 'DONE'
dev.display(
TM1637I2C.SEGMENT_B|TM1637I2C.SEGMENT_C|TM1637I2C.SEGMENT_D|TM1637I2C.SEGMENT_E|TM1637I2C.SEGMENT_G, # d
TM1637I2C.SEGMENT_E|TM1637I2C.SEGMENT_D|TM1637I2C.SEGMENT_C|TM1637I2C.SEGMENT_G, # o
TM1637I2C.SEGMENT_E|TM1637I2C.SEGMENT_G|TM1637I2C.SEGMENT_C, # n
TM1637I2C.SEGMENT_A|TM1637I2C.SEGMENT_F|TM1637I2C.SEGMENT_G|TM1637I2C.SEGMENT_E|TM1637I2C.SEGMENT_D, # E
)
time.sleep(0.07)
dev.brightness(TM1637I2C.BRIGHTNESS_LEVEL_2)
print('all done.')
dev.close()