feat: cleanup and rework audio system

This commit is contained in:
2020-12-22 16:50:30 +01:00
parent 57b92b2864
commit 56fa2a92a9
12 changed files with 302 additions and 161 deletions

View File

@@ -1,10 +1,12 @@
import atexit
import logging
try:
from RPi import GPIO
except ImportError:
from .mockGpio import GPIO
LOG = logging.getLogger(__name__)
PWM_FREQUENCY = 10_000 # 10 KHz
MOTORS = []
@@ -17,7 +19,7 @@ def setup_gpio():
def cleanup_gpio():
print("cleaning up")
LOG.info("cleaning up")
for motor in MOTORS:
# noinspection PyProtectedMember
motor._stop()
@@ -49,7 +51,7 @@ class DcMotor:
self._set_reverse(val)
absval = abs(val)
if absval > 1:
print(f"clipping {val} to 1")
logging.warning(f"clipping {val} to 1")
absval = 1
self.pwm_enable.ChangeDutyCycle(absval * 100)