diff --git a/app/by_buzzer.c b/app/by_buzzer.c index 1626379..5b94c62 100644 --- a/app/by_buzzer.c +++ b/app/by_buzzer.c @@ -25,7 +25,7 @@ void queue_add_element(int element) } void queue_pop_element(void) { - memmove(a, &a[1], (queue_long - 1) * sizeof(a[0])); + memmove(a, &a[1], (queue_long - 1) * sizeof(a[0])); // FIXME 强迫症震怒,仅移动,未清除原位置上的值 if (queue_long > 0) { queue_long--; } @@ -61,16 +61,19 @@ void by_buzzer_add(uint16_t tone) void by_buzzer_run(void) { - if (queue_long != 0) { + if (queue_long > 0) { 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); + if (0 == time_out) + pwm_set_duty(BUZZER_PIN, 0); + } + + if (time_out) { + time_out--; } } \ No newline at end of file