Files

104 lines
1.4 KiB
Markdown
Raw Permalink Normal View History

2019-02-14 17:15:34 +08:00
# 喇叭
2018-12-25 16:04:58 +08:00
2019-05-06 22:54:01 +09:00
## begin()
**功能:**
Initialize the speaker.
**函数原型:**
2020-11-05 11:39:06 +08:00
`begin();`
2019-05-06 22:54:01 +09:00
**参数:**
None
**返回值:**
None
## end()
**功能:**
Mute the speakers and stop the output.
**函数原型:**
2020-11-05 11:39:06 +08:00
`end();`
2019-05-06 22:54:01 +09:00
**参数:**
None
**返回值:**
None
2019-02-22 16:52:45 +08:00
<!-- ### tone
2018-12-25 16:04:58 +08:00
> M5.Speaker.tone(uint32_t freq);
设置声音音高
2019-05-06 22:54:01 +09:00
| 参数 | 型 | 描述 |
2018-12-25 16:04:58 +08:00
| --- | --- | --- |
| freq | <code>uint32_t</code> | 频率 |
**例程**
2021-02-26 17:27:20 +08:00
```clike
2018-12-25 16:04:58 +08:00
M5.Speaker.tone(100);
2019-02-22 16:52:45 +08:00
``` -->
2019-02-14 17:15:34 +08:00
2019-02-26 17:56:32 +08:00
## tone()
2019-02-14 17:15:34 +08:00
**函数原型:**
2020-11-05 11:39:06 +08:00
`tone(uint16_t freq);` // for arduino
2019-02-22 16:52:45 +08:00
2020-11-05 11:39:06 +08:00
`tone(uint16_t freq, uint32_t duration);` // for arduino
<!-- `fillScreen(color)` # for micropython -->
2019-02-14 17:15:34 +08:00
**功能:喇叭响指定频率的声音持续指定时间。**
| 参数 | 描述 |
| --- | --- |
| freq | 声音频率 |
| duration | 持续时间 (单位:毫秒) |
2019-02-22 16:52:45 +08:00
<!-- *如果函数的 duration 值没给出,则使用当前的背景颜色。* -->
2019-02-14 17:15:34 +08:00
**例程**
2021-02-26 17:27:20 +08:00
```clike
2019-02-14 17:15:34 +08:00
#include <M5Stack.h>
M5.begin();
M5.Speaker.tone(900, 1000);
```
2019-05-06 22:54:01 +09:00
## setBeep()
**功能:**
Set the beep sound.
**函数原型:**
2020-11-05 11:39:06 +08:00
`setBeep(uint16_t freq, uint16_t duration);`
2019-05-06 22:54:01 +09:00
| 参数 |描述 | 型 |
2019-05-06 22:58:59 +09:00
| --- | --- |---|
2019-05-06 22:54:01 +09:00
| freq | 声音频率 (Hz) | uint16_t |
| duration | 持续时间 (单位:毫秒) | uint16_t |
**例程**
2021-02-26 17:27:20 +08:00
```clike
2019-05-06 22:54:01 +09:00
#include <M5Stack.h>
void setup() {
M5.begin();
M5.Speaker.setBeep(900, 1000);
}
```