-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLEDBlockDisplay.py
82 lines (75 loc) · 2.49 KB
/
LEDBlockDisplay.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
#!/usr/bin/python
import time
from LED.LEDProcessor import LEDBlock
import json
from gpio_96boards import GPIO
LED_SCROLL_PAUSE = 0.5
def led_print_text(text):
string = text.upper()
try:
for i in range(0, len(string)):
led.printLetter(string[i], False, 1)
time.sleep(LED_SCROLL_PAUSE)
finally:
led.clearDisplays()
led.cleanup()
def led_print_numbers(numbers):
numbers = str(numbers)
try:
for i in range(0, len(numbers)):
led.printNumber(numbers[i], False, 1)
time.sleep(LED_SCROLL_PAUSE)
finally:
led.clearDisplays()
led.cleanup()
if __name__ == '__main__':
global DIN
global CS
global CLK
DIN = GPIO.gpio_id('GPIO-E')
CS = GPIO.gpio_id('GPIO-D')
CLK = GPIO.gpio_id('GPIO-C')
global pins
print DIN
pins = (
(DIN, 'out'),
(CS, 'out'),
(CLK, 'out')
)
with GPIO(pins) as gpio:
numOfDevices = 2
led = LEDBlock(gpio, numOfDevices, 'GPIO-E', 'GPIO-D', 'GPIO-C')
while 1 is 1:
with open('sensordata.json', 'r') as datafile:
sensordata = json.load(datafile)
print(str(sensordata['t']) + ' ' + str(sensordata['h']))
led.printLetter('T', False, 2)
led.printLetter('T', False, 1)
time.sleep(1)
print_arr = str(round(sensordata['t'])).split('.')
led.printNumber(print_arr[0][0], 1)
led.printNumber(print_arr[0][1], 2)
time.sleep(1)
# for i in print_arr[0]:
# led.printNumber(i, 1)
# time.sleep(1)
# led.printDice(1, 1)
# time.sleep(1)
# for i in print_arr[1]:
# led.printNumber(i, 1)
# time.sleep(1)
led.printLetter('H', False, 2)
led.printLetter('H', False, 1)
time.sleep(1)
print_arr = str(round(sensordata['h'])).split('.')
led.printNumber(print_arr[0][0], 1)
led.printNumber(print_arr[0][1], 2)
time.sleep(1)
# for i in print_arr[0]:
# led.printNumber(i, 1)
# time.sleep(1)
# led.printDice(1, 1)
# time.sleep(1)
# for i in print_arr[1]:
# led.printNumber(i, 1)
# time.sleep(1)