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


Python GPIO.PUD_OFF属性代码示例

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


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

示例1: __init__

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_OFF [as 别名]
def __init__(self, resolution=(104, 212), cs_pin=CS0_PIN, dc_pin=DC_PIN, reset_pin=RESET_PIN, busy_pin=BUSY_PIN, h_flip=False, v_flip=False):
        self.inky_version = 2
        self.inky_colour = None
        self.resolution = resolution
        self.width, self.height = resolution

        self.buffer = numpy.zeros((self.height, self.width), dtype=numpy.uint8)

        self.dc_pin = dc_pin
        self.reset_pin = reset_pin
        self.busy_pin = busy_pin
        self.cs_pin = cs_pin
        self.h_flip = h_flip
        self.v_flip = v_flip

        self.update_x1 = 0
        self.update_x2 = self.width
        self.update_y1 = 0
        self.update_y2 = self.height

        self.partial_mode = False
        self.partial_config = []
        self.border = 0b00000000

        GPIO.setup(self.dc_pin, GPIO.OUT, initial=GPIO.LOW, pull_up_down=GPIO.PUD_OFF)
        GPIO.setup(self.reset_pin, GPIO.OUT, initial=GPIO.HIGH, pull_up_down=GPIO.PUD_OFF)
        GPIO.setup(self.busy_pin, GPIO.IN, pull_up_down=GPIO.PUD_OFF)

        GPIO.output(self.reset_pin, GPIO.LOW)
        time.sleep(0.1)
        GPIO.output(self.reset_pin, GPIO.HIGH)
        time.sleep(0.1)

        if GPIO.input(self.busy_pin) == 1:
            self.set_version(1)
            self.palette = (BLACK, WHITE, RED)
        elif GPIO.input(self.busy_pin) == 0:
            self.set_version(2)
            self.palette = (WHITE, BLACK, RED)
        else:
            self.set_version(2)
            self.palette = (WHITE, BLACK, RED)

        self._spi = spidev.SpiDev()
        self._spi.open(0, self.cs_pin)
        self._spi.max_speed_hz = 488000

        atexit.register(self._display_exit) 
开发者ID:pimoroni,项目名称:inky-phat,代码行数:50,代码来源:inky212x104.py

示例2: _configure_gpio

# 需要导入模块: from RPi import GPIO [as 别名]
# 或者: from RPi.GPIO import PUD_OFF [as 别名]
def _configure_gpio(self):
        if not self._hasGPIO:
            self._logger.error("RPi.GPIO is required.")
            return
        
        self._logger.info("Running RPi.GPIO version %s" % GPIO.VERSION)
        if GPIO.VERSION < "0.6":
            self._logger.error("RPi.GPIO version 0.6.0 or greater required.")
        
        GPIO.setwarnings(False)

        for pin in self._configuredGPIOPins:
            self._logger.debug("Cleaning up pin %s" % pin)
            try:
                GPIO.cleanup(self._gpio_get_pin(pin))
            except (RuntimeError, ValueError) as e:
                self._logger.error(e)
        self._configuredGPIOPins = []

        if GPIO.getmode() is None:
            if self.GPIOMode == 'BOARD':
                GPIO.setmode(GPIO.BOARD)
            elif self.GPIOMode == 'BCM':
                GPIO.setmode(GPIO.BCM)
            else:
                return
        
        if self.sensingMethod == 'GPIO':
            self._logger.info("Using GPIO sensing to determine PSU on/off state.")
            self._logger.info("Configuring GPIO for pin %s" % self.senseGPIOPin)

            if self.senseGPIOPinPUD == 'PULL_UP':
                pudsenseGPIOPin = GPIO.PUD_UP
            elif self.senseGPIOPinPUD == 'PULL_DOWN':
                pudsenseGPIOPin = GPIO.PUD_DOWN
            else:
                pudsenseGPIOPin = GPIO.PUD_OFF
    
            try:
                GPIO.setup(self._gpio_get_pin(self.senseGPIOPin), GPIO.IN, pull_up_down=pudsenseGPIOPin)
                self._configuredGPIOPins.append(self.senseGPIOPin)
            except (RuntimeError, ValueError) as e:
                self._logger.error(e)
        
        if self.switchingMethod == 'GPIO':
            self._logger.info("Using GPIO for On/Off")
            self._logger.info("Configuring GPIO for pin %s" % self.onoffGPIOPin)
            try:
                if not self.invertonoffGPIOPin:
                    initial_pin_output=GPIO.LOW
                else:
                    initial_pin_output=GPIO.HIGH
                GPIO.setup(self._gpio_get_pin(self.onoffGPIOPin), GPIO.OUT, initial=initial_pin_output)
                self._configuredGPIOPins.append(self.onoffGPIOPin)
            except (RuntimeError, ValueError) as e:
                self._logger.error(e) 
开发者ID:kantlivelong,项目名称:OctoPrint-PSUControl,代码行数:58,代码来源:__init__.py


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