A tiny and simple buzzer library, implements a simple turnon, turnoff, and the capabilitie to play loops and ringtones.
All functions works in NON BLOCKING MODE, so, you application will never stops the execution while handling with the device, and, inclusivelly, implementing a `callback` when an operation end.
A tiny and simple buzzer library, implements a simple turn on, turn off, and the capability to play loops and ringtones.
All functions work in NON-BLOCKING MODE, so, your application will never stop the execution while handling the device, and, inclusively, implementing a `callback` when an operation end.
Supports any microcontroller and Passive or Active buzzer.
### Requirements
- A GPIO (active) or PWM (passive) output;
- A Task or timer interrupt;
### Features
- Easy to use;
- Start and stop manually;
- Start for a defined time;
- "Blinks" with a fixed period;
- Play ringtones;
- Non-blocking functions;
- Callback to tell you that an operation is finished.
# How to Use
First, declares your ```buzzer_t``` with, at least, the ```pwmOut``` or ```gpioOut``` (just pick one! the other fxn must be `NULL`). About the functions:
- `void pwmOut(uint32_t freq)` : Is used for PASSIVE buzzers, this function returns `void` and receive only the the `freq` argument. When implementing, the freq=0, the device MUST turnoff PWM.
- `void gpioOut(uint32_t val)` : Is used for ACTIVE buzzer, the value `val` needs to be turnon when is `1`, and `0` turnoff the Buzzer. These buzzers, doesn't can set frequency values.
The lib will automatically identifies the Buzzer type on `buzzer_init()`, by checking the defined fxn.
- `void pwmOut(uint32_t freq)` : Is used for PASSIVE buzzers, this function returns `void` and receives only the `freq` argument. When implementing, the freq=0, the device MUST turn offPWM.
- `void gpioOut(uint32_t val)` : Is used for the ACTIVE buzzer, the value `val` needs to be turn onwhen is `1`, and `0` turnoff the Buzzer. These buzzers can't set frequency values.
Another parameter that needs to be implemented, if user want's to user `buzzer_start` and `buzzer_start_array`, is the `interruptMs`, that only indicates how often you will call the `buzzer_interrupt` in a timer/task routine, in milliseconds.
The lib will automatically identify the Buzzer type on `buzzer_init()`, by checking the defined fxn.
Another parameter that needs to be implemented, if the user wants to user `buzzer_start` and `buzzer_start_array`, is the `interruptMs`, which only indicates how often you will call the `buzzer_interrupt` in a timer/task routine, in milliseconds.
This parameter serves to cronometer the buzzer, turning on and off, for loops, ringtones, etc.
This parameter serves to chronometer the buzzer, turning it on and off, for loops, ringtones, etc.
## Configuring for PASSIVE Buzzer
Bellow, is this example, we are configuring a buzzer in a generic chipset, with a 50ms timer interrupt and a PWM function.
Bellow, in this example, we are configuring a buzzer in a generic chipset, with a 50ms timer interrupt and a PWM function.