当前位置: 首页>>代码示例>>Python>>正文


Python pigpio.OUTPUT属性代码示例

本文整理汇总了Python中pigpio.OUTPUT属性的典型用法代码示例。如果您正苦于以下问题:Python pigpio.OUTPUT属性的具体用法?Python pigpio.OUTPUT怎么用?Python pigpio.OUTPUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在pigpio的用法示例。


在下文中一共展示了pigpio.OUTPUT属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def __init__(self, pi, trigger, echo):
        """
        The class is instantiated with the Pi to use and the
        gpios connected to the trigger and echo pins.
        """
        self.pi = pi
        self._trig = trigger
        self._echo = echo

        self._ping = False
        self._high = None
        self._time = None

        self._triggered = False

        self._trig_mode = pi.get_mode(self._trig)
        self._echo_mode = pi.get_mode(self._echo)

        pi.set_mode(self._trig, pigpio.OUTPUT)
        pi.set_mode(self._echo, pigpio.INPUT)

        self._cb = pi.callback(self._trig, pigpio.EITHER_EDGE, self._cbf)
        self._cb = pi.callback(self._echo, pigpio.EITHER_EDGE, self._cbf)

        self._inited = True 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:27,代码来源:sonar.py

示例2: write

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def write(self, measure):
        # self._in_progress = async.DelayedCall(0.0, self._read_temp)
        # 0 Switch to OUT               ___   18000   ___
        # 1. Pull down for 20ms trigger    \___ //___/
        # 2. Switch to IN               ___  80  ____
        # 3. Wait for 80us ack             \____/
        # 4. Read 40 bits               ___  50  ____________  50  ____ ....
        #    Format is                     \____/ 27=0, 70=1 \____/
        #                                  +----+------------+
        #    and stop bit               ___  50  ___ ....
        #                                  \____/
        #    (just read 41 falling edges...)
        self._in_progress = True
        self._gpio.set_mode(self._pin, pigpio.OUTPUT)
        self._gpio.write(self._pin, 0)
        async.DelayedCall(0.025, self._switch_to_listen_cb)
        self._listen_in_progress = async.DelayedCall(self._listen_timeout, self._listen_failed) 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:19,代码来源:DHT11.py

示例3: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def __init__(self, pi, txgpio, bps=2000):
      """
      Instantiate a transmitter with the Pi, the transmit gpio,
      and the bits per second (bps).  The bps defaults to 2000.
      The bps is constrained to be within MIN_BPS to MAX_BPS.
      """
      self.pi = pi

      self.txbit = (1<<txgpio)

      if bps < MIN_BPS:
         bps = MIN_BPS
      elif bps > MAX_BPS:
         bps = MAX_BPS

      self.mics = int(1000000 / bps)

      self.wave_id = None

      pi.wave_add_new()

      pi.set_mode(txgpio, pigpio.OUTPUT) 
开发者ID:DzikuVx,项目名称:piVirtualWire,代码行数:24,代码来源:piVirtualWire.py

示例4: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def __init__(self, push_button=11, led=4, publish_topic='button'):
        """
        This method initialize the class for operation
        :param push_button: push_button pin
        :param led: led pin
        :param publish_topic: publishing topic
        """

        # initialize the parent
        super(Single, self).__init__(process_name='Single')

        # make the input parameters available to the entire class
        self.push_button = push_button
        self.led = led
        self.publish_topic = publish_topic

        # initialize the GPIO pins using pigpio
        self.pi = pigpio.pi()
        self.pi.set_mode(self.push_button, pigpio.INPUT)
        self.pi.set_pull_up_down(self.push_button, pigpio.PUD_DOWN)
        self.pi.set_mode(led, pigpio.OUTPUT)

        # set a glitch filter to debounce the switch
        self.pi.set_glitch_filter(push_button, 100)

        # set a callback for when the button is pressed
        self.pi.callback(self.push_button, pigpio.EITHER_EDGE,
                         self.button_callback)

        # this will keep the program running forever
        try:
            self.receive_loop()
        except KeyboardInterrupt:
            sys.exit(0) 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:36,代码来源:single.py

示例5: play_tone

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def play_tone(self, topic, payload):
        """
        This method plays a tone on a piezo device connected to the selected
        pin at the frequency and duration requested.
        Frequency is in hz and duration in milliseconds.

        Call set_mode_tone before using this method.
        :param topic: message topic
        :param payload: {"command": "play_tone", "pin": “PIN”, "tag": "TAG",
                         “freq”: ”FREQUENCY”, duration: “DURATION”}
        """
        pin = int(payload['pin'])
        self.pi.set_mode(pin, pigpio.OUTPUT)

        frequency = int(payload['freq'])
        frequency = int((1000 / frequency) * 1000)
        tone = [pigpio.pulse(1 << pin, 0, frequency),
                pigpio.pulse(0, 1 << pin, frequency)]

        self.pi.wave_add_generic(tone)
        wid = self.pi.wave_create()

        if wid >= 0:
            self.pi.wave_send_repeat(wid)
            time.sleep(payload['duration'] / 1000)
            self.pi.wave_tx_stop()
            self.pi.wave_delete(wid) 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:29,代码来源:rpi_gateway.py

