pref: 修改buzzer接口

This commit is contained in:
bmy
2024-02-07 14:12:00 +08:00
parent 5f29a9eca2
commit 04973e875c
3 changed files with 13 additions and 22 deletions

View File

@@ -54,3 +54,13 @@ void by_buzzer_add(uint16_t tone)
{ {
queue_add_element(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);
}
}

View File

@@ -7,7 +7,7 @@
#define BY_PRESS_LONG 2500 #define BY_PRESS_LONG 2500
#define BY_FORWARD 1500 #define BY_FORWARD 1500
#define BY_BACKWARD 1800 #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 uint32_t a[40];
extern uint16_t queue_long; extern uint16_t queue_long;
@@ -20,4 +20,5 @@ extern void queue_pop_element(void);
extern void queue_pop_read(void); extern void queue_pop_read(void);
extern void by_buzzer_init(void); extern void by_buzzer_init(void);
extern void by_buzzer_add(uint16_t tone); extern void by_buzzer_add(uint16_t tone);
extern void by_buzzer_run(void);
#endif #endif

View File

@@ -47,27 +47,7 @@ int main(void)
Page_Init(); Page_Init();
while (1) { while (1) {
by_buzzer_run();
// 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();
Page_Run(); Page_Run();
} }
} }