feat: 蜂鸣器和旋钮适配

This commit is contained in:
bmy
2024-02-07 10:24:11 +08:00
parent 845ab06586
commit 5f29a9eca2
9 changed files with 78 additions and 120 deletions

View File

@@ -1,12 +1,13 @@
#include "by_buzzer.h"
#include "by_rt_button.h"
#include "zf_common_headfile.h"
#include <string.h>
#include "zf_common_headfile.h"
#define BUZZER_QUEUE_LENGTH 40
uint16_t queue_long = 0;
uint32_t a[40] = {0};
uint16_t queue_long = 0;
const uint32_t max_long = 40;
uint32_t a[40];
void queue_init(void)
{
memset(a, 0, sizeof(a));
@@ -14,7 +15,7 @@ void queue_init(void)
void queue_add_element(int element)
{
if (queue_long < max_long) {
if (queue_long < BUZZER_QUEUE_LENGTH) {
a[queue_long] = element;
queue_long += 1;
}
@@ -38,5 +39,18 @@ void queue_pop_read(void)
void by_buzzer_init(void)
{
queue_init();
pwm_init(BUZZER_PIN, 2000, 0);
by_buzzer_add(1250);
by_buzzer_add(1500);
by_buzzer_add(1750);
by_buzzer_add(1500);
by_buzzer_add(1200);
by_buzzer_add(900);
}
void by_buzzer_add(uint16_t tone)
{
queue_add_element(tone);
}