當前位置: 首頁>>代碼示例>>Python>>正文


Python Pin.PULL_DOWN屬性代碼示例

本文整理匯總了Python中machine.Pin.PULL_DOWN屬性的典型用法代碼示例。如果您正苦於以下問題:Python Pin.PULL_DOWN屬性的具體用法?Python Pin.PULL_DOWN怎麽用?Python Pin.PULL_DOWN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在machine.Pin的用法示例。


在下文中一共展示了Pin.PULL_DOWN屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_spi

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import PULL_DOWN [as 別名]
def get_spi(self): 
        spi = None
        id = 1
        
        if config_lora.IS_ESP8266:
            spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0)
            spi.init()
            
        if config_lora.IS_ESP32:
            try:
                if config_lora.SOFT_SPI: id = -1              
                spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0, bits = 8, firstbit = SPI.MSB,
                          sck = Pin(self.PIN_ID_SCK, Pin.OUT, Pin.PULL_DOWN),
                          mosi = Pin(self.PIN_ID_MOSI, Pin.OUT, Pin.PULL_UP),
                          miso = Pin(self.PIN_ID_MISO, Pin.IN, Pin.PULL_UP))
                spi.init()
                    
            except Exception as e:
                print(e)
                if spi: 
                    spi.deinit()
                    spi = None
                reset()  # in case SPI is already in use, need to reset. 
        
        return spi 
開發者ID:Wei1234c,項目名稱:SX127x_driver_for_MicroPython_on_ESP8266,代碼行數:27,代碼來源:controller_esp.py

示例2: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import PULL_DOWN [as 別名]
def __init__(self, gnd, sck, data, vcc):
        self.gnd = gnd
        self.sck = sck
        self.data = data
        self.vcc = vcc

        self.gnd.mode(Pin.OUT)
        self.vcc.mode(Pin.OUT)
        self.sck.mode(Pin.OUT)
        self.data.mode(Pin.OPEN_DRAIN)

        self.gnd.pull(Pin.PULL_DOWN)
        self.vcc.pull(Pin.PULL_UP)
        self.sck.pull(Pin.PULL_DOWN)
        self.data.pull(None)

        self.sleep() 
開發者ID:ayoy,項目名稱:upython-aq-monitor,代碼行數:19,代碼來源:sht1x.py

示例3: pull

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import PULL_DOWN [as 別名]
def pull(self, pul):
        if self.direction is Direction.INPUT:
            self.__pull = pul
            if pul is Pull.UP:
                self._pin.init(mode=Pin.IN, pull=Pin.PULL_UP)
            elif pul is Pull.DOWN:
                if hasattr(Pin, "PULL_DOWN"):
                    self._pin.init(mode=Pin.IN, pull=Pin.PULL_DOWN)
                else:
                    raise NotImplementedError(
                        "{} unsupported on {}".format(Pull.DOWN, board_id)
                    )
            elif pul is None:
                self._pin.init(mode=Pin.IN, pull=None)
            else:
                raise AttributeError("Not a Pull")
        else:
            raise AttributeError("Not an input") 
開發者ID:adafruit,項目名稱:Adafruit_Blinka,代碼行數:20,代碼來源:digitalio.py

示例4: get_spi

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import PULL_DOWN [as 別名]
def get_spi(self):
        spi = None
        id = 1

        if config_lora.IS_ESP8266:
            spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0)
            spi.init()

        if config_lora.IS_ESP32:
            try:
                if config_lora.SOFT_SPI:
                    id = -1
                spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0, bits = 8, firstbit = SPI.MSB,
                          sck = Pin(self.PIN_ID_SCK, Pin.OUT, Pin.PULL_DOWN),
                          mosi = Pin(self.PIN_ID_MOSI, Pin.OUT, Pin.PULL_UP),
                          miso = Pin(self.PIN_ID_MISO, Pin.IN, Pin.PULL_UP))
                spi.init()

            except Exception as e:
                print(e)
                if spi:
                    spi.deinit()
                    spi = None
                reset()  # in case SPI is already in use, need to reset. 

        return spi 
開發者ID:Wei1234c,項目名稱:SX127x_driver_for_MicroPython_on_ESP8266,代碼行數:28,代碼來源:controller_esp.py

示例5: __init__

# 需要導入模塊: from machine import Pin [as 別名]
# 或者: from machine.Pin import PULL_DOWN [as 別名]
def __init__(self, ledNumber=1, brightness=100, dataPin='P22'):
        """
        Params:
        * ledNumber = count of LEDs
        * brightness = light brightness (integer : 0 to 100%)
        * dataPin = pin to connect data channel (LoPy only)
        """
        self.ledNumber = ledNumber
        self.brightness = brightness

        # Prepare SPI data buffer (8 bytes for each color)
        self.buf_length = self.ledNumber * 3 * 8
        self.buf = bytearray(self.buf_length)

        # SPI init
        # Bus 0, 8MHz => 125 ns by bit, 8 clock cycle when bit transfert+2 clock cycle between each transfert
        # => 125*10=1.25 us required by WS2812
        if uname().sysname == 'LoPy':
            self.spi = SPI(0, SPI.MASTER, baudrate=8000000, polarity=0, phase=1, pins=(None, dataPin, None))
             # Enable pull down
	    Pin(dataPin, mode=Pin.OUT, pull=Pin.PULL_DOWN)
	else: #WiPy
            self.spi = SPI(0, SPI.MASTER, baudrate=8000000, polarity=0, phase=1)
            # Enable pull down
            Pin('GP16', mode=Pin.ALT, pull=Pin.PULL_DOWN)
        
        # Turn LEDs off
        self.show([]) 
開發者ID:Oliv4945,項目名稱:wipy-WS2812,代碼行數:30,代碼來源:ws2812.py


注:本文中的machine.Pin.PULL_DOWN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。