Skip to content

Commit 3bb05cd

Browse files
authored
Update files
Update files. THIS UPDATE IS NOT FULLY FUNCTIONING YET. I also added the updated firmware file with the most recent micropython version. (untested) So if someone would like to test it, That would be great!
1 parent d6094ef commit 3bb05cd

File tree

5 files changed

+791
-277
lines changed

5 files changed

+791
-277
lines changed

boot.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import vga1_bold_16x32 as fontlarge
1313
import urequests as requests
1414
import _thread as thread
15+
import sdcard
1516

1617
execfile('appRefresh.py')
1718

@@ -30,12 +31,43 @@
3031

3132
upamount = 40
3233

33-
espcolor = st7789.BLUE
3434
spi = machine.SPI(1, baudrate=40000000, polarity=1)
3535
display = st7789.ST7789(spi, 240, 240, reset=machine.Pin(27, machine.Pin.OUT), dc=machine.Pin(26, machine.Pin.OUT), backlight=sc)
3636
display.init()
3737

3838
os.chdir('/')
3939

40+
try:
41+
sdspi=machine.SoftSPI(-1, sck=machine.Pin(18), mosi=machine.Pin(23), miso=machine.Pin(19))
42+
sd = sdcard.SDCard(sdspi, machine.Pin(5))
43+
os.mount(sd, '/sd')
44+
print('SD card mounted.')
45+
except Exception as e:
46+
print('No SD card present.')
47+
48+
LOGGING = True
49+
LOGFILENAME = ''
50+
51+
def log(text):
52+
if LOGGING:
53+
logfile=open('/sd/.logs/'+LOGFILENAME+'.log', 'a')
54+
logfile.write('\n')
55+
logfile.write(str(time.localtime()[3])+':'+str(time.localtime()[4])+':'+str(time.localtime()[5])+': '+str(text))
56+
logfile.close()
57+
else:
58+
print(str(time.localtime()[3])+':'+str(time.localtime()[4])+': '+str(text))
59+
4060
if btn.value() == 0:
41-
execfile('/system/microOS.py')
61+
try:
62+
logs=os.listdir('/sd/.logs')
63+
logs.reverse()
64+
try:
65+
LOGFILENAME='log_'+str(int(logs[0].strip('log_').strip('.'))+1)
66+
except:
67+
LOGFILENAME='log_0'
68+
except:
69+
LOGGING = False
70+
try:
71+
execfile('/system/microOS.py')
72+
except Exception as e:
73+
log('An error ocurred in the system.\nError:\n'+str(e)+'\nPlease refer to the instructions at https://github.com/asherevan/microOS/wiki/Reporting%E2%80%90bugs to report this bug.')

firmware.bin

1.6 MB
Binary file not shown.

functions.py

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,41 @@ def microoswords():
22
display.fill_rect(15, 80-upamount, 215, 70, st7789.WHITE)
33
display.fill_rect(70, 150-upamount, 100, 70, st7789.YELLOW)
44
# M
5-
display.line(20, 140-upamount, 30, 90-upamount, espcolor)
6-
display.line(30, 90-upamount, 40, 140-upamount, espcolor)
7-
display.line(40, 140-upamount, 50, 90-upamount, espcolor)
8-
display.line(50, 90-upamount, 60, 140-upamount, espcolor)
5+
display.line(20, 140-upamount, 30, 90-upamount, st7789.BLUE)
6+
display.line(30, 90-upamount, 40, 140-upamount, st7789.BLUE)
7+
display.line(40, 140-upamount, 50, 90-upamount, st7789.BLUE)
8+
display.line(50, 90-upamount, 60, 140-upamount, st7789.BLUE)
99

1010
# I
11-
display.line(70, 90-upamount, 100, 90-upamount, espcolor)
12-
display.line(85, 90-upamount, 85, 140-upamount, espcolor)
13-
display.line(70, 140-upamount, 100, 140-upamount, espcolor)
11+
display.line(70, 90-upamount, 100, 90-upamount, st7789.BLUE)
12+
display.line(85, 90-upamount, 85, 140-upamount, st7789.BLUE)
13+
display.line(70, 140-upamount, 100, 140-upamount, st7789.BLUE)
1414

1515
# C
16-
display.line(110, 90-upamount, 140, 90-upamount, espcolor)
17-
display.line(110, 90-upamount, 110, 140-upamount, espcolor)
18-
display.line(110, 140-upamount, 140, 140-upamount, espcolor)
16+
display.line(110, 90-upamount, 140, 90-upamount, st7789.BLUE)
17+
display.line(110, 90-upamount, 110, 140-upamount, st7789.BLUE)
18+
display.line(110, 140-upamount, 140, 140-upamount, st7789.BLUE)
1919

2020

2121
# R
22-
display.line(150, 90-upamount, 150, 140-upamount, espcolor)
23-
display.rect(150, 90-upamount, 25, 25, espcolor)
24-
display.line(150, 115-upamount, 175, 140-upamount, espcolor)
22+
display.line(150, 90-upamount, 150, 140-upamount, st7789.BLUE)
23+
display.rect(150, 90-upamount, 25, 25, st7789.BLUE)
24+
display.line(150, 115-upamount, 175, 140-upamount, st7789.BLUE)
2525

