當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。