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


Python GPIO.RISING属性代码示例

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


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

示例1: startKeyEvent

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def startKeyEvent(self):
        print('Start Key Event Catcher')
        # Add return key to interrupt callback
        pins = [27, 23, 4, 17, 22, 5, 6]  # [L, R, C, U, D, A, B]
        # Add each to to key detect
        for i in pins:
            GPIO.add_event_detect(i, GPIO.RISING)

        # GPIO.add_event_callback(27, callback=self._semitone_down)
        # GPIO.add_event_callback(23, callback=self._semitone_up)
        # GPIO.add_event_callback(4, callback=self._reset_change)
        # GPIO.add_event_callback(17, callback=self._octave_up)
        # GPIO.add_event_callback(22, callback=self._octave_down)
        GPIO.add_event_callback(5, callback=self.stopInterruptCallBack)
        # GPIO.add_event_callback(6, callback=self.stopInterruptCallBack)

        # GPIO.add_event_callback(27, callback=self.leftKey)
        # GPIO.add_event_callback(23, callback=self.rightKey)
        # GPIO.add_event_callback(4, callback=self.centerKey)
        # GPIO.add_event_callback(17, callback=self.upKey)
        # GPIO.add_event_callback(22, callback=self.downKay)
        # GPIO.add_event_callback(5, callback=self.aKey)
        # GPIO.add_event_callback(6, callback=self.bKey) 
开发者ID:adwuard,项目名称:OP_Manager,代码行数:25,代码来源:Midi.py

示例2: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def __init__(self,
                 channel,
                 polarity=GPIO.FALLING,
                 pull_up_down=GPIO.PUD_UP,
                 debounce_time=0.08):
        if polarity not in [GPIO.FALLING, GPIO.RISING]:
            raise ValueError(
                'polarity must be one of: GPIO.FALLING or GPIO.RISING')

        self.channel = int(channel)
        self.polarity = polarity
        self.expected_value = polarity == GPIO.RISING
        self.debounce_time = debounce_time

        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(channel, GPIO.IN, pull_up_down=pull_up_down)

        self.callback = None 
开发者ID:gigagenie,项目名称:ai-makers-kit,代码行数:21,代码来源:_button.py

示例3: start_filament_detection

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def start_filament_detection(self):
        self.stop_filament_detection()
        try:
            for filament_sensor in list(filter(
                    lambda item: item['input_type'] == 'gpio' and item['action_type'] == 'printer_control' and item[
                        'printer_action'] == 'filament', self.rpi_inputs)):
                edge = GPIO.RISING if filament_sensor['edge'] == 'rise' else GPIO.FALLING
                if GPIO.input(self.to_int(filament_sensor['gpio_pin'])) == (edge == GPIO.RISING):
                    self._printer.pause_print()
                    self._logger.info("Started printing with no filament.")
                else:
                    self.last_filament_end_detected.append(dict(index_id=filament_sensor['index_id'], time=0))
                    self._logger.info("Adding GPIO event detect on pin %s with edge: %s", filament_sensor['gpio_pin'],
                        edge)
                    GPIO.add_event_detect(self.to_int(filament_sensor['gpio_pin']), edge,
                        callback=self.handle_filamment_detection, bouncetime=200)
        except Exception as ex:
            self.log_error(ex) 
开发者ID:vitormhenrique,项目名称:OctoPrint-Enclosure,代码行数:20,代码来源:__init__.py

示例4: main

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def main():
    # report rail info
    payload = {
        "ip": os.popen('ip addr show eth0').read().split("inet ")[1].split("/")[0]
    }
    mqttClient.publish(DEVICE_INFO_TOPIC, json.dumps(payload), 0)
    # open rail for default
    move_servo(RAIL_OPEN)

    # add event handler for buttons
    GPIO.add_event_detect(GPIO_BTN_OPEN, GPIO.RISING, callback=btn_servo_pressed, bouncetime=BOUNCE_TIME)
    GPIO.add_event_detect(GPIO_BTN_CLOSE, GPIO.RISING, callback=btn_servo_pressed, bouncetime=BOUNCE_TIME)
    GPIO.add_event_detect(GPIO_BTN_POS1, GPIO.RISING, callback=btn_robot_pressed, bouncetime=BOUNCE_TIME)
    GPIO.add_event_detect(GPIO_BTN_POS2, GPIO.RISING, callback=btn_robot_pressed, bouncetime=BOUNCE_TIME)
    GPIO.add_event_detect(GPIO_BTN_POS3, GPIO.RISING, callback=btn_robot_pressed, bouncetime=BOUNCE_TIME)

    # wait for events
    while True:
        time.sleep(1) 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:21,代码来源:main.py

