diff --git a/boards/default/micropython/build/HZK16_GBK.bin b/boards/default/micropython/build/HZK16_GBK.bin new file mode 100644 index 00000000..2965cdb8 Binary files /dev/null and b/boards/default/micropython/build/HZK16_GBK.bin differ diff --git a/boards/default/micropython/build/lib/map.json b/boards/default/micropython/build/lib/map.json index c8cc0248..17500707 100644 --- a/boards/default/micropython/build/lib/map.json +++ b/boards/default/micropython/build/lib/map.json @@ -572,7 +572,7 @@ "ustruct" ], "__file__": true, - "__size__": 1423, + "__size__": 1424, "__name__": "ntptime.py" }, "object_picture": { @@ -690,7 +690,7 @@ "ustruct" ], "__file__": true, - "__size__": 1559, + "__size__": 1556, "__name__": "rtctime.py" }, "sc7a20": { diff --git a/boards/default/micropython/build/lib/ntptime.py b/boards/default/micropython/build/lib/ntptime.py index 84549720..7474eec6 100644 --- a/boards/default/micropython/build/lib/ntptime.py +++ b/boards/default/micropython/build/lib/ntptime.py @@ -28,12 +28,12 @@ def settime(times): try: val = eval(times) if len(val) >= 6: - times=(val[0], val[1], val[2], 0, val[3], val[4], val[5], 0) + times=(val[0], val[1], val[2], val[3], val[4], val[5], 0) else: raise ValueError("Clock information format error") except: raise ValueError("Clock information format error, use ',' to separate at least 6 numerical values") - if isinstance(times, tuple): + if type(times) in (tuple, list): if 6 <= len(times) <= 8: RTC().datetime((times[0], times[1], times[2], 0, times[3], times[4], times[5], 0)) else: diff --git a/boards/default/micropython/build/lib/rtctime.py b/boards/default/micropython/build/lib/rtctime.py index 3d44d4bc..ff60e6b6 100644 --- a/boards/default/micropython/build/lib/rtctime.py +++ b/boards/default/micropython/build/lib/rtctime.py @@ -30,7 +30,7 @@ def settime(times): try: val = eval(times) if len(val) >= 6: - times=(val[0], val[1], val[2], 0, val[3], val[4], val[5], 0) + times=(val[0], val[1], val[2], val[3], val[4], val[5], 0) else: raise ValueError("Clock information format error") except: diff --git a/boards/default/micropython_esp32s3/build/Mixgo_Sant_lib-v1.23.0.bin b/boards/default/micropython_esp32s3/build/Mixgo_Sant_lib-v1.23.0.bin index ab0cd927..f89568b6 100644 Binary files a/boards/default/micropython_esp32s3/build/Mixgo_Sant_lib-v1.23.0.bin and b/boards/default/micropython_esp32s3/build/Mixgo_Sant_lib-v1.23.0.bin differ diff --git a/boards/default/micropython_esp32s3/build/lib/map.json b/boards/default/micropython_esp32s3/build/lib/map.json index e56aa006..2628027e 100644 --- a/boards/default/micropython_esp32s3/build/lib/map.json +++ b/boards/default/micropython_esp32s3/build/lib/map.json @@ -63,7 +63,7 @@ "ci130x" ], "__file__": true, - "__size__": 7048, + "__size__": 6753, "__name__": "mixgo_sant.py" }, "mixgo_zero": { diff --git a/boards/default/micropython_esp32s3/build/lib/mixgo_sant.py b/boards/default/micropython_esp32s3/build/lib/mixgo_sant.py index e84806f5..40dff7c1 100644 --- a/boards/default/micropython_esp32s3/build/lib/mixgo_sant.py +++ b/boards/default/micropython_esp32s3/build/lib/mixgo_sant.py @@ -18,10 +18,10 @@ onboard_i2c = SoftI2C(scl=Pin(47), sda=Pin(48), freq=400000) '''BOT035-Sensor''' try : - import sant_bot - onboard_bot = sant_bot.BOT035(onboard_i2c) + import sant_bot + onboard_bot = sant_bot.BOT035(onboard_i2c) except Exception as e: - print("Warning: Failed to communicate with BOT035 (Coprocessor) or",e) + print("Warning: Failed to communicate with BOT035 (Coprocessor) or",e) '''SPI-onboard''' onboard_spi = SPI(1, baudrate=80000000, polarity=1, phase=1) @@ -74,10 +74,10 @@ except Exception as e: '''ASR-Sensor''' try : - import ci130x - onboard_asr = ci130x.CI130X(onboard_i2c) + import ci130x + onboard_asr = ci130x.CI130X(onboard_i2c) except Exception as e: - print("Warning: Failed to communicate with CI130X (ASR) or",e) + print("Warning: Failed to communicate with CI130X (ASR) or",e) '''2RGB_WS2812''' from ws2812 import NeoPixel @@ -143,101 +143,108 @@ A4key = KEYSensor(15,2900) '''2-LED''' class LED: - def __init__(self, pins=[]): - self._pins = [PWM(Pin(pin), duty_u16=0) for pin in pins] - self._brightness = [0 for _ in range(len(self._pins))] + def __init__(self, pins=[]): + self._pins = [PWM(Pin(pin), duty_u16=0) for pin in pins] + self._brightness = [0 for _ in range(len(self._pins))] - def setbrightness(self, index, val): - if not 0 <= val <= 100: - raise ValueError("Brightness must be in the range: 0-100%") - self._brightness[index - 1] = val - self._pins[index - 1].duty_u16(val * 65535 // 100) + def setbrightness(self, index, val): + if not 0 <= val <= 100: + raise ValueError("Brightness must be in the range: 0-100%") + self._brightness[index - 1] = val + self._pins[index - 1].duty_u16(val * 65535 // 100) - def getbrightness(self, index): - return self._brightness[index - 1] + def getbrightness(self, index): + return self._brightness[index - 1] - def setonoff(self, index, val): - if val == -1: - self.setbrightness(index, 100) if self.getbrightness(index) < 50 else self.setbrightness(index, 0) - elif val == 1: - self.setbrightness(index, 100) - elif val == 0: - self.setbrightness(index, 0) + def setonoff(self, index, val): + if val == -1: + self.setbrightness(index, 100) if self.getbrightness(index) < 50 else self.setbrightness(index, 0) + elif val == 1: + self.setbrightness(index, 100) + elif val == 0: + self.setbrightness(index, 0) - def getonoff(self, index): - return True if self.getbrightness(index) > 50 else False + def getonoff(self, index): + return True if self.getbrightness(index) > 50 else False onboard_led = LED(pins=[45, 46]) +class Voice_Energy: + def read(self): + _dat = onboard_asr._rreg(0x08, 3) #在语音识别里获取 + return (_dat[0] | _dat[1] << 8) // 10 + +onboard_sound = Voice_Energy() + class Clock: - def __init__(self, x, y, radius, color, oled=onboard_tft): #定义时钟中心点和半径 - self.display = oled - self.xc = x - self.yc = y - self.r = radius - self.color= color - self.hour = 0 - self.min = 0 - self.sec = 0 + def __init__(self, x, y, radius, color, oled=onboard_tft): #定义时钟中心点和半径 + self.display = oled + self.xc = x + self.yc = y + self.r = radius + self.color= color + self.hour = 0 + self.min = 0 + self.sec = 0 - def set_time(self, h, m, s): #设定时间 - self.hour = h - self.min = m - self.sec = s + def set_time(self, h, m, s): #设定时间 + self.hour = h + self.min = m + self.sec = s - def set_rtctime(self): #设定时间 - t = rtc_clock.datetime() - self.hour = t[4] - self.min = t[5] - self.sec = t[6] + def set_rtctime(self): #设定时间 + t = rtc_clock.datetime() + self.hour = t[4] + self.min = t[5] + self.sec = t[6] - def drawDial(self,color): #画钟表刻度 - r_tic1 = self.r - 1 - r_tic2 = self.r - 2 - self.display.ellipse(self.xc, self.yc, self.r, self.r, color) - self.display.ellipse(self.xc, self.yc, 2, 2, color,True) + def drawDial(self,color): #画钟表刻度 + r_tic1 = self.r - 1 + r_tic2 = self.r - 2 + self.display.ellipse(self.xc, self.yc, self.r, self.r, color) + self.display.ellipse(self.xc, self.yc, 2, 2, color,True) - for h in range(12): - at = math.pi * 2.0 * h / 12.0 - x1 = round(self.xc + r_tic1 * math.sin(at)) - x2 = round(self.xc + r_tic2 * math.sin(at)) - y1 = round(self.yc - r_tic1 * math.cos(at)) - y2 = round(self.yc - r_tic2 * math.cos(at)) - self.display.line(x1, y1, x2, y2, color) + for h in range(12): + at = math.pi * 2.0 * h / 12.0 + x1 = round(self.xc + r_tic1 * math.sin(at)) + x2 = round(self.xc + r_tic2 * math.sin(at)) + y1 = round(self.yc - r_tic1 * math.cos(at)) + y2 = round(self.yc - r_tic2 * math.cos(at)) + self.display.line(x1, y1, x2, y2, color) - def drawHour(self,color): #画时针 - r_hour = int(self.r / 10.0 * 5) - ah = math.pi * 2.0 * ((self.hour % 12) + self.min / 60.0) / 12.0 - xh = int(self.xc + r_hour * math.sin(ah)) - yh = int(self.yc - r_hour * math.cos(ah)) - self.display.line(self.xc, self.yc, xh, yh, color) + def drawHour(self,color): #画时针 + r_hour = int(self.r / 10.0 * 5) + ah = math.pi * 2.0 * ((self.hour % 12) + self.min / 60.0) / 12.0 + xh = int(self.xc + r_hour * math.sin(ah)) + yh = int(self.yc - r_hour * math.cos(ah)) + self.display.line(self.xc, self.yc, xh, yh, color) - def drawMin(self,color): #画分针 - r_min = int(self.r / 10.0 * 7) - am = math.pi * 2.0 * self.min / 60.0 - xm = round(self.xc + r_min * math.sin(am)) - ym = round(self.yc - r_min * math.cos(am)) - self.display.line(self.xc, self.yc, xm, ym, color) + def drawMin(self,color): #画分针 + r_min = int(self.r / 10.0 * 7) + am = math.pi * 2.0 * self.min / 60.0 + xm = round(self.xc + r_min * math.sin(am)) + ym = round(self.yc - r_min * math.cos(am)) + self.display.line(self.xc, self.yc, xm, ym, color) - def drawSec(self,color): #画秒针 - r_sec = int(self.r / 10.0 * 9) - asec = math.pi * 2.0 * self.sec / 60.0 - xs = round(self.xc + r_sec * math.sin(asec)) - ys = round(self.yc - r_sec * math.cos(asec)) - self.display.line(self.xc, self.yc, xs, ys, color) + def drawSec(self,color): #画秒针 + r_sec = int(self.r / 10.0 * 9) + asec = math.pi * 2.0 * self.sec / 60.0 + xs = round(self.xc + r_sec * math.sin(asec)) + ys = round(self.yc - r_sec * math.cos(asec)) + self.display.line(self.xc, self.yc, xs, ys, color) - def draw_clock(self, bg_color=0): #画完整钟表 - self.drawDial(self.color) - self.drawHour(self.color) - self.drawMin(self.color) - self.drawSec(self.color) - self.display.show() - self.drawHour(bg_color) - self.drawMin(bg_color) - self.drawSec(bg_color) + def draw_clock(self, bg_color=0): #画完整钟表 + self.drawDial(self.color) + self.drawHour(self.color) + self.drawMin(self.color) + self.drawSec(self.color) + self.display.show() + self.drawHour(bg_color) + self.drawMin(bg_color) + self.drawSec(bg_color) - def clear(self, color=0): #清除 - self.display.ellipse(self.xc, self.yc, self.r, self.r, color, True) + def clear(self, color=0): #清除 + self.display.ellipse(self.xc, self.yc, self.r, self.r, color, True) '''Reclaim memory''' gc.collect() diff --git a/boards/default/micropython_esp32s3/config.json b/boards/default/micropython_esp32s3/config.json index e4971237..ac738c11 100644 --- a/boards/default/micropython_esp32s3/config.json +++ b/boards/default/micropython_esp32s3/config.json @@ -8,7 +8,7 @@ "type": "command", "portSelect": "all", "micropython:esp32s3:mixgo_sant": { - "command": "\"{esptool}\" --chip esp32s3 --port {com} --baud 460800 --before default_reset --after=no_reset_stub erase_flash && \"{esptool}\" --chip esp32s3 --port {com} --baud 460800 --after hard_reset write_flash 0x0 \"{indexPath}/build/Mixgo_Sant-v1.23.0.bin\" 0xE00000 \"{indexPath}/../micropython/build/HZK16.bin\"" + "command": "\"{esptool}\" --chip esp32s3 --port {com} --baud 460800 --before default_reset --after=no_reset_stub erase_flash && \"{esptool}\" --chip esp32s3 --port {com} --baud 460800 --after hard_reset write_flash 0x0 \"{indexPath}/build/Mixgo_Sant-v1.23.0.bin\" 0xE00000 \"{indexPath}/../micropython/build/HZK16_GBK.bin\"" }, "micropython:esp32s3:mixgo_nova": { "command": "\"{esptool}\" --chip esp32s3 --port {com} --baud 460800 --before default_reset --after=no_reset_stub erase_flash && \"{esptool}\" --chip esp32s3 --port {com} --baud 460800 --after hard_reset write_flash 0x0 \"{indexPath}/build/Mixgo_Nova-v1.21.0.bin\" 0x700000 \"{indexPath}/../micropython/build/HZK12.bin\"" @@ -72,7 +72,7 @@ "path": "./build/Mixgo_Sant_lib-v1.23.0.bin" }, { "offset": "0xE00000", - "path": "../micropython/build/HZK16.bin" + "path": "../micropython/build/HZK16_GBK.bin" } ] }, diff --git a/boards/default_src/micropython/origin/build/lib/map.json b/boards/default_src/micropython/origin/build/lib/map.json index c8cc0248..17500707 100644 --- a/boards/default_src/micropython/origin/build/lib/map.json +++ b/boards/default_src/micropython/origin/build/lib/map.json @@ -572,7 +572,7 @@ "ustruct" ], "__file__": true, - "__size__": 1423, + "__size__": 1424, "__name__": "ntptime.py" }, "object_picture": { @@ -690,7 +690,7 @@ "ustruct" ], "__file__": true, - "__size__": 1559, + "__size__": 1556, "__name__": "rtctime.py" }, "sc7a20": { diff --git a/boards/default_src/micropython_esp32s3/origin/build/lib/map.json b/boards/default_src/micropython_esp32s3/origin/build/lib/map.json index e56aa006..2628027e 100644 --- a/boards/default_src/micropython_esp32s3/origin/build/lib/map.json +++ b/boards/default_src/micropython_esp32s3/origin/build/lib/map.json @@ -63,7 +63,7 @@ "ci130x" ], "__file__": true, - "__size__": 7048, + "__size__": 6753, "__name__": "mixgo_sant.py" }, "mixgo_zero": {