本文整理汇总了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
示例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()
示例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")
示例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
示例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([])