Ensure pigpio is set and used as the pin factory.

This commit is contained in:
Piv
2019-09-23 22:42:12 +09:30
parent 80c33d2b48
commit cfd452d3a5

View File

@@ -1,12 +1,13 @@
import os import os
from gpiozero import Servo, Device from gpiozero import Servo, Device
from gpiozero.pins.pigpio import PiGPIOFactory
GPIOZERO_PIN_FACTORY = "piggpio" GPIOZERO_PIN_FACTORY = "piggpio"
class Motor: class Motor:
def __init__(self, motor_pin=19): def __init__(self, motor_pin=19):
# This may not work properly, should print. # 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) print('Using pin factory: ' + Device.pin_factory)
# This will say it fails if pigpio daemon is already started, just ignore it. # This will say it fails if pigpio daemon is already started, just ignore it.
os.system("sudo pigpiod") os.system("sudo pigpiod")