Repository navigation
Expand file tree
/
Copy pathvarinit.py
More file actions
179 lines (158 loc) · 5.68 KB
/
Copy pathvarinit.py
File metadata and controls
179 lines (158 loc) · 5.68 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
from __main__ import display, matrix
import displayio, microcontroller
import os, time, json, functions, ampule, ipaddress, binascii, dicts
import json
import sys
from DSA_2_0.font_large import font_large
from DSA_2_0.font_small import font_small
#from microcontroller import watchdog
#from watchdog import WatchDogMode
# ----------------------------------------------------------------------------------------
#watchdog.timeout = 60
#watchdog.mode = WatchDogMode.RESET
def wd(): pass
deviations_list = []
deviations_timer = time.monotonic()
ad_timer = time.monotonic()
ad_delay = 10
deviations_delay = 1
button_delay = 15000
delay = 0.05
traindata = {}
no_of_screens_flag = 2
timer = ""
temperature_timer = False
temperature_threshold = 89
currenttime = ""
_currenttime = ""
screen_selector = "1"
today = ""
newstation = ""
scrollsum = " "
ap_name = ""
results = ""
city = "Stockholm"
html_cache = ""
datadict = {}
netlist = []
checknet = 0
version_msg = ""
updatedelay = 20
network_delay = 5
active_message = 0
socket_timeout = 50
reset_timer = 0
exit = False
ping_list = []
ping = 0
port = 80
dns = False
currentfont = 0
saving_state = False
settingstxt = dicts.settingstxt
fonts = [font_large, font_small]
custom_font_index = None
try:
with open("/DSA_2_0/custom_font.json") as f:
font_custom = json.load(f)
for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
if c in font_custom:
font_custom[c.lower()] = font_custom[c]
if " " in font_custom:
font_custom["_"] = font_custom[" "]
font_custom["-"] = font_custom[" "]
fonts.append(font_custom)
custom_font_index = len(fonts) - 1
except Exception as e:
print("custom_font not loaded:", e)
station_names_dict = dicts.station_names_dict
first_start = True
on_off_counter = 1
new_version_available = 0
new_ver = 0
starttime = time.monotonic()
uptime = ""
show_station_timer = time.monotonic()
show_station_interval = 400
cpver = 8
settings = {}
print(20*"\n")
print(" █▀▀▀▀▀▀▀▀▀▀█ T-Skylt")
print(" █ ██████ █ av Alex")
print(" █ ██ █ och Parham")
print(" █ ██ █ ----------")
print(" █ ██ █")
print(" █▄▄▄▄▄▄▄▄▄▄█ 2023-2024")
print()
print("--------------------------------------------------------- ")
print("Checking SETTINGS.TXT:")
try:
with open("settings.txt") as f:
settings = json.loads(f.read())
except:
try:
with open("settings.txt", "w") as f:
f.write(json.dumps(settingstxt))
print("Created new settings file!")
except: print("Read only!!!")
for all in settingstxt:
try:settings[all]
except: settings[all] = settingstxt[all]#; print("Added: " + str(all) + " ---> " + settings[all])
try:
if_long = display.width
if_tall = display.height
rotated = display.rotation in (90, 270)
except:
if_long = matrix.width
if_tall = matrix.height
rotated = False
if "DevKit" in os.uname().machine or os.uname().machine == "Waveshare ESP32-S3-Zero with ESP32S3":
cpver = 9
print("--------------------------------------------------------- ")
print(" CHIP: ", os.uname().machine)
print(" VERSION: ", cpver)
print(" FREQUENCY: ", microcontroller.cpu.frequency)
print(" SCREEN-WIDTH: ", if_long)
print("--------------------------------------------------------- ")
#display.rotation = int(settings["rotation"])
group = displayio.Group()
display.root_group = group
display.refresh()
try: display.root_group.hidden = True
except: pass
top = displayio.Bitmap(max(280, if_long), 16, 10)
bottom = displayio.Bitmap(1280, 16, 10)
topbottom = displayio.Bitmap(max(200, if_long, if_tall), max(if_long, if_tall), 10)
palette = displayio.Palette(10, dither=False)
shared = {"loop_counter":-5,
"showstation":0,
"scroll_timer":time.monotonic()-updatedelay,
"nightcount": 0,
"startup":1}
cached_departure_data = {}
use_cached_data = False
traffic_dict = {"METRO":settings["METRO"],
"BUS":settings["BUS"],
"TRAIN":settings["TRAIN"],
"TRAM":settings["TRAM"],
"SHIP":settings["SHIP"]}
print(settings["stations"]["1"]["mystation"])
if settings["stations"]["1"]["mystation"] == "":
print("Adding old data to new dict...")
settings["stations"]["1"]["mystation"] = settings["mystation"]
settings["stations"]["1"]["siteid"] = settings["siteid"]
settings["stations"]["1"]["METRO"] = settings["METRO"]
settings["stations"]["1"]["SHIP"] = settings["SHIP"]
settings["stations"]["1"]["BUS"] = settings["BUS"]
settings["stations"]["1"]["TRAIN"] = settings["TRAIN"]
settings["stations"]["1"]["TRAM"] = settings["TRAM"]
settings["stations"]["1"]["direction"] = settings["direction"]
settings["stations"]["1"]["show_msgs"] = settings["show_msgs"]
settings["stations"]["1"]["buses_option"] = settings["buses_option"]
settings["stations"]["1"]["red"] = settings["red"]
settings["stations"]["1"]["green"] = settings["green"]
settings["stations"]["1"]["blue"] = settings["blue"]
settings["stations"]["1"]["operator"] = settings["operator"]
settings["stations"]["1"]["country"] = settings["country"]
settings["stations"]["1"]["offset"] = settings["offset"]
print("Done.")