Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions adafruit_wm8960/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ def input(self, value: int) -> None:
self._codec.mic = mic
self._codec.mic_inverting_input = mic
self._codec.mic_input = (value & 0b110) >> 1 if mic else Mic_Input.VMID
self._codec.mic_mute = mic
self._codec.mic_mute = not mic
self._codec.mic_boost = mic

self._input = value

# Reset gain values
self.gain = self._gain

self._input = value

@property
def gain(self) -> float:
"""The amount of analog gain on the selected input before the ADC.
Expand All @@ -169,13 +169,13 @@ def gain(self, value: float) -> None:
self._codec.input2_boost = (
map_range(value, 0.0, 1.0, BOOST_GAIN_MIN, BOOST_GAIN_MAX)
if not mic and self._input & 0b010
else BOOST_GAIN_MIN
else BOOST_GAIN_MIN - 1.0
)

self._codec.input3_boost = (
map_range(value, 0.0, 1.0, BOOST_GAIN_MIN, BOOST_GAIN_MAX)
if not mic and self._input & 0b100
else BOOST_GAIN_MIN
else BOOST_GAIN_MIN - 1.0
)

self._gain = constrain(value, 0.0, 1.0)
Expand Down