// Autogenerated C header file for Buzzer
#ifndef _JACDAC_SPEC_BUZZER_H
#define _JACDAC_SPEC_BUZZER_H 1

#define JD_SERVICE_CLASS_BUZZER  0x1b57b1d7

/**
 * Read-write ratio u0.8 (uint8_t). The volume (duty cycle) of the buzzer.
 */
#define JD_BUZZER_REG_VOLUME JD_REG_INTENSITY

/**
 * Play a PWM tone with given period and duty for given duration.
 * The duty is scaled down with `volume` register.
 * To play tone at frequency `F` Hz and volume `V` (in `0..1`) you will want
 * to send `P = 1000000 / F` and `D = P * V / 2`.
 */
#define JD_BUZZER_CMD_PLAY_TONE 0x80
typedef struct jd_buzzer_play_tone {
    uint16_t period; // μs
    uint16_t duty; // μs
    uint16_t duration; // ms
} jd_buzzer_play_tone_t;


/**
 * Play a note at the given frequency and volume.
 */
#define JD_BUZZER_CMD_PLAY_NOTE 0x81
typedef struct jd_buzzer_play_note {
    uint16_t frequency; // AudHz
    uint16_t volume;  // ratio u0.16
    uint16_t duration; // ms
} jd_buzzer_play_note_t;


#endif
