Skip to content

File syn_buzzer.h

FileList > output > syn_buzzer.h

Go to the source code of this file

Non-blocking Piezo Buzzer & Tone Generator module.

  • #include "../common/syn_defs.h"
  • #include "../port/syn_port_gpio.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_Buzzer
Non-blocking piezo buzzer context.

Public Functions

Type Name
SYN_Status syn_buzzer_beep (SYN_Buzzer * buz, uint32_t freq_hz, uint32_t duration_ms)
Play a single tone non-blockingly.
SYN_Status syn_buzzer_init (SYN_Buzzer * buz, SYN_GPIO_Pin pin, bool active_high)
Initialize a buzzer instance on a GPIO pin.
bool syn_buzzer_is_playing (const SYN_Buzzer * buz)
Check if buzzer is currently playing a tone or melody pattern.
SYN_Status syn_buzzer_play_pattern (SYN_Buzzer * buz, const uint16_t * freqs, const uint16_t * durs, size_t count)
Play a sequence of tones (melody/pattern) non-blockingly.
void syn_buzzer_step (SYN_Buzzer * buz, uint32_t dt_ms)
Update buzzer state machine. Call periodically in main/scheduler loop.
void syn_buzzer_stop (SYN_Buzzer * buz)
Stop audio output immediately.

Public Functions Documentation

function syn_buzzer_beep

Play a single tone non-blockingly.

SYN_Status syn_buzzer_beep (
    SYN_Buzzer * buz,
    uint32_t freq_hz,
    uint32_t duration_ms
) 

Parameters:

  • buz Buzzer context.
  • freq_hz Frequency in Hz (0 = silent pause).
  • duration_ms Duration in milliseconds.

Returns:

SYN_OK on success.


function syn_buzzer_init

Initialize a buzzer instance on a GPIO pin.

SYN_Status syn_buzzer_init (
    SYN_Buzzer * buz,
    SYN_GPIO_Pin pin,
    bool active_high
) 

Parameters:

  • buz Buzzer context.
  • pin GPIO pin identifier.
  • active_high True if HIGH logic turns on buzzer.

Returns:

SYN_OK on success.


function syn_buzzer_is_playing

Check if buzzer is currently playing a tone or melody pattern.

bool syn_buzzer_is_playing (
    const SYN_Buzzer * buz
) 

Parameters:

  • buz Buzzer context.

Returns:

True if active.


function syn_buzzer_play_pattern

Play a sequence of tones (melody/pattern) non-blockingly.

SYN_Status syn_buzzer_play_pattern (
    SYN_Buzzer * buz,
    const uint16_t * freqs,
    const uint16_t * durs,
    size_t count
) 

Parameters:

  • buz Buzzer context.
  • freqs Array of note frequencies in Hz.
  • durs Array of note durations in ms.
  • count Number of notes in the pattern.

Returns:

SYN_OK on success.


function syn_buzzer_step

Update buzzer state machine. Call periodically in main/scheduler loop.

void syn_buzzer_step (
    SYN_Buzzer * buz,
    uint32_t dt_ms
) 

Parameters:

  • buz Buzzer context.
  • dt_ms Milliseconds elapsed since last call.

function syn_buzzer_stop

Stop audio output immediately.

void syn_buzzer_stop (
    SYN_Buzzer * buz
) 

Parameters:

  • buz Buzzer context.


The documentation for this class was generated from the following file src/syntropic/output/syn_buzzer.h