TB2026-YDS Firmware
Loading...
Searching...
No Matches
volume.c File Reference

Volume service: pot -> active output (DAC byte or Bluetooth AVRCP), deadband write. More...

#include "volume.h"
#include "adc.h"
#include "audio_dac.h"
#include "settings.h"

Macros

#define BAL_KEY   "audio_bal"
#define BAL_BIAS   40

Functions

esp_err_t volume_init (void)
 Bring up the volume pot and push the current knob position to the DAC.
bool volume_read_mv (int *out_mv)
 Read the pot wiper voltage without touching any output (for diagnostics).
bool volume_poll (int *out_mv, uint8_t *out_level)
 Sample the pot and write the active output only if the mapped level changed.
void volume_set_output (volume_output_t out)
 Select which output volume_poll() drives. Default VOLUME_OUT_DAC.
volume_output_t volume_get_output (void)
 The output volume_poll() currently drives (see volume_set_output()).
void volume_set_fixed (int percent)
 Override the pot with a fixed volume (for a deterministic measurement).
void volume_clear_fixed (void)
 Release the fixed-volume override; the pot drives the level again from the next poll.
uint8_t volume_get_level (void)
 The level that would be applied to the active output under the current setting.
void volume_set_bt_handler (esp_err_t(*set_abs_vol)(uint8_t))
 Register the Bluetooth absolute-volume setter (e.g. bluetooth_set_absolute_volume).
void volume_set_balance (int8_t steps)
 Trim the L/R balance to compensate the analog imbalance (driver is independent L/R).
int8_t volume_get_balance (void)
 The current L/R balance trim in register steps (see volume_set_balance()).
void volume_save_balance (void)
 Persist the current balance trim to NVS so it survives a reboot.

Detailed Description

Volume service: pot -> active output (DAC byte or Bluetooth AVRCP), deadband write.

Note
Développé avec l'assistance de Claude Opus 4.8 (Anthropic), sous la direction de Y. Dos Santos : spécification, revue et validation sur cible par l'auteur.

Macro Definition Documentation

◆ BAL_BIAS

#define BAL_BIAS   40

◆ BAL_KEY

#define BAL_KEY   "audio_bal"