Skip to content

Commit 64bfa8a

Browse files
authored
Add files via upload
1 parent 895aa1a commit 64bfa8a

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

boot.py

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,48 @@
1212
import urequests as requests
1313
import _thread as thread
1414
import json
15+
import random
16+
import string
1517

1618
os.chdir('drivers')
1719

1820
index=open('drivers.conf', 'r')
19-
j = json.load(index)
21+
conf = json.load(index)
22+
23+
LOADEDDRIVERS = []
24+
basedrivers = ['display', 'direction', 'storage', 'keyboard']
25+
26+
# Load base drivers
27+
try:
28+
execfile(conf['display'])
29+
LOADEDDRIVERS.append('display')
30+
except:
31+
print('Could not initialize a driver for display.')
32+
33+
try:
34+
execfile(conf['direction'])
35+
LOADEDDRIVERS.append('direction')
36+
except:
37+
print('Could not initialize a driver for directional control.')
38+
39+
try:
40+
execfile(conf['storage'])
41+
LOADEDDRIVERS.append('storage')
42+
except:
43+
print('Could not initialize a driver for external storage.')
44+
45+
try:
46+
execfile(conf['keyboard'])
47+
LOADEDDRIVERS.append('keyboard')
48+
except:
49+
print('Could not initialize driver for keyboard input')
2050

21-
execfile(j['display'])
22-
execfile(j['direction'])
23-
execfile(j['SDreader'])
24-
execfile(j['keyboard'])
51+
# Load optional drivers
52+
for i in conf:
53+
if not i in basedrivers:
54+
if conf[i][0] == True:
55+
execfile(conf[i][1])
56+
LOADEDDRIVERS.append(i)
2557

2658
print('Drivers initialized')
2759

@@ -36,12 +68,12 @@ def log(text):
3668
if LOGGING:
3769
logfile=open('/sd/.logs/'+LOGFILENAME+'.log', 'a')
3870
logfile.write('\n')
39-
logfile.write(str(time.localtime()[3])+':'+str(time.localtime()[4])+':'+str(time.localtime()[5])+': '+str(text))
71+
logfile.write(str(time.localtime()[3])+':'+str(time.localtime()[4])+'.'+str(time.localtime()[5])+': '+str(text))
4072
logfile.close()
4173
else:
4274
print(str(time.localtime()[3])+':'+str(time.localtime()[4])+':'+str(time.localtime()[5])+': '+str(text))
4375

44-
if btn.value() != 0:
76+
if not pressed():
4577
try:
4678
logs=os.listdir('/sd/.logs')
4779
logs.reverse()

0 commit comments

Comments
 (0)