From 9c12e7dc7eaf1ba55112dfe9ff2038eac7de60a3 Mon Sep 17 00:00:00 2001 From: 0x1abin <270995079@qq.com> Date: Tue, 10 Apr 2018 14:51:09 +0800 Subject: [PATCH] v0.3.9 --- .../micropython/esp32/modules/inisetup.py | 4 ++-- .../micropython/esp32/modules/m5stack.py | 21 ++++++++----------- .../micropython/esp32/modules/wificonfig.py | 1 + 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/MicroPython_BUILD/components/micropython/esp32/modules/inisetup.py b/MicroPython_BUILD/components/micropython/esp32/modules/inisetup.py index 7205297..d672580 100644 --- a/MicroPython_BUILD/components/micropython/esp32/modules/inisetup.py +++ b/MicroPython_BUILD/components/micropython/esp32/modules/inisetup.py @@ -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) diff --git a/MicroPython_BUILD/components/micropython/esp32/modules/m5stack.py b/MicroPython_BUILD/components/micropython/esp32/modules/m5stack.py index bfccc18..3838a6b 100644 --- a/MicroPython_BUILD/components/micropython/esp32/modules/m5stack.py +++ b/MicroPython_BUILD/components/micropython/esp32/modules/m5stack.py @@ -1,12 +1,9 @@ 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 -VERSION = "v0.3.8" +VERSION = "v0.3.9" _BUTTON_A_PIN = const(39) _BUTTON_B_PIN = const(38) @@ -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 @@ -156,9 +153,9 @@ print('\nDevice ID:' + node_id) # LCD lcd = lcd.TFT() -lcd.init(lcd.M5STACK, width=240, height=320, rst_pin=33, backl_pin=32, miso=19, mosi=23, clk=18, cs=14, dc=27, bgr=True, backl_on=1, invrot=3) +lcd.init(lcd.M5STACK, width=240, height=320, speed=27000000, rst_pin=33, backl_pin=32, miso=19, mosi=23, clk=18, cs=14, dc=27, bgr=True, backl_on=1, invrot=3) lcd.clear() -lcd.setBrightness(600) +lcd.setBrightness(500) lcd.setColor(0xCCCCCC) lcd.println('M5Stack MicroPython '+VERSION, 0, 0) lcd.println('Device ID:'+node_id) diff --git a/MicroPython_BUILD/components/micropython/esp32/modules/wificonfig.py b/MicroPython_BUILD/components/micropython/esp32/modules/wificonfig.py index 8cdbee1..15cd2a5 100644 --- a/MicroPython_BUILD/components/micropython/esp32/modules/wificonfig.py +++ b/MicroPython_BUILD/components/micropython/esp32/modules/wificonfig.py @@ -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')