fix: 修正蜂鸣器声音队列移位错误

This commit is contained in:
bmy
2024-03-03 17:19:00 +08:00
parent b6bb69d24c
commit b02471785b
2 changed files with 4 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ uint32_t a[40] = {0};
void queue_init(void)
{
queue_long = 0;
memset(a, 0, sizeof(a));
}
@@ -22,7 +23,7 @@ void queue_add_element(int element)
}
void queue_pop_element(void)
{
memmove(a, &a[1], queue_long * sizeof(a));
memmove(a, &a[1], (queue_long - 1) * sizeof(a[0]));
if (queue_long > 0) {
queue_long--;
}