-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_20x4.py
73 lines (59 loc) · 2.42 KB
/
display_20x4.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
#!/usr/bin/python3
# Created By Julian Bruegger
# 29.03.2020
# Questions please contact jul.bruegger(at)gmail.com
# To change country edit ./module/corona.py
from module.i2c import *
import requests
import time
import math
import sys
import json
while True:
url = "http://transport.opendata.ch/v1/stationboard?station=lucerne&limit=1"
response = requests.get(url)
data = response.text
parsed = json.loads(data)
station = str(parsed.get("station").get("name"))
destination = str(parsed.get("stationboard")[0].get("to"))
delay = str(parsed.get("stationboard")[0].get("stop").get("delay"))
name = str(parsed.get("stationboard")[0].get("name"))
number = str(parsed.get("stationboard")[0].get("number"))
category = str(parsed.get("stationboard")[0].get("category"))
departure =str(parsed.get("stationboard")[0].get("stop").get("departure"))
departure_time = departure[-13:16]
if delay == 'None':
if category == 'RE':
lcd_init()
time.sleep(1)
lcd_string((station)+(" nach ")+(destination),LCD_LINE_1)
lcd_string((number),LCD_LINE_2)
lcd_string("Departure:",LCD_LINE_3)
lcd_string(departure_time,LCD_LINE_4)
print(station, number, destination, departure_time)
else:
lcd_init()
time.sleep(1)
lcd_string((station)+(" nach ")+(destination),LCD_LINE_1)
lcd_string(category+number,LCD_LINE_2)
lcd_string("Departure:",LCD_LINE_3)
lcd_string(departure_time,LCD_LINE_4)
print(station, (category+number), destination, departure_time)
else :
if category == 'RE':
lcd_init()
time.sleep(1)
lcd_string((station)+(" nach ")+(destination),LCD_LINE_1)
lcd_string(number,LCD_LINE_2)
lcd_string("Departure:",LCD_LINE_3)
lcd_string((departure_time)+(" Exp: +")+(delay),LCD_LINE_4)
print(station, (number), destination, departure_time, delay)
else:
print(station, (category+number), destination, departure_time, delay)
lcd_init()
time.sleep(1)
lcd_string((station)+(" nach ")+(destination),LCD_LINE_1)
lcd_string(category+number,LCD_LINE_2)
lcd_string("Departure:",LCD_LINE_3)
lcd_string((departure_time)+(" Exp: +")+(delay),LCD_LINE_4)
time.sleep(30)