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


Python SPI.MASTER属性代码示例

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


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

示例1: __init__

# 需要导入模块: from machine import SPI [as 别名]
# 或者: from machine.SPI import MASTER [as 别名]
def __init__(self, sck, mosi, miso, rst, cs):

		self.sck = Pin(sck, Pin.OUT)
		self.mosi = Pin(mosi, Pin.OUT)
		self.miso = Pin(miso)
		self.rst = Pin(rst, Pin.OUT)
		self.cs = Pin(cs, Pin.OUT)

		self.rst.value(0)
		self.cs.value(1)
		
		board = uname()[0]

		if board == 'WiPy' or board == 'LoPy' or board == 'FiPy':
			self.spi = SPI(0)
			self.spi.init(SPI.MASTER, baudrate=1000000, pins=(self.sck, self.mosi, self.miso))
		elif board == 'esp8266':
			self.spi = SPI(baudrate=100000, polarity=0, phase=0, sck=self.sck, mosi=self.mosi, miso=self.miso)
			self.spi.init()
		else:
			raise RuntimeError("Unsupported platform")

		self.rst.value(1)
		self.init() 
开发者ID:wendlers,项目名称:micropython-mfrc522,代码行数:26,代码来源:mfrc522.py

示例2: __init__

# 需要导入模块: from machine import SPI [as 别名]
# 或者: from machine.SPI import MASTER [as 别名]
def __init__(self, reset, dc, busy, cs, clk, mosi):
        self.reset_pin = reset
        self.reset_pin.mode(Pin.OUT)

        self.dc_pin = dc
        self.dc_pin.mode(Pin.OUT)

        self.busy_pin = busy
        self.busy_pin.mode(Pin.IN)

        self.cs_pin = cs
        self.cs_pin.mode(Pin.OUT)
        self.cs_pin.pull(Pin.PULL_UP)

        self.spi = SPI(0, mode=SPI.MASTER, baudrate=2000000, polarity=0, phase=0, pins=(clk, mosi, None))

        self.width = EPD_WIDTH
        self.height = EPD_HEIGHT
        self.rotate = ROTATE_0 
开发者ID:ayoy,项目名称:micropython-waveshare-epd,代码行数:21,代码来源:epd1in54b.py

示例3: __init__

# 需要导入模块: from machine import SPI [as 别名]
# 或者: from machine.SPI import MASTER [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.SPI.MASTER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。