mirror of
https://github.com/m5stack/M5Stack_MicroPython.git
synced 2026-05-20 10:14:44 -07:00
Merge branch 'm5stack-dev' into m5stack
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import uos, time, machine
|
||||
import os, time, machine
|
||||
|
||||
def setup():
|
||||
uos.chdir('/flash')
|
||||
os.chdir('/flash')
|
||||
with open("boot.py", "w") as f:
|
||||
f.write("""\
|
||||
# This file is executed on every boot (including wake-boot from deepsleep)
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
from micropython import const
|
||||
import uos as os
|
||||
import machine, ubinascii
|
||||
import utime as time
|
||||
from utime import ticks_ms
|
||||
import os, time, machine, ubinascii
|
||||
import display as lcd
|
||||
import utils
|
||||
|
||||
@@ -37,9 +34,9 @@ class Button:
|
||||
if self._pin == pin:
|
||||
# FALLING
|
||||
if pin_val == 0:
|
||||
if ticks_ms() - self._timeshoot > self._dbtime:
|
||||
if time.ticks_ms() - self._timeshoot > self._dbtime:
|
||||
self._lastState = True
|
||||
self._startTicks = ticks_ms()
|
||||
self._startTicks = time.ticks_ms()
|
||||
self._event |= 0x02 # EVENT_WAS_PRESSED
|
||||
if self._wasPressed_cb:
|
||||
self._wasPressed_cb()
|
||||
@@ -51,11 +48,11 @@ class Button:
|
||||
if self._wasReleased_cb:
|
||||
self._wasReleased_cb()
|
||||
if self._timeout > 0:
|
||||
if ticks_ms() - self._startTicks > self._timeout:
|
||||
if time.ticks_ms() - self._startTicks > self._timeout:
|
||||
self._event |= 0x08 # EVENT_RELEASED_FOR
|
||||
if self._releasedFor_cb:
|
||||
self._releasedFor_cb()
|
||||
self._timeshoot = ticks_ms()
|
||||
self._timeshoot = time.ticks_ms()
|
||||
|
||||
|
||||
def read(self):
|
||||
@@ -93,7 +90,7 @@ class Button:
|
||||
|
||||
|
||||
def pressedFor(self, timeout):
|
||||
if self._lastState and ticks_ms() - self._startTicks > timeout * 1000:
|
||||
if self._lastState and time.ticks_ms() - self._startTicks > timeout * 1000:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -122,6 +122,7 @@ routeHandlers = [
|
||||
|
||||
def webserver_start():
|
||||
wlan_ap = network.WLAN(network.AP_IF)
|
||||
wlan_ap.active(False)
|
||||
wlan_ap.active(True)
|
||||
node_id = ubinascii.hexlify(machine.unique_id())
|
||||
ssid_name= "M5Stack-"+node_id[-6:].decode('utf-8')
|
||||
|
||||
Reference in New Issue
Block a user