Files

38 lines
761 B
Python
Raw Permalink Normal View History

2018-04-10 14:51:09 +08:00
import os, time, machine
2018-03-02 10:59:33 +08:00
def setup():
2018-04-10 14:51:09 +08:00
os.chdir('/flash')
2018-03-02 10:59:33 +08:00
with open("boot.py", "w") as f:
f.write("""\
# This file is executed on every boot (including wake-boot from deepsleep)
import sys
sys.path[1] = '/flash/lib'
2018-04-19 09:47:40 +08:00
from m5stack import lcd, speaker, buttonA, buttonB, buttonC
2018-03-02 10:59:33 +08:00
# ---------- M5Cloud ------------
2018-04-19 11:03:08 +08:00
if False:
2018-03-02 10:59:33 +08:00
if buttonB.isPressed():
lcd.println('On: OFF-LINE Mode', color=lcd.ORANGE)
2018-03-02 17:10:06 +08:00
else:
2018-03-02 10:59:33 +08:00
import wifisetup
import m5cloud
""")
with open("main.py", "w") as f:
f.write("""\
from m5stack import lcd
2018-03-02 17:10:06 +08:00
'''
lcd.clear()
lcd.setCursor(0, 0)
lcd.setColor(lcd.WHITE)
lcd.print("Hello world!")
'''
2018-03-02 10:59:33 +08:00
""")
time.sleep(0.1)
print('boot.py Creact done! reset..')
machine.reset()
setup()