-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLCDInterface.py
More file actions
48 lines (36 loc) · 1.32 KB
/
LCDInterface.py
File metadata and controls
48 lines (36 loc) · 1.32 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
from LCDModule import LCD
import time
def lcd_show_text(lcd, strings, alle_shifts=(0, 0, 0, 0)):
lcd.clear()
newstrings = []
for i in range(4 - len(strings)):
strings.append("")
# Uber jede Zeile
for zeilen_idx in range(4):
aktuelle_zeile = strings[zeilen_idx]
zeilenlaenge = len(aktuelle_zeile)
zeile_shift = alle_shifts[zeilen_idx]
newstring = aktuelle_zeile[zeile_shift : 16+zeile_shift]
newstring = (newstring + " "*(16 - zeilenlaenge))
newstrings.append(newstring)
firstline = "".join([newstrings[0], newstrings[2]])
secondline = "".join([newstrings[1], newstrings[3]])
lcd.message(firstline)
lcd.message("\n")
lcd.message(secondline)
def main():
four_strings = ["Guten Morgen", "Julia", "und Jakov"]
lcd = LCD()
lcd_show_text(lcd, four_strings, (0,0,0,0))
time.sleep(2)
four_strings = ["Guten Morgen ihr sportskanonen",
"Julia mein lieber Schatz",
"und Jakov der programmierer",
"Ich wunsche euch einen tollen Tag !!!"]
lcd_show_text(lcd, four_strings, (0,0,0,0))
time.sleep(2)
for i in range(len(four_strings[3]) - 15):
lcd_show_text(lcd, four_strings, (2,4,2,i))
time.sleep(0.1)
if __name__ == "__main__":
main()