From cfd452d3a56c8a7970f8e9c8b96978a398b6de2f Mon Sep 17 00:00:00 2001 From: Piv <18462828+Piv200@users.noreply.github.com> Date: Mon, 23 Sep 2019 22:42:12 +0930 Subject: [PATCH] Ensure pigpio is set and used as the pin factory. --- MotorControl/gpiozero/motor_session.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MotorControl/gpiozero/motor_session.py b/MotorControl/gpiozero/motor_session.py index 6a6e1ae..8563a65 100644 --- a/MotorControl/gpiozero/motor_session.py +++ b/MotorControl/gpiozero/motor_session.py @@ -1,12 +1,13 @@ import os from gpiozero import Servo, Device +from gpiozero.pins.pigpio import PiGPIOFactory GPIOZERO_PIN_FACTORY = "piggpio" class Motor: def __init__(self, motor_pin=19): # This may not work properly, should print. - os.environ["GPIOZERO_PIN_FACTORY"] = GPIOZERO_PIN_FACTORY + Device.pin_factory = PiGPIOFactory() print('Using pin factory: ' + Device.pin_factory) # This will say it fails if pigpio daemon is already started, just ignore it. os.system("sudo pigpiod")