-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScoreRefresh.py
81 lines (71 loc) · 2.03 KB
/
ScoreRefresh.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
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
79
80
81
import RPi.GPIO as GPIO
import time
import sys
# Pin definitions
data = 17
clock = 27
strobe = 22 # PIN 15
enable = 18 # PIN 12 - always high to show data
# Suppress warnings
GPIO.setwarnings(False)
# Use "GPIO" pin numbering
GPIO.setmode(GPIO.BCM)
# Set LED pin as output
GPIO.setup(data, GPIO.OUT)
GPIO.setup(clock, GPIO.OUT)
GPIO.setup(strobe, GPIO.OUT)
GPIO.setup(enable, GPIO.OUT)
def binaryData(idx):
switcher2 = {
'-':'00000000',
'0':'00000000',
'1':'10000000',
'2':'01000000',
'3':'00100000',
'4':'00010000',
'5':'00001000',
'6':'00000100',
'7':'00000010',
'8':'00000001',
'9':'00000000'
}
switcher = {
'-':'00000000',
'0':'01111111',
'1':'00010001',
'2':'10111110',
'3':'10111011',
'4':'11011001',
'5':'11101011',
'6':'11101111',
'7':'00110001',
'8':'11111111',
'9':'11111011'
}
return switcher.get(idx,"Not Found")
scoreStr= sys.argv[1]
#scoreStr='-0123456789-012345678951'
#scoreStr = '-2-44-3-17-1--3--0-3-24'
print(scoreStr)
#scoreStr='55'
#nBits =0
GPIO.output(enable, GPIO.HIGH)
#print(binary)
for iNum in range(len(scoreStr)):
binary=binaryData(scoreStr[iNum])
for iBit in range(len(binary)):
bitVal = binary[iBit]
# nBits = nBits + 1
if bitVal == '1':
GPIO.output(data, GPIO.HIGH) # Turn LED off
GPIO.output(clock, GPIO.HIGH) # Turn LED on
GPIO.output(clock, GPIO.LOW) # Turn LED off
GPIO.output(data, GPIO.LOW) # Turn LED off
else:
GPIO.output(data, GPIO.LOW) # Turn LED off
GPIO.output(clock, GPIO.HIGH) # Turn LED on
GPIO.output(clock, GPIO.LOW) # Turn LED off
GPIO.output(data, GPIO.LOW) # Turn LED off
GPIO.output(strobe, GPIO.HIGH)
GPIO.output(strobe, GPIO.LOW)
print("DONE")