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


Python pigpio.EITHER_EDGE属性代码示例

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


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

示例1: __init__

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

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import EITHER_EDGE [as 别名]
def _listen(self):
        if not self.is_receiver:
            raise RuntimeError("Receiver not configured")
        while True:
            self._rx_done = False
            self._rx_buffer = ''
            self._rx_t = None
            self._rx_preamble_low = False
            self._rx_preamble_high = False
            self._rx_sync_buffer = ''
            cb = self._pi.callback(self.rx, pigpio.EITHER_EDGE, self._listen_cbf)
            while not self._rx_done:
                pass
            cb.cancel()
            try:
                decoded = self.decode(self._rx_buffer)
                #print("Raw: " + "".join(map("{:02X}".format, decoded)))
            except DecodeError as e:
                print(str(e), file=stderr)
                continue
            os.write(self._write_fd, decoded) 
开发者ID:bggardner,项目名称:simplisafe-rf,代码行数:23,代码来源:pigpio.py

示例3: __init__

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

示例4: set_mode_digital_input

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

示例5: init

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

示例6: __init__

# 需要导入模块: import pigpio [as 别名]
# 或者: from pigpio import EITHER_EDGE [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.EITHER_EDGE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。