コード例 #1
0
# This file is executed on every boot (including wake-boot from deepsleep)

# import esp
# esp.osdebug(None)

# import webrepl
# webrepl.start()

# import gc
# gc.collect()
import machine
Pin_0 = machine.Pin(0)
Pin_0.init(mode = machine.Pin.IN, pull = machine.Pin.PULL_UP)
rtc = machine.RTC()
rtc.wake_on_ext0(Pin_0,0)
print('wake reason: ' + str(machine.wake_reason()))
print('wake reason: ' + str(machine.wake_description()))
if (machine.wake_reason() != (3,1)):
    print('going to sleep')
    machine.deepsleep(0)
print('running main.py')


import time
import utime
from machine import Pin, I2C
import machine
import ssd1306
import framebuf
import network
import ubinascii

# Definitions
ssid = 'DoESLiverpool'
password = '******'

# Why did we wake up?
print(machine.wake_description())

# Setup OLED
rst = Pin(16, Pin.OUT)
rst.value(1)
scl = Pin(15, Pin.OUT, Pin.PULL_UP)
sda = Pin(4, Pin.OUT, Pin.PULL_UP)

i2c = I2C(scl=scl, sda=sda, freq=450000)

oled = ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3c)

# Gimme a welcome screen!
oled.fill(0)
oled.text('DoES Dash', 0, 0)
oled.show()
コード例 #3
0
if badge.safe_mode():
	splash = 'splash'
else:
	splash = badge.nvs_get_str('boot','splash','splash')

if machine.wake_reason() == (7, 0):
	print('[BOOT] Cold boot')
	import post_ota
else:
	if machine.wake_reason() == (3, 4):
		print("[BOOT] Wake from sleep (timer)")
	elif machine.wake_reason() == (3, 1):
		print("[BOOT] Wake from sleep (button)")
	else:
		(reset_cause, wake_reason) = machine.wake_reason()
		(reset_cause_desc, wake_reason_desc) = machine.wake_description()
		print("[BOOT] "+str(reset_cause)+": "+reset_cause_desc+", "+str(wake_reason)+": "+wake_reason_desc)
	load_me = esp.rtcmem_read_string()
	if load_me:
		splash = load_me
		print("starting %s" % load_me)
		esp.rtcmem_write_string("")

try:
	if not splash=="shell":
		if splash.startswith('bpp '):
			splash = splash[4:len(splash)]
			badge.mount_bpp()
		elif splash.startswith('remfs '):
			splash = splash[6:len(splash)]
			badge.mount_remfs()