We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 14ac903 commit e615c18Copy full SHA for e615c18
src/Driver/es8311/es8311.c
@@ -22,8 +22,10 @@
22
*
23
*/
24
25
+
26
#include <string.h>
27
#include <assert.h>
28
+#include <math.h>
29
#include "es8311.h"
30
31
#ifndef BIT
@@ -636,7 +638,13 @@ error_t es8311_codec_set_voice_volume(int volume)
636
638
} else if (volume > 100) {
637
639
volume = 100;
640
}
- int vol = (volume) * 2550 / 1000;
641
+ // Use a logarithmic scale for more natural volume control
642
+ int vol = 0;
643
+ if (volume == 0) {
644
+ vol = 0;
645
+ } else {
646
+ vol = (int)(255.0 * log10(9.0 * volume / 100.0 + 1.0) / log10(10.0));
647
+ }
648
es8311_write_reg(ES8311_DAC_REG32, vol);
649
return res;
650
0 commit comments