Fixed some bug.

develop
刘栩丰 2 years ago
parent 94fed19d74
commit 864ae4663a

@ -72,7 +72,7 @@ void __attribute__((weak)) buzzer_end_callback(buzzer_t *buzzer){
void buzzer_interrupt(buzzer_t *buzzer){ void buzzer_interrupt(buzzer_t *buzzer){
uint16_t i; uint16_t i;
if (buzzer->active) if (buzzer->active)
buzzer->counting += buzzer->millisScaledBy10; buzzer->counting += buzzer->cycleMsInterval;
if (buzzer->active && buzzer->play_param.len > 0 if (buzzer->active && buzzer->play_param.len > 0
&& buzzer->counting > buzzer->play_param.time){ && buzzer->counting > buzzer->play_param.time){
i = buzzer->play_param.i; i = buzzer->play_param.i;
@ -184,7 +184,7 @@ void buzzer_turn_on(buzzer_t *buzzer, uint16_t freq){
void buzzer_start(buzzer_t *buzzer, uint16_t freq, uint16_t period, uint16_t loop_time){ void buzzer_start(buzzer_t *buzzer, uint16_t freq, uint16_t period, uint16_t loop_time){
if (buzzer != NULL){ if (buzzer != NULL){
buzzer->play_param.i = 0; buzzer->play_param.i = 0;
buzzer->play_param.time = period*10;//millisScaledBy10 buzzer->play_param.time = period;//cycleMsInterval
buzzer->play_param.loop_time = loop_time*2; buzzer->play_param.loop_time = loop_time*2;
buzzer->play_param.pTimes = NULL; buzzer->play_param.pTimes = NULL;
buzzer->play_param.pFreq = NULL; buzzer->play_param.pFreq = NULL;

@ -17,8 +17,8 @@
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
//#define _BUZZER_DERIVER_USE_PWM #define _BUZZER_DERIVER_USE_PWM
#define _BUZZER_DERIVER_USE_GPIO //#define _BUZZER_DERIVER_USE_GPIO
/* /*
* Enumerates * Enumerates
@ -58,7 +58,7 @@ typedef enum{
* *
*/ */
#ifdef _BUZZER_DERIVER_USE_PWM #ifdef _BUZZER_DERIVER_USE_PWM
typedef void (*pwmOutFx)(uint32_t freq); typedef void (*pwmOutFx)(uint16_t freq);
#endif #endif
#ifdef _BUZZER_DERIVER_USE_GPIO #ifdef _BUZZER_DERIVER_USE_GPIO
@ -85,7 +85,7 @@ typedef struct{
// the interrupt period that you will call buzzer_interrupt() // the interrupt period that you will call buzzer_interrupt()
// necessary for buzzer_start() and buzzer_start_array() // necessary for buzzer_start() and buzzer_start_array()
uint16_t millisScaledBy10; uint16_t cycleMsInterval;
buzzer_active_e active; buzzer_active_e active;
uint16_t counting; uint16_t counting;

Loading…
Cancel
Save