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


Python pigpio.INPUT属性代码示例

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


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

示例1: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [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: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [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

示例3: set_mode_digital_input

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [as 别名]
def set_mode_digital_input(self, topic, payload):
        """
        This method sets a pin as digital input.
        :param topic: message topic
        :param payload: {"command": "set_mode_digital_input", "pin": “PIN”, "tag":”TAG” }
        """
        pin = payload['pin']
        entry = self.pins_dictionary[pin]
        entry['mode'] = self.DIGITAL_INPUT_MODE

        self.pi.set_glitch_filter(pin, 20000)
        self.pi.set_mode(pin, pigpio.INPUT)
        self.pi.set_pull_up_down(pin, pigpio.PUD_DOWN)

        self.pi.callback(pin, pigpio.EITHER_EDGE, self.input_callback) 
开发者ID:MrYsLab,项目名称:python_banyan,代码行数:17,代码来源:rpi_gateway.py

示例4: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [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

示例5: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [as 别名]
def __init__(self, pin, pull_ud='U', trigger_ud='D', event=None):
        """
        Args:
            pin (int): Board-numbered pin, converted to BCM numbering during instantiation.
            pull_ud ('U', 'D', 'B'): Should this beambreak be pulled up or down?
            trigger_ud ('U', 'D', 'B'): Is the trigger event up (low to high) or down (high to low)?
            event (:class:`threading.Event`): We can be passed an Event object if we want to handle
                stage transition logic here instead of the :class:`.Task` object, as is typical.
        """

        self.trigger = True
        self.type = 'POKES'
        self.input = True

        # Make pigpio instance
        self.pig = pigpio.pi()

        # Convert pin from board to bcm numbering
        self.pin = BOARD_TO_BCM[int(pin)]

        try:
            self.pull_ud = PULL_MAP[pull_ud]
        except KeyError:
            Exception('pull_ud must be one of {}, was given {}'.format(PULL_MAP.keys(), pull_ud))

        try:
            self.trigger_ud = TRIGGER_MAP[trigger_ud]
        except KeyError:
            Exception('trigger_ud must be one of {}, was given {}'.format(TRIGGER_MAP.keys(), trigger_ud))

        # We can be passed a threading.Event object if we want to handle stage logic here
        # rather than in the parent as is typical.
        self.event = event

        # List to store callback handles
        self.callbacks = []

        # Setup pin
        self.pig.set_mode(self.pin, pigpio.INPUT)
        self.pig.set_pull_up_down(self.pin, self.pull_ud) 
开发者ID:wehr-lab,项目名称:autopilot,代码行数:42,代码来源:hardware.py

示例6: init

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [as 别名]
def init(self, switch_pin=None, clock_pin=None, data_pin=None, **kwargs):
        self._switch_pin = switch_pin
        self._clock_pin = clock_pin
        self._data_pin = data_pin
        self._state = 0
        self._gpio = pigpio.pi()
        self._data = None
        self._clock = None
        self._switch = None

        if self._switch_pin:
            self._gpio.set_glitch_filter(self._switch_pin, 2000)
            self._gpio.set_mode(self._switch_pin, pigpio.INPUT)
            self._gpio.set_pull_up_down(self._switch_pin, pigpio.PUD_UP)
            self._switch = self._gpio.callback(self._switch_pin, pigpio.EITHER_EDGE, self._switch_cb)

        if self._data_pin:
            self._gpio.set_mode(self._data_pin, pigpio.INPUT)
            self._data = self._gpio.callback(self._data_pin, pigpio.EITHER_EDGE, self._data_cb)

        if self._clock_pin:
            self._gpio.set_mode(self._clock_pin, pigpio.INPUT)
            self._clock = self._gpio.callback(self._clock_pin, pigpio.EITHER_EDGE, self._clock_cb)

        if self._data_pin and self._clock_pin:
            self._state = 2*self._gpio.read(self._clock_pin) + self._gpio.read(self._data_pin)

        self._values = [] 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:30,代码来源:PIGPIOKY040.py

示例7: init

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [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

示例8: init

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [as 别名]
def init(self, pin, **kwargs):
        self._pin = pin
        self._in_progress = False
        self._humidity = None
        self._gpio = pigpio.pi()
        self._gpio.set_pull_up_down(self._pin, pigpio.PUD_OFF)
        self._gpio.set_mode(self._pin, pigpio.INPUT)
        self._read_data_handle = None
        self._edge_ticks = None
        self._listen_timeout = 1.0
        self._listen_in_progress = None
        self._humidity_last_reading = 0.0 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:14,代码来源:DHT11.py

示例9: _switch_to_listen_cb

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [as 别名]
def _switch_to_listen_cb(self):
        self._gpio.write(self._pin, 1)
        self._edge_ticks = []
        self._gpio.set_mode(self._pin, pigpio.INPUT)
        self._read_data_handle = self._gpio.callback(self._pin, pigpio.FALLING_EDGE, self._read_data_cb) 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:7,代码来源:DHT11.py

示例10: init

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [as 别名]
def init(self, pin, direction, pull=None, edge=None, bouncetime=None, **kwargs):
        self._values = []
        self._pin = pin
        self._direction = direction
        self._debounce = 1000*bouncetime if bouncetime else None # bouncetime is ms, pigpio uses us
        self._edge = edge
        self._gpio = pigpio.pi()
        self._cb = None
        
        try :
            mode = self.MODE[direction.lower()]
        except KeyError:
            raise Exception("Unknown direction '{}', should be IN, OUT".format(direction))
        
        if mode == pigpio.INPUT:
            try:
                pud = self.PULL[pull.lower()] if pull else pigpio.PUD_OFF
            except KeyError:
                raise Exception("Unknown pull '{}', should be UP, DOWN, OFF".format(pull))
            self._gpio.set_pull_up_down(pin, pud)
            if self._debounce:
                self._gpio.set_glitch_filter(pin, self._debounce)
            
        self._gpio.set_mode(pin, mode)


        if edge is not None:
            try:
                detect = self.EDGE[edge.lower()]
            except KeyError:
                raise Exception("Unknown edge '{}', should be RISING, FALLING, BOTH")
            self._cb = self._gpio.callback(pin, detect, self._edge_cb) 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:34,代码来源:PIGPIOPin.py

示例11: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [as 别名]
def __init__(self, pi, gpio_0, gpio_1, callback, bit_timeout=5):
        """
        Instantiate with the pi, gpio for 0 (green wire), the gpio for 1
        (white wire), the callback function, and the bit timeout in
        milliseconds which indicates the end of a code.

        The callback is passed the code length in bits and the value.
        """

        self.pi = pi
        self.gpio_0 = gpio_0
        self.gpio_1 = gpio_1

        self.callback = callback

        self.bit_timeout = bit_timeout

        self.in_code = False

        self.pi.set_mode(gpio_0, pigpio.INPUT)
        self.pi.set_mode(gpio_1, pigpio.INPUT)

        self.pi.set_pull_up_down(gpio_0, pigpio.PUD_UP)
        self.pi.set_pull_up_down(gpio_1, pigpio.PUD_UP)

        self.cb_0 = self.pi.callback(gpio_0, pigpio.FALLING_EDGE, self._cb)
        self.cb_1 = self.pi.callback(gpio_1, pigpio.FALLING_EDGE, self._cb) 
开发者ID:linuz,项目名称:LongRangeReader,代码行数:29,代码来源:lrr_wiegand_listener.py

示例12: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import INPUT [as 别名]
def __init__(self, pi, rxgpio, bps=2000):
      """
      Instantiate a receiver with the Pi, the receive 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.rxgpio = rxgpio

      self.messages = []
      self.bad_CRC = 0

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

      slack = 0.20
      self.mics = int(1000000 / bps)
      slack_mics = int(slack * self.mics)
      self.min_mics = self.mics - slack_mics       # Shortest legal edge.
      self.max_mics = (self.mics + slack_mics) * 4 # Longest legal edge.

      self.timeout =  8 * self.mics / 1000 # 8 bits time in ms.
      if self.timeout < 8:
         self.timeout = 8

      self.last_tick = None
      self.good = 0
      self.bits = 0
      self.token = 0
      self.in_message = False
      self.message = [0]*(MAX_MESSAGE_BYTES+_CTL)
      self.message_len = 0
      self.byte = 0

      pi.set_mode(rxgpio, pigpio.INPUT)

      self.cb = pi.callback(rxgpio, pigpio.EITHER_EDGE, self._cb) 
开发者ID:DzikuVx,项目名称:piVirtualWire,代码行数:41,代码来源:piVirtualWire.py


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