use adafruit_simplemath instead of simpleio. Use multi-line string for warning message
This commit is contained in:
parent
c41e65bdeb
commit
733ef1b925
2 changed files with 8 additions and 8 deletions
|
|
@ -38,9 +38,9 @@ import digitalio
|
||||||
import displayio
|
import displayio
|
||||||
import framebufferio
|
import framebufferio
|
||||||
import picodvi
|
import picodvi
|
||||||
import simpleio
|
|
||||||
import storage
|
import storage
|
||||||
import supervisor
|
import supervisor
|
||||||
|
from adafruit_simplemath import map_range
|
||||||
from digitalio import DigitalInOut, Direction, Pull
|
from digitalio import DigitalInOut, Direction, Pull
|
||||||
from neopixel import NeoPixel
|
from neopixel import NeoPixel
|
||||||
|
|
||||||
|
|
@ -278,11 +278,11 @@ class Peripherals:
|
||||||
|
|
||||||
if volume_level > self.safe_volume_limit:
|
if volume_level > self.safe_volume_limit:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Volume level must be less than or equal to "
|
f"""Volume level must be less than or equal to
|
||||||
+ f"safe_volume_limit: {self.safe_volume_limit}. "
|
safe_volume_limit: {self.safe_volume_limit}.
|
||||||
+ f"Using higher values could damage speakers. "
|
Using higher values could damage speakers.
|
||||||
+ f"To override this limitation pass a value larger {self.safe_volume_limit} "
|
To override this limitation pass a value larger {self.safe_volume_limit}
|
||||||
+ f"for the safe_volume_limit argument of the constructor."
|
for the safe_volume_limit argument of the constructor."""
|
||||||
)
|
)
|
||||||
|
|
||||||
self._volume = volume_level
|
self._volume = volume_level
|
||||||
|
|
@ -316,5 +316,5 @@ class Peripherals:
|
||||||
"""
|
"""
|
||||||
Map the basic volume level to a db value and set it on the DAC.
|
Map the basic volume level to a db value and set it on the DAC.
|
||||||
"""
|
"""
|
||||||
db_val = simpleio.map_range(self._volume, 1, 20, -63, 23)
|
db_val = map_range(self._volume, 1, 20, -63, 23)
|
||||||
self._dac.dac_volume = db_val
|
self._dac.dac_volume = db_val
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,4 @@ adafruit-circuitpython-display-text
|
||||||
adafruit-circuitpython-sd
|
adafruit-circuitpython-sd
|
||||||
adafruit-circuitpython-ntp
|
adafruit-circuitpython-ntp
|
||||||
adafruit-circuitpython-connectionmanager
|
adafruit-circuitpython-connectionmanager
|
||||||
adafruit-circuitpython-simpleio
|
adafruit-circuitpython-simplemath
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue