Exemplo n.º 1
0
 def __init__(self, in1, in2, pwm):
     self._in1 = DigitalOutputDevice(pin=in1)
     self._in2 = DigitalOutputDevice(pin=in2)
     self._pwm = PWMOutputDevice(pin=pwm)
     self._speed = 0
     # self._direction = None
     super(Motor, self).__init__()
Exemplo n.º 2
0
    def __init__(self, pwmL=19, forwardL=22, backwardL=27, pin_factory=None):

        super(MotorL,
              self).__init__(pwmL=PWMOutputDevice(pwmL,
                                                  pin_factory=pin_factory),
                             fwdL=DigitalOutputDevice(forwardL,
                                                      pin_factory=pin_factory),
                             revL=DigitalOutputDevice(backwardL,
                                                      pin_factory=pin_factory),
                             _order=('pwmL', 'fwdL', 'revL'),
                             pin_factory=pin_factory)
Exemplo n.º 3
0
    def __init__(self, pwmR=18, forwardR=24, backwardR=23, pin_factory=None):

        super(MotorR,
              self).__init__(pwmR=PWMOutputDevice(pwmR,
                                                  pin_factory=pin_factory),
                             fwdR=DigitalOutputDevice(forwardR,
                                                      pin_factory=pin_factory),
                             revR=DigitalOutputDevice(backwardR,
                                                      pin_factory=pin_factory),
                             _order=('pwmR', 'fwdR', 'revR'),
                             pin_factory=pin_factory)
Exemplo n.º 4
0
	def __init__(self, output_one = None, output_two = None, pwm = None,
					enable = None, pin_factory = None):
		if not all (p is not None for p in [output_one, output_two, pwm]):
			raise GPIOPinMissing(
				'output_one, output_two, and pwm must be provided'
				)
		devices = OrderedDict((
			('output_one_device', DigitalOutputDevice(output_one)),
			('output_two_device', DigitalOutputDevice(output_two)),
			('pwm_device', PWMOutputDevice(pwm)),
		))
		if enable is not None:
			devices['enable_device'] = DigitalOutputDevice(enable,
														   initial_value = True)
		super(TB6612FNG, self).__init__(_order=devices.keys(), **devices)
Exemplo n.º 5
0
 def __init__(self):
     """
     Constructor
     """
     self._channels = []
     self._logger = logging.getLogger(LOG_ADSYREN)
     self._is_alerting = False
     self._output = DigitalOutputDevice(pin=SYREN_OUT)
Exemplo n.º 6
0
    def __init__(self,
                 left=None,
                 right=None,
                 standby: int = None,
                 enable=True,
                 pin_factory=None,
                 *args):
        # *args is a hack to ensure a useful message is shown when pins are
        # supplied as sequential positional arguments e.g. 2, 3, 4, 5
        if not isinstance(left, tuple) or not isinstance(right, tuple):
            raise GPIOPinMissing('left and right motor pins must be given as '
                                 'tuples')

        if standby:
            print('Standby high')
            self.standby = DigitalOutputDevice(pin=standby)
            self.standby.on()

        super(Robot, self).__init__(
            left_motor=Motor(*left),
            right_motor=Motor(*right),
            _order=('left_motor', 'right_motor'),
            # pin_factory=pin_factory
        )
Exemplo n.º 7
0
#!/usr/bin/env python3
from time import sleep
from gpiozero.output_devices import DigitalOutputDevice

#
# Relay is hooked up to share power with signal line
# Load is hooked up to Normal-Open.
#

def blink_sync(relay, sleep_time):
  # DigitalOutputDevice.blink creates a thread, we need synchronous
  # execution; use .on() and .off() with time.sleep() instead
  relay.on()
  sleep(sleep_time)
  relay.off()

# This object instantiation does not toggle the garage door opener
# at creation time of the object; other configurations cause the
# relay to switch and thus unintentionally toggle the garage door opener
relay = DigitalOutputDevice('GPIO4', True, False)
blink_sync(relay, 0.4)