summaryrefslogtreecommitdiff
path: root/src/drivers/wm8523.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-09-04 16:17:55 +1000
committerjacqueline <me@jacqueline.id.au>2023-09-04 16:17:55 +1000
commitd5d6e3993cd67238ff245446e69e2f200c3fd0e5 (patch)
tree6245939ab341694363eac8bc24ab1b91b5140c6e /src/drivers/wm8523.cpp
parent6d831fa7a8c50e15424814fd2be1dd3951e06a4f (diff)
downloadtangara-fw-d5d6e3993cd67238ff245446e69e2f200c3fd0e5.tar.gz
Support changing max volume, persisted to nvs
Diffstat (limited to 'src/drivers/wm8523.cpp')
-rw-r--r--src/drivers/wm8523.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/drivers/wm8523.cpp b/src/drivers/wm8523.cpp
index e1dffd51..5f6c8053 100644
--- a/src/drivers/wm8523.cpp
+++ b/src/drivers/wm8523.cpp
@@ -15,6 +15,23 @@
namespace drivers {
namespace wm8523 {
+const uint16_t kAbsoluteMaxVolume = 0x1ff;
+const uint16_t kAbsoluteMinVolume = 0b0;
+
+// This is 3dB below what the DAC considers to be '0dB', and 9.5dB above line
+// level reference.
+const uint16_t kMaxVolumeBeforeClipping = 0x184;
+
+// This is 12.5 dB below what the DAC considers to be '0dB'.
+const uint16_t kLineLevelReferenceVolume = 0x15E;
+
+// Default to -24 dB, which I will claim is 'arbitrarily chosen to be safe but
+// audible', but is in fact just a nice value for my headphones in particular.
+const uint16_t kDefaultVolume = kLineLevelReferenceVolume - 96;
+
+// Default to +6dB == 2Vrms == 'CD Player'
+const uint16_t kDefaultMaxVolume = kLineLevelReferenceVolume + 12;
+
static const uint8_t kAddress = 0b0011010;
auto ReadRegister(Register reg) -> std::optional<uint16_t> {