mirror of
https://github.com/m5stack/M5Stack_MicroPython.git
synced 2026-05-20 10:14:44 -07:00
v0.3.7
This commit is contained in:
@@ -479,7 +479,7 @@ mp_obj_t mp_machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
||||
}
|
||||
|
||||
if (i2c_slave_task_handle[self->bus_id] == NULL) {
|
||||
xTaskCreate(i2c_slave_task, "i2c_slave_task", 1024, (void *)self, CONFIG_MICROPY_TASK_PRIORITY+4, &i2c_slave_task_handle[self->bus_id]);
|
||||
xTaskCreate(i2c_slave_task, "i2c_slave_task", 1024, (void *)self, 8, &i2c_slave_task_handle[self->bus_id]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ STATIC mp_obj_t mp_machine_i2c_init(mp_uint_t n_args, const mp_obj_t *pos_args,
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Error installing I2C driver"));
|
||||
}
|
||||
if (i2c_slave_task_handle[self->bus_id] == NULL) {
|
||||
xTaskCreate(i2c_slave_task, "i2c_slave_task", 1024, (void *)self, CONFIG_MICROPY_TASK_PRIORITY+4, &i2c_slave_task_handle[self->bus_id]);
|
||||
xTaskCreate(i2c_slave_task, "i2c_slave_task", 1024, (void *)self, 8, &i2c_slave_task_handle[self->bus_id]);
|
||||
}
|
||||
}
|
||||
i2c_used[bus_id] = mode;
|
||||
|
||||
@@ -6,12 +6,12 @@ from utime import ticks_ms
|
||||
import display as lcd
|
||||
import utils
|
||||
|
||||
VERSION = "v0.3.6"
|
||||
VERSION = "v0.3.7"
|
||||
|
||||
_BUTTON_A_PIN = const(39)
|
||||
_BUTTON_B_PIN = const(38)
|
||||
_BUTTON_C_PIN = const(37)
|
||||
_SPEAKER_PIN = const(25)
|
||||
_SPEAKER_PIN = const(25)
|
||||
|
||||
|
||||
class Button:
|
||||
@@ -97,7 +97,7 @@ class Button:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def releasedFor(self, timeout, callback=None):
|
||||
self._timeout = timeout * 1000 # second
|
||||
@@ -114,32 +114,28 @@ class Button:
|
||||
|
||||
class Speaker:
|
||||
def __init__(self, pin=25, volume=2):
|
||||
self.pin = machine.PWM(machine.Pin(pin))
|
||||
self.pwm = machine.PWM(machine.Pin(pin), 1, 0, 0)
|
||||
self._timer = 0
|
||||
self._volume = volume*10
|
||||
self.pin.duty(0)
|
||||
self._timer = machine.Timer(3)
|
||||
|
||||
def _timeout_cb(self, timer):
|
||||
self.pin.duty(0)
|
||||
self._timer.deinit()
|
||||
self.pwm.duty(0)
|
||||
self.pwm.deinit()
|
||||
|
||||
def tone(self, freq=1800, timeout=200):
|
||||
self.pin.freq(freq)
|
||||
self.pin.duty(self._volume)
|
||||
self.pwm.init(freq=freq, duty=self._volume)
|
||||
if timeout > 0:
|
||||
self._timer = machine.Timer(3)
|
||||
self._timer.init(period=timeout, mode=self._timer.ONE_SHOT, callback=self._timeout_cb)
|
||||
|
||||
def volume(self, val):
|
||||
self._volume = val * 10
|
||||
|
||||
|
||||
|
||||
#
|
||||
def fimage(x, y, file):
|
||||
if file[:3] == '/sd':
|
||||
# try:
|
||||
# os.umountsd()
|
||||
# except:
|
||||
# pass
|
||||
# os.mountsd()
|
||||
utils.filecp(file, '/flash/fcache', blocksize=4096)
|
||||
lcd.image(x, y, '/flash/fcache', 0, lcd.JPG)
|
||||
os.remove('/flash/fcache')
|
||||
@@ -151,7 +147,7 @@ def delay(ms):
|
||||
time.sleep_ms(ms)
|
||||
|
||||
|
||||
# -------- M5Stack ---------
|
||||
# ------------------ M5Stack -------------------
|
||||
|
||||
# Node ID
|
||||
node_id = ubinascii.hexlify(machine.unique_id()).decode('utf-8')
|
||||
@@ -179,4 +175,4 @@ buttonC = Button(_BUTTON_C_PIN)
|
||||
|
||||
|
||||
# SPEAKER
|
||||
# speaker = Speaker()
|
||||
speaker = Speaker()
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
#define MICROPY_PY_WEBSOCKET (1)
|
||||
#endif
|
||||
#define MICROPY_PY_OS_DUPTERM (1)
|
||||
#define MICROPY_PY_WEBREPL (1)
|
||||
#define MICROPY_PY_WEBREPL (0)
|
||||
|
||||
#ifdef CONFIG_MICROPY_PY_FRAMEBUF
|
||||
#define MICROPY_PY_FRAMEBUF (1)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user