示例5: pushbutton

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def pushbutton(self):
        if GPIOcontrol:
            while mutestopbutton:
                time.sleep(.1)
                if GPIO.event_detected(stoppushbutton):
                    GPIO.remove_event_detect(stoppushbutton)
                    now = time.time()
                    count = 1
                    GPIO.add_event_detect(stoppushbutton,GPIO.RISING)
                    while time.time() < now + 1:
                         if GPIO.event_detected(stoppushbutton):
                             count +=1
                             time.sleep(.25)
                    if count == 2:
                        self.buttonsinglepress()
                        GPIO.remove_event_detect(stoppushbutton)
                        GPIO.add_event_detect(stoppushbutton,GPIO.FALLING)
                    elif count == 3:
                        self.buttondoublepress()
                        GPIO.remove_event_detect(stoppushbutton)
                        GPIO.add_event_detect(stoppushbutton,GPIO.FALLING)
                    elif count == 4:
                        self.buttontriplepress()
                        GPIO.remove_event_detect(stoppushbutton)
                        GPIO.add_event_detect(stoppushbutton,GPIO.FALLING) 
开发者ID:shivasiddharth,项目名称:GassistPi,代码行数:27,代码来源:main.py

示例6: setup_sensor

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def setup_sensor(self):
		try:
			GPIO.setup(self.gpio, GPIO.IN)
			GPIO.add_event_detect(self.gpio, GPIO.RISING, callback=self.cb_alarm, bouncetime=self.bouncetime)
		except ValueError as ve: # GPIO pin number or bouncetime is not in valid range
			logging.error("GPIOSensor: The given pin number or bouncetime is not in a valid range: %s" % ve)
			return
		logging.debug("GPIOSensor: Registered sensor at pin %s!" % self.gpio) 
开发者ID:SecPi,项目名称:SecPi,代码行数:10,代码来源:gpio_sensor.py

示例7: prepare_irq_pin

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def prepare_irq_pin(self, pin_id): 
        pin = self.prepare_pin(pin_id, GPIO.IN) 
        if pin:       
            pin.set_handler_for_irq_on_rising_edge = \
                lambda handler: GPIO.add_event_detect(pin.pin_id,
                                                      GPIO.RISING,
                                                      callback = handler)  
            pin.detach_irq = lambda : GPIO.remove_event_detect(pin.pin_id) 
            return pin 
开发者ID:Wei1234c,项目名称:SX127x_driver_for_MicroPython_on_ESP8266,代码行数:11,代码来源:controller_rpi.py

示例8: prepare_irq_pin

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def prepare_irq_pin(self, pin_id):
        pin = self.prepare_pin(pin_id, GPIO.IN)
        if pin:
            pin.set_handler_for_irq_on_rising_edge = \
                lambda handler: GPIO.add_event_detect(pin.pin_id,
                                                      GPIO.RISING,
                                                      callback = handler)
            pin.detach_irq = lambda: GPIO.remove_event_detect(pin.pin_id)
            return pin 
开发者ID:Wei1234c,项目名称:SX127x_driver_for_MicroPython_on_ESP8266,代码行数:11,代码来源:controller_rpi.py

