pref: 修改蜂鸣器为非阻塞形式
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
#include <string.h>
|
||||
#include "zf_common_headfile.h"
|
||||
|
||||
#define BUZZER_QUEUE_LENGTH 40
|
||||
#define BUZZER_TIME (100) // 蜂鸣器音节长度
|
||||
#define BUZZER_QUEUE_LENGTH (40)
|
||||
|
||||
uint32_t time_out = 0;
|
||||
uint16_t queue_long = 0;
|
||||
uint32_t a[40] = {0};
|
||||
|
||||
@@ -59,9 +61,15 @@ void by_buzzer_add(uint16_t tone)
|
||||
void by_buzzer_run(void)
|
||||
{
|
||||
if (queue_long != 0) {
|
||||
pwm_init(BUZZER_PIN, a[0], 5000);
|
||||
queue_pop_element();
|
||||
system_delay_ms(100);
|
||||
|
||||
if (0 == time_out) {
|
||||
pwm_init(BUZZER_PIN, a[0], 5000);
|
||||
queue_pop_element();
|
||||
time_out = BUZZER_TIME;
|
||||
} else {
|
||||
time_out--;
|
||||
}
|
||||
} else {
|
||||
pwm_set_duty(BUZZER_PIN, 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user