]>
git.gir.st - RaspiRouter.git/blob - usr/bin/dispprogress
4 import RPi
.GPIO
as GPIO
5 GPIO
.setwarnings(False)
7 # Zuordnung der GPIO Pins (ggf. anpassen)
15 DISPLAY_WIDTH
= 16 # Zeichen je Zeile
16 DISPLAY_LINE_1
= 0x80 # Adresse der ersten Display Zeile
25 GPIO
.setmode(GPIO
.BCM
)
26 GPIO
.setup(DISPLAY_E
, GPIO
.OUT
)
27 GPIO
.setup(DISPLAY_RS
, GPIO
.OUT
)
28 GPIO
.setup(DISPLAY_DATA4
, GPIO
.OUT
)
29 GPIO
.setup(DISPLAY_DATA5
, GPIO
.OUT
)
30 GPIO
.setup(DISPLAY_DATA6
, GPIO
.OUT
)
31 GPIO
.setup(DISPLAY_DATA7
, GPIO
.OUT
)
35 #lcd_byte(DISPLAY_LINE_1, DISPLAY_CMD)
36 #lcd_string("Luftinte")
37 #lcd_byte(DISPLAY_LINE_2, DISPLAY_CMD)
40 lcd_byte(0x0e, DISPLAY_CMD
)#enable cursor
41 lcd_byte(0x02, DISPLAY_CMD
)#put cursor to the left
42 lcd_byte(DISPLAY_LINE_1
- 1, DISPLAY_CMD
)
43 for i
in range (0, 8):
44 lcd_byte (0x14, DISPLAY_CMD
)#advance cursor
46 lcd_byte(DISPLAY_LINE_2
- 1, DISPLAY_CMD
)
48 lcd_byte(0x14, DISPLAY_CMD
)
51 lcd_byte(0x0f, DISPLAY_CMD
) #cursor blinky (als lade-anim)
52 lcd_byte (33, DISPLAY_CMD
)
54 #if len (sys.argv) > 1:
55 # mystring = sys.argv[1].ljust (8, " ")
56 # lcd_byte (DISPLAY_LINE_1, DISPLAY_CMD)
57 # lcd_string (mystring[0:8])
58 # lcd_byte (DISPLAY_LINE_2, DISPLAY_CMD)
59 # lcd_string (mystring[8:16])
63 lcd_byte(0x33,DISPLAY_CMD
)
64 lcd_byte(0x32,DISPLAY_CMD
)
65 lcd_byte(0x28,DISPLAY_CMD
)
66 #lcd_byte(0x0C,DISPLAY_CMD) #cursor off
67 lcd_byte(0x06,DISPLAY_CMD
)
68 #lcd_byte(0x01,DISPLAY_CMD) #clear
70 def lcd_string(message
):
71 message
= message
.ljust(DISPLAY_WIDTH
," ")
72 for i
in range(DISPLAY_WIDTH
):
73 lcd_byte(ord(message
[i
]),DISPLAY_CHR
)
75 def lcd_byte(bits
, mode
):
76 GPIO
.output(DISPLAY_RS
, mode
)
77 GPIO
.output(DISPLAY_DATA4
, False)
78 GPIO
.output(DISPLAY_DATA5
, False)
79 GPIO
.output(DISPLAY_DATA6
, False)
80 GPIO
.output(DISPLAY_DATA7
, False)
82 GPIO
.output(DISPLAY_DATA4
, True)
84 GPIO
.output(DISPLAY_DATA5
, True)
86 GPIO
.output(DISPLAY_DATA6
, True)
88 GPIO
.output(DISPLAY_DATA7
, True)
90 GPIO
.output(DISPLAY_E
, True)
92 GPIO
.output(DISPLAY_E
, False)
94 GPIO
.output(DISPLAY_DATA4
, False)
95 GPIO
.output(DISPLAY_DATA5
, False)
96 GPIO
.output(DISPLAY_DATA6
, False)
97 GPIO
.output(DISPLAY_DATA7
, False)
99 GPIO
.output(DISPLAY_DATA4
, True)
101 GPIO
.output(DISPLAY_DATA5
, True)
103 GPIO
.output(DISPLAY_DATA6
, True)
105 GPIO
.output(DISPLAY_DATA7
, True)
107 GPIO
.output(DISPLAY_E
, True)
109 GPIO
.output(DISPLAY_E
, False)
112 if __name__
== '__main__':