build(boards): micropython板卡执行 npm run build:prod

This commit is contained in:
王立帮
2025-06-18 23:43:04 +08:00
parent e42a129714
commit 0d8b8b3170
61 changed files with 867 additions and 124 deletions

View File

@@ -68,7 +68,7 @@ class AI:
def motion_recognition(self, threshold=50):
if self._func == MOTION_DEECTION:
if self._once: self._init(threshold)
return self._ai.read()
return bool(self._ai.read() >= threshold)
else:
raise AttributeError('This model can only run motion recognition')
@@ -104,3 +104,7 @@ class AI:
self._ai.delete(_id)
else:
raise AttributeError('This model can only run face recognition')
def stop(self):
if self._ai is not None:
self._ai.stop()

View File

@@ -7,14 +7,16 @@ MicroPython library for the GC032A(Inherit C module)
"""
import time
import base64
from sensor import *
from machine import SoftI2C, Pin
from mixgo_sant import onboard_bot
from esp_usb import CAM
class GC032A(Camera):
def __init__(self, framesize=LCD, hmirror=None):
def __init__(self, framesize=LCD, hmirror=None, frame=1):
onboard_bot.cam_en(1, 500)
super().__init__()
super().__init__(frame)
super().set_framesize(framesize)
time.sleep_ms(100)
if hmirror is not None:
@@ -32,3 +34,36 @@ class GC032A(Camera):
super().display()
else:
super().display_stop()
def snapshot(self, path=None, formats=0, quality=50):
if path is None:
_data = super().snapshot(formats=formats, quality=quality)
if formats >= 2:
return b'data:image/jpg;base64,' + base64.b64encode(_data)
else:
return _data
else:
return super().snapshot(path, quality=50)
class UVC(CAM):
def __init__(self, framesize=QVGA):
super().__init__(framesize)
def deinit(self):
super().deinit()
def display(self, show=True):
if show:
super().display()
else:
super().display_stop()
def snapshot(self, path=None, formats=0, quality=50):
if path is None:
_data = super().snapshot(formats=formats, quality=quality)
if formats >= 2:
return b'data:image/jpg;base64,' + base64.b64encode(_data)
else:
return _data
else:
return super().snapshot(path, quality=50)

View File

@@ -5,18 +5,20 @@
"micropython"
],
"__file__": true,
"__size__": 3981,
"__size__": 4086,
"__name__": "ai_camera.py"
},
"camera": {
"__require__": [
"time",
"base64",
"sensor",
"machine",
"mixgo_sant"
"mixgo_sant",
"esp_usb"
],
"__file__": true,
"__size__": 964,
"__size__": 2071,
"__name__": "camera.py"
},
"ci1302x": {
@@ -90,7 +92,7 @@
"ci1302x"
],
"__file__": true,
"__size__": 6354,
"__size__": 6446,
"__name__": "mixgo_sant.py"
},
"mixgo_zero": {
@@ -135,7 +137,7 @@
"machine"
],
"__file__": true,
"__size__": 6992,
"__size__": 6947,
"__name__": "musicx.py"
},
"music_spk": {
@@ -216,7 +218,7 @@
"tftlcd"
],
"__file__": true,
"__size__": 1518,
"__size__": 1587,
"__name__": "st7789_cf.py"
},
"ws2812x": {

View File

@@ -156,9 +156,11 @@ class LED:
onboard_led = LED(onboard_bot.led_pwm)
class Voice_Energy:
def read(self):
_dat = onboard_asr._rreg(0x08, 3) #在语音识别里获取
return (_dat[0] | _dat[1] << 8) // 10
def read(self, samples=10):
values = []
for _ in range(samples):
values.append(int.from_bytes(onboard_asr._rreg(0x08, 3)[:2], 'little')) #在语音识别里获取
return sorted(values)[samples // 2]
onboard_sound = Voice_Energy()

View File

@@ -4,11 +4,8 @@ Music buzzer
Micropython library for the Music buzzer
=======================================================
#Based on Author: qiren123(MIDI Music) 20220618
#Make changes to instantiation 20220622
#Increase level reversal selection 20220716
dahanzimin From the Mixly Team
#Based on Author: qiren123(MIDI Music)
@dahanzimin From the Mixly Team
"""
from time import sleep_ms
@@ -97,8 +94,8 @@ class MIDI():
self.set_duration(int(tone[(pos + 1):]))
tone = tone[:pos]
def play(self, tune, duration=None):
if self._pa_ctrl: self._pa_ctrl(1)
def play(self, tune, duration=None, pa_delay=100):
if self._pa_ctrl: self._pa_ctrl(1, pa_delay)
self._pwm = PWM(Pin(self._pin), duty=1023 if self._invert else 0)
if duration is None:
self.set_default(tune[0])
@@ -110,32 +107,32 @@ class MIDI():
continue
midi = self.midi(tone)
self._pwm.duty(1023-self._volume) if self._invert else self._pwm.duty(self._volume)
self._pwm.freq(midi[0])
self._pwm.freq(midi[0])
sleep_ms(midi[1])
self._pwm.freq(40000)
sleep_ms(1)
if self._pa_ctrl: self._pa_ctrl(0)
if self._pa_ctrl: self._pa_ctrl(0, 0)
self._pwm.deinit()
sleep_ms(10)
def pitch(self, freq):
if self._pa_ctrl: self._pa_ctrl(1)
def pitch(self, freq, pa_delay=100):
if self._pa_ctrl: self._pa_ctrl(1, pa_delay)
self._pwm = PWM(Pin(self._pin))
self._pwm.duty(1023-self._volume) if self._invert else self._pwm.duty(self._volume)
self._pwm.freq(int(freq))
self._pwm.freq(int(freq))
def pitch_time(self, freq, delay):
if self._pa_ctrl: self._pa_ctrl(1)
def pitch_time(self, freq, delay, pa_delay=100):
if self._pa_ctrl: self._pa_ctrl(1, pa_delay)
self._pwm = PWM(Pin(self._pin))
self._pwm.duty(1023-self._volume) if self._invert else self._pwm.duty(self._volume)
self._pwm.freq(int(freq))
self._pwm.freq(int(freq))
sleep_ms(delay)
if self._pa_ctrl: self._pa_ctrl(0)
if self._pa_ctrl: self._pa_ctrl(0, 0)
self._pwm.deinit()
sleep_ms(10)
def stop(self):
if self._pa_ctrl: self._pa_ctrl(0)
if self._pa_ctrl: self._pa_ctrl(0, 0)
if self._pwm: self._pwm.deinit()
sleep_ms(10)

View File

@@ -10,6 +10,8 @@ from tftlcd import LCD15
class ST7789(uframebuf.FrameBuffer_Uincode):
def __init__(self, width=240, height=240, reset=None, backlight=None, direction=1, font_address=0x700000):
self.display = LCD15(portrait=direction)
self.display.deinit()
if reset is not None:
reset(0, 50)
reset(1, 100)

View File

@@ -1,7 +1,8 @@
{
"board": {
"元控青春": "micropython:esp32s3:mixgo_nova",
"元控自强": "micropython:esp32s3:mixgo_sant"
"元控自强": "micropython:esp32s3:mixgo_sant",
"S3_generic":"micropython:esp32s3:generic"
},
"language": "MicroPython",
"burn": {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long