示例6: set_mode_digital_output

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def set_mode_digital_output(self, topic, payload):
        """
        This method sets a pin as a digital output pin.
        :param topic: message topic
        :param payload: {"command": "set_mode_digital_output",
                         "pin": PIN, "tag":”TAG” }
        """
        self.pi.set_mode(payload['pin'], pigpio.OUTPUT) 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:10,代码来源:rpi_gateway.py

示例7: set_mode_pwm

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def set_mode_pwm(self, topic, payload):
        """
         This method sets a GPIO pin capable of PWM for PWM operation.
         :param topic: message topic
         :param payload: {"command": "set_mode_pwm", "pin": “PIN”, "tag":”TAG” }
         """
        self.pi.set_mode(payload['pin'], pigpio.OUTPUT) 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:9,代码来源:rpi_gateway.py

示例8: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def __init__(self, *args, **kwargs):

        if 'rx' in kwargs:
            self.is_receiver = True
            self.rx = kwargs['rx']
            del kwargs['rx']
        else:
            self.is_receiver = False

        if 'tx' in kwargs:
            self.is_transmitter = True
            self.tx = kwargs['tx']
            del kwargs['tx']
        else:
            self.is_transmitter = False

        if not self.is_receiver and not self.is_transmitter:
            raise ValueError("Receiver or Transmitter GPIO pin is required")

        self._read_fd, self._write_fd = os.pipe()

        self._pi = pigpio.pi(**kwargs) # Connect to pgpiod
        if self.is_receiver:
            self._pi.set_mode(self.rx, pigpio.INPUT)
            self._pi.set_glitch_filter(self.rx, 400)
            #self._pi.set_noise_filter(self.rx, 400, 400)
        if self.is_transmitter:
            self._pi.set_mode(self.tx, pigpio.OUTPUT)

        self._listener = Thread(target=self._listen)
        self._listener.start() 
开发者ID:bggardner,项目名称:simplisafe-rf,代码行数:33,代码来源:pigpio.py

示例9: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def __init__(self, conf, pi):
        self.conf = conf
        self.currentAngle = 0
        self.releaseTimeout = None
        self.lastPulseWidth = 0
        self.sleeping = False
        self.pi = pi
        pi.set_mode(conf['pin'], pigpio.OUTPUT) 
开发者ID:movidius,项目名称:ncappzoo,代码行数:10,代码来源:servo.py

示例10: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def __init__(self, pin, duration=20, vol=None):
        """
        Args:
            pin (int): Board pin number, converted to BCM on init.
            duration (int, float): duration of open, ms.
            vol (int, float): desired volume of reward in uL, must have computed calibration results, see :method:`~autopilot.core.terminal.Terminal.calibrate_ports`
        """

        # Initialize connection to pigpio daemon
        self.pig = pigpio.pi()
        if not self.pig.connected:
            Exception('No connection to pigpio daemon could be made')

        # Setup port
        self.pin = BOARD_TO_BCM[int(pin)]
        self.pig.set_mode(self.pin, pigpio.OUTPUT)

        # Pigpio has us create waves to deliver timed output
        # Since we typically only use one duration,
        # we make the wave once and only make it again when asked to
        # We start with passed or default duration (ms)
        if vol:
            self.dur_from_vol(vol)

        else:
            self.duration = float(duration)/1000
            #self.wave_id = None
            #self.make_wave() 
开发者ID:wehr-lab,项目名称:autopilot,代码行数:30,代码来源:hardware.py

示例11: init

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def init(self, pin, repeat, **kwargs):
        self._pin = pin 
        self._repeat = repeat & 0xFF
        self._gpio = pigpio.pi()
        self._gpio.set_mode(self._pin, pigpio.OUTPUT) 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:7,代码来源:PIGPIOTX433MHz.py

示例12: init

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def init(self, echo_pin, trigger_pin, **kwargs):
        self._echo_pin = echo_pin
        self._trigger_pin = trigger_pin

        self._gpio = pigpio.pi()
        self._gpio.set_mode(self._trigger_pin, pigpio.OUTPUT)
        self._gpio.set_mode(self._echo_pin, pigpio.INPUT)
        self._gpio.set_pull_up_down(self._echo_pin, pigpio.PUD_DOWN)

        self._elapsed = None
        self._detection = None 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:13,代码来源:PIGPIOSR04.py

示例13: init

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def init(self, pin,frequency, dutycycle, **kwargs):
        self._pin = pin
        self._dutycycle = dutycycle
        self._frequency = frequency
        
        self._gpio = pigpio.pi()
        self._gpio.set_mode(self._pin, pigpio.OUTPUT)
        
        self._gpio.set_PWM_range(self._pin, 100)# pigpio uses default dc range [0, 255]
        self._gpio.set_PWM_frequency(self._pin, self._frequency)
        self._gpio.set_PWM_dutycycle(self._pin, self._dutycycle) 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:13,代码来源:PIGPIOPWM.py

示例14: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import OUTPUT [as 别名]
def __init__(self, pin):
        self.pin = pin
        gpio.set_mode(pin, pigpio.OUTPUT) 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:5,代码来源:gpio.py


注:本文中的pigpio.OUTPUT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。