2626
# O
27-
display.rect(190, 90-upamount, 30, 50, espcolor)
28-
display.rect(191, 91-upamount, 28, 48, espcolor)
27+
display.rect(190, 90-upamount, 30, 50, st7789.BLUE)
28+
display.rect(191, 91-upamount, 28, 48, st7789.BLUE)
2929

3030
# O
31-
display.rect(80, 160-upamount, 30, 50, espcolor)
32-
display.rect(81, 161-upamount, 28, 48, espcolor)
31+
display.rect(80, 160-upamount, 30, 50, st7789.BLUE)
32+
display.rect(81, 161-upamount, 28, 48, st7789.BLUE)
3333

3434
# S
35-
display.line(105+20, 90+70-upamount, 135+20, 90+70-upamount, espcolor)
36-
display.line(105+20, 90+70-upamount, 105+20, 115+70-upamount, espcolor)
37-
display.line(105+20, 115+70-upamount, 135+20, 115+70-upamount, espcolor)
38-
display.line(135+20, 115+70-upamount, 135+20, 140+70-upamount, espcolor)
39-
display.line(135+20, 140+70-upamount, 105+20, 140+70-upamount, espcolor)
35+
display.line(105+20, 90+70-upamount, 135+20, 90+70-upamount, st7789.BLUE)
36+
display.line(105+20, 90+70-upamount, 105+20, 115+70-upamount, st7789.BLUE)
37+
display.line(105+20, 115+70-upamount, 135+20, 115+70-upamount, st7789.BLUE)
38+
display.line(135+20, 115+70-upamount, 135+20, 140+70-upamount, st7789.BLUE)
39+
display.line(135+20, 140+70-upamount, 105+20, 140+70-upamount, st7789.BLUE)
4040

4141

4242
def numpad(textx=25, texty=10):
@@ -354,12 +354,25 @@ def appstore():
354354
display.fill(0)
355355

356356
display.text(font, 'App Store', 75, 1)
357-
358-
with open('/system/apps.txt') as file:
359-
for line in file:
360-
line = line.rstrip('\n')
361-
apps.append(line.split(':')[0])
362-
links.append(line.split(':')[1])
357+
358+
try:
359+
with open('/system/apps.txt') as file:
360+
for line in file:
361+
line = line.rstrip('\n')
362+
apps.append(line.split(';')[0])
363+
links.append(line.split(';')[1])
364+
except:
365+
r=requests.get('https://raw.githubusercontent.com/asherevan/microOS-apps/master/index.txt')
366+
file=open('/system/apps.txt', 'w')
367+
file.write(r.text)
368+
file.close()
369+
with open('/system/apps.txt') as file:
370+
for line in file:
371+
line = line.rstrip('\n')
372+
apps.append(line.split(';')[0])
373+
links.append(line.split(';')[1])
374+
print(apps)
375+
print(links)
363376

364377
line = 0
365378
selected = 0
@@ -387,12 +400,12 @@ def appstore():
387400
if btn.value() == 0:
388401
display.fill(0)
389402
display.text(font, apps[selected], 75, 1)
390-
r=requests.get('https://raw.githubusercontent.com/asherevan/microOS-apps/master/'+apps[selected]+'/details.txt')
403+
r=requests.get(links[selected]+'details.txt')
391404
results=r.text
392405
line = 0
393406
for i in split_string(results, 30):
394407
display.text(font, i, 2, 12+10*line)
395-
line +=1
408+
line += 1
396409

397410
display.rect(20, 217, 200, 12, st7789.WHITE)
398411
if not apps[selected] in os.listdir('/apps'):
@@ -406,11 +419,20 @@ def appstore():
406419
if btn.value() == 0:
407420
if not apps[selected] in os.listdir('/apps'):
408421
display.text(font, 'Installing', 80, 218, st7789.BLUE)
409-
r=requests.get('https://raw.githubusercontent.com/asherevan/microOS-apps/master/'+apps[selected]+'/main.py')
410422
os.mkdir('/apps/'+apps[selected])
411-
file=open('/apps/'+apps[selected]+'/main.py', 'w')
412-
file.write(r.text)
413-
file.close()
423+
try:
424+
r=requests.get(links[selected]+'files.txt').text
425+
files=r.split('\n')
426+
for i in files:
427+
r = requests.get(links[selected]+i).text
428+
file=open('/apps/'+apps[selected]+'/'+i, 'w')
429+
file.write(r)
430+
file.close()
431+
except:
432+
r = requests.get(links[selected]+'main.py').text
433+
file=open('/apps/'+apps[selected]+'/main.py', 'w')
434+
file.write(r)
435+
file.close()
414436
appstore()
415437
else:
416438
for i in os.listdir('/apps/'+apps[selected]):
@@ -432,8 +454,8 @@ def appsrefresh():
432454
with open('/system/apps.txt') as file:
433455
for line in file:
434456
line = line.rstrip('\n')
435-
apps.append(line.split(':')[0])
436-
links.append(line.split(':')[1])
457+
apps.append(line.split(';')[0])
458+
links.append(line.split(';')[1])
437459

438460

439461
def updateapps():
@@ -484,4 +506,4 @@ def app_menu():
484506
updateapps()
485507
selectedapp = appamount-1
486508

487-
display.rect(5, 10 * selectedapp, 230, 10, st7789.RED)
509+
display.rect(5, 10 * selectedapp, 230, 10, st7789.RED)

0 commit comments

Comments
 (0)