diff --git a/boards/default_src/micropython/origin/build/lib/tvoc07s.py b/boards/default_src/micropython/origin/build/lib/tvoc07s.py new file mode 100644 index 00000000..dd509b8b --- /dev/null +++ b/boards/default_src/micropython/origin/build/lib/tvoc07s.py @@ -0,0 +1,39 @@ +""" +TVOC + +Micropython library for the TVOC(UART) +======================================================= +@dahanzimin From the Mixly Team +""" +import time + +class TVOC: + def __init__(self, uart): + self._uart = uart + self._uart.init(baudrate=9600) + self._tvoc = (0, 0 ,0) #TVOC mg/m3, CH2O mg/m3, C02 ppm + self._flag = False + if not self._chip_id(): + raise AttributeError("Cannot find a TOVC") + + def _rreg(self): + '''Read data''' + if self._uart.any(): + eec = 0 + buf = self._uart.read(9) + for i in buf[:8]: + eec += i + if (eec & 0xFF) == buf[8] and buf[0] == 0x2C: + self._tvoc=((buf[2] << 8 | buf[3]) * 0.001, (buf[4] << 8 | buf[5]) * 0.001, buf[6] << 8 | buf[7] ) + return True + + def _chip_id(self): + for _ in range(5): + if self._rreg(): + return True + time.sleep(1) + return False + + def read(self): + self._rreg() + return self._tvoc diff --git a/boards/default_src/micropython_esp32s3/origin/build/lib/ai_camera.py b/boards/default_src/micropython_esp32s3/origin/build/lib/ai_camera.py index 436aac5d..aef70a08 100644 --- a/boards/default_src/micropython_esp32s3/origin/build/lib/ai_camera.py +++ b/boards/default_src/micropython_esp32s3/origin/build/lib/ai_camera.py @@ -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() diff --git a/boards/default_src/micropython_esp32s3/origin/build/lib/mixgo_sant.py b/boards/default_src/micropython_esp32s3/origin/build/lib/mixgo_sant.py index 12674a70..cf1c7bad 100644 --- a/boards/default_src/micropython_esp32s3/origin/build/lib/mixgo_sant.py +++ b/boards/default_src/micropython_esp32s3/origin/build/lib/mixgo_sant.py @@ -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()