Skip to content

Commit

Permalink
getVolume() make configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Oct 22, 2024
1 parent 47ed8f8 commit bce7eec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/AudioBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ class AudioBoard {
this->volume = volume;
return driver->setVolume(volume);
}
int getVolume() { return volume >= 0 ? volume : driver->getVolume(); }
int getVolume() {
#if DRIVER_REPORT_DRIVER_VOLUME
return driver->getVolume(); }
#else
return volume >= 0 ? volume : driver->getVolume(); }
#endif
DriverPins& getPins() { return *pins; }
bool setPAPower(bool enable) { return driver->setPAPower(enable); }
/// set volume for adc: this is only supported on some defined codecs
Expand Down
9 changes: 9 additions & 0 deletions src/AudioDriverConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
# define DRIVER_DEFAULT_VOLUME 70
#endif

// AudioBoard getVolume() can report the volume reported by the driver or the volume that was last
// set. When using the driver volume, there might be small rounding errors compared to
// the last defined value.
#ifndef DRIVER_REPORT_DRIVER_VOLUME
# define DRIVER_REPORT_DRIVER_VOLUME false
#endif


// To increase the max volume e.g. for ai_thinker (ES8388) 2957 or A202 -> set
// to 1 or 2 0 AUX volume is LINE level 1 you can control the AUX volume with
// setVolume()
Expand All @@ -30,3 +38,4 @@
#ifndef FORCE_WIRE_CLOSE
# define FORCE_WIRE_CLOSE false
#endif

0 comments on commit bce7eec

Please sign in to comment.