From b7b2cf33b303b1db0a33e40f8e3f9efedb8f6b16 Mon Sep 17 00:00:00 2001 From: dahanzimin <353767514@qq.com> Date: Sat, 12 Jul 2025 10:24:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0MINI=E7=9A=84PCM=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=87=BD=E6=95=B0=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../origin/build/lib/mini_bot.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py index de1343e4..dca92853 100644 --- a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py +++ b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py @@ -348,12 +348,13 @@ class BOT035(FrameBuffer): print("Warning: Please upgrade the coprocessor firmware to use this feature") def mic_pga(self, value=None): + '''0:4x, 1:8x, 2:16x, 3:32x, 4:OFF''' if value is None: return self._rreg(_BOT035_FLAG) >> 4 else: self._wreg(_BOT035_FLAG, (self._rreg(_BOT035_FLAG) & 0x0F) | (value & 0x03) << 4) - def pcm_power(self, power=None): + def pcm_en(self, power=None): if self._version >= 3: if power is None: return bool(self._rreg(_BOT035_STA) & 0x08) @@ -362,28 +363,28 @@ class BOT035(FrameBuffer): else: print("Warning: Please upgrade the coprocessor firmware to use this feature") - def pcm_state(self, power=None): + def pcm_any(self): return bool(self._rreg(_BOT035_STA) & 0x80) - def pcm_data(self, ibuf=1600): + def pcm_read(self, ibuf=1600): return self._rreg(_BOT035_PCM, ibuf) def pcm_record(self, path='mixly.wav', seconds=5, ibuf=1600, timeout=2000): if self._version >= 3: - self.pcm_power(True) + self.pcm_en(True) _star = time.ticks_ms() _size = int(ibuf * seconds * 10) _header = b'RIFF' + (36 + _size).to_bytes(4, 'little') + b'WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00' + (ibuf * 5).to_bytes(4, 'little') + (ibuf * 10).to_bytes(4, 'little') + b'\x02\x00\x10\x00data' + _size.to_bytes(4, 'little') with open(path, 'wb') as f: f.write(_header) while _size > 0: - if self.pcm_state(): - f.write(self.pcm_data(ibuf)) + if self.pcm_any(): + f.write(self.pcm_read(ibuf)) _size -= ibuf _star = time.ticks_ms() if time.ticks_diff(time.ticks_ms(), _star) > timeout: raise OSError("Timeout write error") - self.pcm_power(False) + self.pcm_en(False) else: print("Warning: Please upgrade the coprocessor firmware to use this feature")