示例9: initialize_gpio

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def initialize_gpio():
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(Gmail.PIN, GPIO.OUT)
    GPIO.setup(CHECK_NOW_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    GPIO.add_event_detect(CHECK_NOW_PIN, GPIO.RISING, callback=check_mail_now, bouncetime=1000) 
开发者ID:grantwinney,项目名称:52-Weeks-of-Pi,代码行数:7,代码来源:NewEmailIndicator.py

示例10: user_shutdown_setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def user_shutdown_setup(shutdown_pin):
    # setup the pin to check the shutdown switch - use the internal pull down resistor
    GPIO.setup(shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

    # create a trigger for the shutdown switch
    GPIO.add_event_detect(shutdown_pin, GPIO.RISING, callback=user_shutdown, bouncetime=1000)

# User has pressed shutdown button - initiate a clean shutdown 
开发者ID:craic,项目名称:pi_power,代码行数:10,代码来源:pi_power.py

示例11: setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def setup():
	GPIO.setmode(GPIO.BCM)       # Numbers GPIOs by physical location
	GPIO.setup(SigPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)    # Set Pin's mode is input, and pull up to high level(3.3V)
	GPIO.add_event_detect(SigPin, GPIO.RISING, callback=count) # wait for rasing 
开发者ID:sunfounder,项目名称:SunFounder_Super_Kit_V3.0_for_Raspberry_Pi,代码行数:6,代码来源:09_ne555.py

示例12: setup

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def setup():
	GPIO.setmode(GPIO.BCM)
	GPIO.setwarnings(False)
	GPIO.setup(SDI, GPIO.OUT, initial=GPIO.LOW)
	GPIO.setup(RCLK, GPIO.OUT, initial=GPIO.LOW)
	GPIO.setup(SRCLK, GPIO.OUT, initial=GPIO.LOW)
	GPIO.setup(TouchPin, GPIO.IN, pull_up_down = GPIO.PUD_UP)
	GPIO.add_event_detect(TouchPin, GPIO.RISING, callback = randomISR, bouncetime = 20)

# Shift the data to 74HC595 
开发者ID:sunfounder,项目名称:SunFounder_Super_Kit_V3.0_for_Raspberry_Pi,代码行数:12,代码来源:14_dice.py

示例13: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def __init__(self, pin):
        super().__init__()
        GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        self.pin = pin
        self.pressed = GPIO.input(self.pin) == GPIO.LOW
        # Using a timer to Poll
        #self.timer = qtc.QTimer(interval=50, timeout=self.check)
        #self.timer.start()

        # Using a threaded event handler
        GPIO.add_event_detect(
            self.pin,
            GPIO.RISING,
            callback=self.on_event_detect) 
开发者ID:PacktPublishing,项目名称:Mastering-GUI-Programming-with-Python,代码行数:16,代码来源:temp_humid_display.py

示例14: initpins

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def initpins(self):
#   GPIO.setwarnings(False)
#   GPIO.setmode(GPIO.BCM)
   for po in self.colpins:
    GPIO.setup(po,GPIO.OUT)
   for pi in self.rowpins:
    GPIO.setup(pi,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
    try:
     GPIO.remove_event_detect(pi)
    except:
     pass
    time.sleep(0.05)
    GPIO.add_event_detect(pi,GPIO.RISING, callback=self.inthandler,bouncetime=200) 
开发者ID:enesbcs,项目名称:rpieasy,代码行数:15,代码来源:keypad.py

示例15: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import RISING [as 别名]
def __init__(self, pin, name='Control',key=None, resistor=None, edge_detection=None, debounce=None):
		self.pin = pin
		self.name = name
		self.key = key.replace(" ", "_").lower() if key is not None else self.name.replace(" ", "_").lower()
		self.gpio = GPIO
		self.debounce = debounce if debounce is not None else None

		if resistor is not None:
			if resistor == "up" or resistor == GPIO.PUD_UP:
				self.resistor = GPIO.PUD_UP
			elif resistor == "down" or resistor == GPIO.PUD_DOWN:
				self.resistor = GPIO.PUD_DOWN
		else:
			self.resistor = resistor

		if edge_detection is not None:
			if edge_detection == "falling" or edge_detection == GPIO.FALLING:
				self.edge_detection = GPIO.FALLING
			elif edge_detection == "rising" or edge_detection == GPIO.RISING:
				self.edge_detection = GPIO.RISING
			elif edge_detection == "both" or edge_detection == GPIO.BOTH:
				self.edge_detection = GPIO.BOTH
		else:
			self.edge_detection = None

		return 
开发者ID:mudpi,项目名称:mudpi-core,代码行数:28,代码来源:control.py


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