-
Notifications
You must be signed in to change notification settings - Fork 1
/
_boot.py
65 lines (47 loc) · 1.17 KB
/
_boot.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
import gc
import uos
from flashbdev import bdev
try:
if bdev:
uos.mount(bdev, "/")
except OSError:
import inisetup
vfs = inisetup.setup()
gc.collect()
import builtins
import leviot.touchpad
import leviot
# noinspection PyBroadException
try:
import user_boot
except ImportError:
pass
# noinspection PyPep8Naming
class Command:
def __init__(self, callback):
self.callback = callback
def __repr__(self):
self.callback()
return ""
def __str__(self):
self.callback()
return ""
def __call__(self):
self.callback()
def _wifi_up():
from leviot.network import up
import uasyncio
loop = uasyncio.get_event_loop()
loop.run_until_complete(up())
builtins.run = Command(leviot.main)
builtins.netup = Command(_wifi_up)
try:
from leviot_conf import autoboot
except ImportError:
print("Warning: no config file found. Please create 'leviot_conf.py'")
autoboot = False
if autoboot:
leviot.main()
print("Type 'run' to re-start the program, 'netup' to turn on and connect to Wi-Fi")
print("You can run your code before startup by adding a 'user_boot.py' script.")
print()