Skip to content

Commit bce7eec

Browse files
committed
getVolume() make configurable
1 parent 47ed8f8 commit bce7eec

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/AudioBoard.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ class AudioBoard {
6262
this->volume = volume;
6363
return driver->setVolume(volume);
6464
}
65-
int getVolume() { return volume >= 0 ? volume : driver->getVolume(); }
65+
int getVolume() {
66+
#if DRIVER_REPORT_DRIVER_VOLUME
67+
return driver->getVolume(); }
68+
#else
69+
return volume >= 0 ? volume : driver->getVolume(); }
70+
#endif
6671
DriverPins& getPins() { return *pins; }
6772
bool setPAPower(bool enable) { return driver->setPAPower(enable); }
6873
/// set volume for adc: this is only supported on some defined codecs

src/AudioDriverConfig.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
# define DRIVER_DEFAULT_VOLUME 70
66
#endif
77

8+
// AudioBoard getVolume() can report the volume reported by the driver or the volume that was last
9+
// set. When using the driver volume, there might be small rounding errors compared to
10+
// the last defined value.
11+
#ifndef DRIVER_REPORT_DRIVER_VOLUME
12+
# define DRIVER_REPORT_DRIVER_VOLUME false
13+
#endif
14+
15+
816
// To increase the max volume e.g. for ai_thinker (ES8388) 2957 or A202 -> set
917
// to 1 or 2 0 AUX volume is LINE level 1 you can control the AUX volume with
1018
// setVolume()
@@ -30,3 +38,4 @@
3038
#ifndef FORCE_WIRE_CLOSE
3139
# define FORCE_WIRE_CLOSE false
3240
#endif
41+

0 commit comments

Comments
 (0)