-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpypcd-demo.py
34 lines (32 loc) · 948 Bytes
/
pypcd-demo.py
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from pypcd8544_piandmore import *
if '--demo' in sys.argv:
begin(20)
print "Initialized."
drawLine(0, 0, 40, 40, True)
print "Line Drawn."
display()
setTextColor(True, False)
write('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tem')
display()
sys.exit()
elif '--write' in sys.argv:
print "Initializing..."
try:
contrast = int(sys.argv[sys.argv.index('--write')+1])
except IndexError:
print "Usage: %s --write <contrast>\n(Try using values between 20 and 50)" % sys.argv[0]
sys.exit(1)
print "Using contrast %d" % contrast
begin(contrast, False)
print "Writing"
string = sys.stdin.read()
print "Text: '%s'" % string
setTextColor(True, False)
write(string)
display()
sys.exit(0)
else:
print "Usage:\n %s --write <contrast> Read text from STDIN and write to display\n %s --demo Show a demonstration"