Mic
Mic 用于控制主机内部集成的按键。以下是主机的 Mic 支持详细:
Controller |
SPM1423 |
ES7210 |
---|---|---|
AtomS3 |
||
AtomS3 Lite |
||
AtomS3U |
✔ |
|
StampS3 |
||
CoreS3 |
✔ |
|
Core2 |
✔ |
|
TOUGH |
Micropython Example:
pass
UIFLOW2 Example:
pass
class Mic
重要
Mic Class的方法重度依赖 M5.begin()
和 M5.update()
。
调用 Mic 对象的所有方法,需要放在 M5.begin()
的后面,并在 主循环中调用 M5.update()
。
Methods
- Mic.config([cfg:mic_config_t])
- Mic.config('param')
- Mic.config(param=value)
获取或者设置 Mic 对象的参数。
当不传入任何参数时,会返回
mic_config_t
的对象。当传入一个mic_config_t
的对象, Mic 会设置 Mic 的所有支持的参数。当传入下表中的参数, Mic 会对传入的参数进行获取或者设置。
以下是支持的参数:
Parameter
Type
Description
pin_data_in
(integer)
I2S 的串行数据线,用二进制补码表示的音频数据。
pin_bck
(integer)
I2S 的串行时钟线,对应数字音频的每一位数据。
pin_mck
(integer)
I2S 的主时钟线。一般为了使系统间能够更好地同步时增加MCLK信号,MCLK的频率 = 256 * 采样频率。
pin_ws
(integer)
I2S 的帧时钟,用于切换左右声道的数据。
sample_rate
(integer)
输入音频的目标采样率。
stereo
(boolean)
使用双声道输出。
over_sampling
(integer)
求平均值的采样次数。
magnification
(integer)
输入值的乘数。
noise_filter_level
(integer)
先前值的系数,用于噪声过滤。
use_adc
(boolean)
使用模拟输入麦克风(仅需要 pin_data_in )。
dma_buf_len
(integer)
I2S 的DMA缓冲区长度。
dma_buf_count
(integer)
I2S 的DMA缓冲区数量。
task_priority
(integer)
后台任务优先级。
task_pinned_core
(integer)
后台任务使用的CPU。
i2s_port
(integer)
I2S端口。
UIFLOW2:
读取属性:
Python:
Mic.config("pin_data_in")
设置属性:
Python:
Mic.config(pin_data_in=1)
- Mic.isRecording() int
获取 Mic 是否处于录音状态, 返回int类型。
返回值:
0=not recording
1=recording (There’s room in the queue)
2=recording (There’s no room in the queue.)
UIFLOW2: