|
|
@ -40,7 +40,6 @@ static constexpr uint16_t kMinVolume = 0b0; |
|
|
|
static constexpr uint16_t kMaxVolumeBeforeClipping = 0x185; |
|
|
|
static constexpr uint16_t kMaxVolumeBeforeClipping = 0x185; |
|
|
|
static constexpr uint16_t kLineLevelVolume = 0x13d; |
|
|
|
static constexpr uint16_t kLineLevelVolume = 0x13d; |
|
|
|
static constexpr uint16_t kDefaultVolume = 0x100; |
|
|
|
static constexpr uint16_t kDefaultVolume = 0x100; |
|
|
|
static constexpr uint16_t kVolumeStep = 5; // CUSTOM - added
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
I2SAudioOutput::I2SAudioOutput(drivers::IGpios& expander, |
|
|
|
I2SAudioOutput::I2SAudioOutput(drivers::IGpios& expander, |
|
|
|
drivers::OutputBuffers& buffers) |
|
|
|
drivers::OutputBuffers& buffers) |
|
|
@ -141,29 +140,21 @@ auto I2SAudioOutput::SetVolumeDb(int_fast16_t val) -> bool { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
auto I2SAudioOutput::AdjustVolumeUp() -> bool { |
|
|
|
auto I2SAudioOutput::AdjustVolumeUp() -> bool { |
|
|
|
uint16_t vol = GetVolume(); |
|
|
|
if (GetVolume() >= max_volume_) { |
|
|
|
if (vol >= max_volume_) { |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SetVolume(GetVolume() + 1); |
|
|
|
if (vol > max_volume_ - kVolumeStep) { |
|
|
|
|
|
|
|
SetVolume(max_volume_); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
SetVolume(vol + kVolumeStep); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
auto I2SAudioOutput::AdjustVolumeDown() -> bool { |
|
|
|
auto I2SAudioOutput::AdjustVolumeDown() -> bool { |
|
|
|
uint16_t vol = GetVolume(); |
|
|
|
if (GetVolume() == kMinVolume) { |
|
|
|
if (vol == kMinVolume) { |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (vol <= kMinVolume + kVolumeStep) { |
|
|
|
if (GetVolume() <= kMinVolume + 1) { |
|
|
|
SetVolume(0); |
|
|
|
SetVolume(0); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
SetVolume(vol - kVolumeStep); |
|
|
|
SetVolume(GetVolume() - 1); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|