feat: Radiomaster TX15 support (#6484)
Co-authored-by: Malte Langermann <54738901+gagarinlg@users.noreply.github.com> Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
Malte Langermann
3djc
raphaelcoeffic
philmoz
Peter Feerick
parent
3a00c0812b
commit
324b2c7761
@@ -22,6 +22,7 @@
|
||||
#include "tas2505.h"
|
||||
#include "stm32_i2s.h"
|
||||
#include "timers_driver.h"
|
||||
#include "hal/audio_driver.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
@@ -126,3 +127,25 @@ int tas2505_init(tas2505_t* dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// adjust this value for a volume level just above the silence
|
||||
// values is attenuation in dB, higher value - less volume
|
||||
// max value is 126
|
||||
#define VOLUME_MIN_DB 60
|
||||
|
||||
void tas2505_set_volume(tas2505_t* dev, uint8_t volume)
|
||||
{
|
||||
if (volume > VOLUME_LEVEL_MAX) {
|
||||
volume = VOLUME_LEVEL_MAX;
|
||||
}
|
||||
// maximum volume is 0x00 and total silence is 0xFE
|
||||
if (volume == 0) {
|
||||
tas2505_write_reg(dev, TAS2505_SPKVOL1, 0xFE);
|
||||
tas2505_write_reg(dev, TAS2505_HP_VOL, 0xFE);
|
||||
} else {
|
||||
uint32_t vol = (VOLUME_MIN_DB * 2) -
|
||||
((uint32_t)volume * (VOLUME_MIN_DB * 2)) / VOLUME_LEVEL_MAX;
|
||||
tas2505_write_reg(dev, TAS2505_SPKVOL1, vol);
|
||||
tas2505_write_reg(dev, TAS2505_HP_VOL, vol);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user