TB2026-YDS Firmware
Loading...
Searching...
No Matches
volume.h
Go to the documentation of this file.
1
21#pragma once
22
23#include "esp_err.h"
24#include <stdint.h>
25
32
39
48esp_err_t volume_init(void);
49
62bool volume_poll(int *out_mv, uint8_t *out_level);
63
74bool volume_read_mv(int *out_mv);
75
85
91
101void volume_set_fixed(int percent);
102
104void volume_clear_fixed(void);
105
115uint8_t volume_get_level(void);
116
125void volume_set_bt_handler(esp_err_t (*set_abs_vol)(uint8_t volume));
126
136void volume_set_balance(int8_t steps);
137
142int8_t volume_get_balance(void);
143
151void volume_save_balance(void);
152
void volume_set_fixed(int percent)
Override the pot with a fixed volume (for a deterministic measurement).
Definition volume.c:126
bool volume_poll(int *out_mv, uint8_t *out_level)
Sample the pot and write the active output only if the mapped level changed.
Definition volume.c:79
void volume_set_balance(int8_t steps)
Trim the L/R balance to compensate the analog imbalance (driver is independent L/R).
Definition volume.c:158
void volume_set_bt_handler(esp_err_t(*set_abs_vol)(uint8_t volume))
Register the Bluetooth absolute-volume setter (e.g. bluetooth_set_absolute_volume).
Definition volume.c:153
uint8_t volume_get_level(void)
The level that would be applied to the active output under the current setting.
Definition volume.c:144
esp_err_t volume_init(void)
Bring up the volume pot and push the current knob position to the DAC.
Definition volume.c:56
void volume_save_balance(void)
Persist the current balance trim to NVS so it survives a reboot.
Definition volume.c:169
void volume_set_output(volume_output_t out)
Select which output volume_poll() drives. Default VOLUME_OUT_DAC.
Definition volume.c:113
volume_output_t volume_get_output(void)
The output volume_poll() currently drives (see volume_set_output()).
Definition volume.c:121
void volume_clear_fixed(void)
Release the fixed-volume override; the pot drives the level again from the next poll.
Definition volume.c:136
bool volume_read_mv(int *out_mv)
Read the pot wiper voltage without touching any output (for diagnostics).
Definition volume.c:73
int8_t volume_get_balance(void)
The current L/R balance trim in register steps (see volume_set_balance()).
Definition volume.c:164
volume_output_t
Where volume_poll() sends the knob level.
Definition volume.h:27
@ VOLUME_OUT_DAC
Definition volume.h:29
@ VOLUME_OUT_NONE
Definition volume.h:28
@ VOLUME_OUT_BT
Definition volume.h:30