From 04973e875c0cf4b338bcbdd11971647df6df67da Mon Sep 17 00:00:00 2001 From: bmy <2583236812@qq.com> Date: Wed, 7 Feb 2024 14:12:00 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E4=BF=AE=E6=94=B9buzzer=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/by_buzzer.c | 10 ++++++++++ app/by_buzzer.h | 3 ++- app/main.c | 22 +--------------------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/app/by_buzzer.c b/app/by_buzzer.c index 0d97078..162fc77 100644 --- a/app/by_buzzer.c +++ b/app/by_buzzer.c @@ -54,3 +54,13 @@ void by_buzzer_add(uint16_t tone) { queue_add_element(tone); } + +void by_buzzer_run(void) +{ + if (queue_long != 0) { + pwm_init(BUZZER_PIN, a[0], 5000); + queue_pop_element(); + system_delay_ms(100); + pwm_set_duty(BUZZER_PIN, 0); + } +} \ No newline at end of file diff --git a/app/by_buzzer.h b/app/by_buzzer.h index a0edcad..7a3fd50 100644 --- a/app/by_buzzer.h +++ b/app/by_buzzer.h @@ -7,7 +7,7 @@ #define BY_PRESS_LONG 2500 #define BY_FORWARD 1500 #define BY_BACKWARD 1800 -#define BUZZER_PIN TIM9_PWM_MAP0_CH1_A2 +#define BUZZER_PIN TIM9_PWM_MAP0_CH1_A2 extern uint32_t a[40]; extern uint16_t queue_long; @@ -20,4 +20,5 @@ extern void queue_pop_element(void); extern void queue_pop_read(void); extern void by_buzzer_init(void); extern void by_buzzer_add(uint16_t tone); +extern void by_buzzer_run(void); #endif \ No newline at end of file diff --git a/app/main.c b/app/main.c index 81faf24..f40f8b5 100644 --- a/app/main.c +++ b/app/main.c @@ -47,27 +47,7 @@ int main(void) Page_Init(); while (1) { - - // switch (by_get_rb_status()) { - // case 3: - // i++; - // break; - // case 4: - // i--; - // break; - // default: - // break; - // } - - // by_pwm_update_duty(500 + i * 50, 500 + i * 50); - // by_pwm_power_duty(500 + i * 50, 500 + i * 50, 500 + i * 50, 500 + i * 50); - // // ips200_show_uint(0, 0, 1000, 4); - // ips200_draw_rect(0, 0, 50, 50, RGB565_YELLOW); - // system_delay_ms(100); - // ips200_draw_rect(0, 0, 50, 50, RGB565_BLACK); - // system_delay_ms(10); - - queue_pop_read(); + by_buzzer_run(); Page_Run(); } }