Ensure pigpio is set and used as the pin factory.
This commit is contained in:
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user