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


Python SPI.MSBFIRST属性代码示例

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


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

示例1: __init__

# 需要导入模块: from Adafruit_GPIO import SPI [as 别名]
# 或者: from Adafruit_GPIO.SPI import MSBFIRST [as 别名]
def __init__(self, clk=None, cs=None, do=None, spi=None, gpio=None):
        """Initialize MAX31855 device with software SPI on the specified CLK,
        CS, and DO pins.  Alternatively can specify hardware SPI by sending an
        Adafruit_GPIO.SPI.SpiDev device in the spi parameter.
        """
        self._logger = logging.getLogger('Adafruit_MAX31855.MAX31855')
        self._spi = None
        # Handle hardware SPI
        if spi is not None:
            self._logger.debug('Using hardware SPI')
            self._spi = spi
        elif clk is not None and cs is not None and do is not None:
            self._logger.debug('Using software SPI')
            # Default to platform GPIO if not provided.
            if gpio is None:
                gpio = GPIO.get_platform_gpio()
            self._spi = SPI.BitBang(gpio, clk, None, do, cs)
        else:
            raise ValueError('Must specify either spi for for hardware SPI or clk, cs, and do for softwrare SPI!')
        self._spi.set_clock_hz(5000000)
        self._spi.set_mode(0)
        self._spi.set_bit_order(SPI.MSBFIRST) 
开发者ID:adafruit,项目名称:Adafruit_Python_MAX31855,代码行数:24,代码来源:MAX31855.py

示例2: __init__

# 需要导入模块: from Adafruit_GPIO import SPI [as 别名]
# 或者: from Adafruit_GPIO.SPI import MSBFIRST [as 别名]
def __init__(self, count, clk=None, do=None, spi=None, gpio=None):
        """Initialize set of WS2801/SPI-like addressable RGB LEDs.  Must
        specify the count of pixels, and either an explicit clk (clokc) and do
        (data output) line for software SPI or a spi instance for hardware SPI.
        """
        self._spi = None
        if spi:
            # Handle hardware SPI.
            self._spi = spi
        elif clk and do:
            # Handle software SPI.
            # Default to platform GPIO if not provided.
            if not gpio:
                import Adafruit_GPIO as GPIO
                gpio = GPIO.get_platform_gpio()
            self._spi = SPI.BitBang(gpio, clk, do, None, None)
        else:
            raise ValueError('Must specify either spi for for hardware SPI or clk, and do for software SPI!')
        # Setup SPI interface with up to 20mhz speed.
        self._spi.set_clock_hz(1000000)
        self._spi.set_mode(0)
        self._spi.set_bit_order(SPI.MSBFIRST)
        # Setup buffer for pixel RGB data.
        self._count = count
        self._pixels = [0]*(count*3) 
开发者ID:adafruit,项目名称:Adafruit_Python_WS2801,代码行数:27,代码来源:WS2801.py

示例3: __init__

# 需要导入模块: from Adafruit_GPIO import SPI [as 别名]
# 或者: from Adafruit_GPIO.SPI import MSBFIRST [as 别名]
def __init__(self, clk=None, cs=None, miso=None, mosi=None, spi=None, gpio=None):
        """Initialize MAX31855 device with software SPI on the specified CLK,
        CS, and DO pins.  Alternatively can specify hardware SPI by sending an
        Adafruit_GPIO.SPI.SpiDev device in the spi parameter.
        """
        self._spi = None
        # Handle hardware SPI
        if spi is not None:
            self._spi = spi
        elif clk is not None and cs is not None and miso is not None and mosi is not None:
            # Default to platform GPIO if not provided.
            if gpio is None:
                gpio = GPIO.get_platform_gpio()
            self._spi = SPI.BitBang(gpio, clk, mosi, miso, cs)
        else:
            raise ValueError('Must specify either spi for for hardware SPI or clk, cs, miso, and mosi for software SPI!')
        self._spi.set_clock_hz(1000000)
        self._spi.set_mode(0)
        self._spi.set_bit_order(SPI.MSBFIRST) 
开发者ID:adafruit,项目名称:Adafruit_Python_MCP3008,代码行数:21,代码来源:MCP3008.py

示例4: __init__

# 需要导入模块: from Adafruit_GPIO import SPI [as 别名]
# 或者: from Adafruit_GPIO.SPI import MSBFIRST [as 别名]
def __init__(self, clk=None, cs=None, miso=None, mosi=None, spi=None, gpio=None):
        """Initialize MAX31855 device with software SPI on the specified CLK,
        CS, and DO pins.  Alternatively can specify hardware SPI by sending an
        Adafruit_GPIO.SPI.SpiDev device in the spi parameter.
        """
        self._spi = None
        # Handle hardware SPI
        if spi is not None:
            self._spi = spi
        elif clk is not None and cs is not None and miso is not None and mosi is not None:
            # Default to platform GPIO if not provided.
            if gpio is None:
                gpio = GPIO.get_platform_gpio()
            self._spi = SPI.BitBang(gpio, clk, mosi, miso, cs)
        else:
            raise ValueError('Must specify either spi for for hardware SPI or clk, cs, miso, and mosi for softwrare SPI!')
        #self._spi.set_clock_hz(800000)
        #self._spi.set_clock_hz(1000000)
        self._spi.set_clock_hz(1000000)
        self._spi.set_mode(0)
        self._spi.set_bit_order(SPI.MSBFIRST) 
开发者ID:Qu-Bit-Electronix,项目名称:QB_Nebulae_V2,代码行数:23,代码来源:MCP3208.py

示例5: __init__

# 需要导入模块: from Adafruit_GPIO import SPI [as 别名]
# 或者: from Adafruit_GPIO.SPI import MSBFIRST [as 别名]
def __init__(self, count, clk=None, do=None, spi=None, gpio=None):
        """Initialize set of WS2801/SPI-like addressable RGB LEDs.  Must
        specify the count of pixels, and either an explicit clk (clokc) and do
        (data output) line for software SPI or a spi instance for hardware SPI.
        """
        self._spi = None
        if spi is not None:
            # Handle hardware SPI.
            self._spi = spi
        elif clk is not None and do is not None:
            # Handle software SPI.
            # Default to platform GPIO if not provided.
            if gpio is None:
                import Adafruit_GPIO as GPIO
                gpio = GPIO.get_platform_gpio()
            self._spi = SPI.BitBang(gpio, clk, do, None, None)
        else:
            raise ValueError('Must specify either spi for for hardware SPI or clk, and do for softwrare SPI!')
        # Setup SPI interface with up to 20mhz speed.
        self._spi.set_clock_hz(1000000)
        self._spi.set_mode(0)
        self._spi.set_bit_order(SPI.MSBFIRST)
        # Setup buffer for pixel RGB data.
        self._count = count
        self._pixels = [0]*(count*3) 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:27,代码来源:WS2801.py

示例6: __init__

# 需要导入模块: from Adafruit_GPIO import SPI [as 别名]
# 或者: from Adafruit_GPIO.SPI import MSBFIRST [as 别名]
def __init__(self, dc, spi, rst=None, gpio=None, width=ILI9341_TFTWIDTH,
        height=ILI9341_TFTHEIGHT):
        """Create an instance of the display using SPI communication.  Must
        provide the GPIO pin number for the D/C pin and the SPI driver.  Can
        optionally provide the GPIO pin number for the reset pin as the rst
        parameter.
        """
        self._dc = dc
        self._rst = rst
        self._spi = spi
        self._gpio = gpio
        self.width = width
        self.height = height
        if self._gpio is None:
            self._gpio = GPIO.get_platform_gpio()
        # Set DC as output.
        self._gpio.setup(dc, GPIO.OUT)
        # Setup reset as output (if provided).
        if rst is not None:
            self._gpio.setup(rst, GPIO.OUT)
        # Set SPI to mode 0, MSB first.
        spi.set_mode(0)
        spi.set_bit_order(SPI.MSBFIRST)
        spi.set_clock_hz(64000000)
        # Create an image buffer.
        self.buffer = Image.new('RGB', (width, height)) 
开发者ID:adafruit,项目名称:Adafruit_Python_ILI9341,代码行数:28,代码来源:ILI9341.py

示例7: __init__

# 需要导入模块: from Adafruit_GPIO import SPI [as 别名]
# 或者: from Adafruit_GPIO.SPI import MSBFIRST [as 别名]
def __init__(self, tc_type=MAX31856_T_TYPE, avgsel=0x0, software_spi=None, hardware_spi=None, gpio=None):
        """
        Initialize MAX31856 device with software SPI on the specified CLK,
        CS, and DO pins.  Alternatively can specify hardware SPI by sending an
        SPI.SpiDev device in the spi parameter.

        Args:
            tc_type (1-byte Hex): Type of Thermocouple.  Choose from class variables of the form
                MAX31856.MAX31856_X_TYPE.
            avgsel (1-byte Hex): Type of Averaging.  Choose from values in CR0 table of datasheet.
                Default is single sample.
            software_spi (dict): Contains the pin assignments for software SPI, as defined below:
                clk (integer): Pin number for software SPI clk
                cs (integer): Pin number for software SPI cs
                do (integer): Pin number for software SPI MISO
                di (integer): Pin number for software SPI MOSI
            hardware_spi (SPI.SpiDev): If using hardware SPI, define the connection
        """
        self._logger = logging.getLogger('Adafruit_MAX31856.MAX31856')
        self._spi = None
        self.tc_type = tc_type
        self.avgsel = avgsel
        # Handle hardware SPI
        if hardware_spi is not None:
            self._logger.debug('Using hardware SPI')
            self._spi = hardware_spi
        elif software_spi is not None:
            self._logger.debug('Using software SPI')
            # Default to platform GPIO if not provided.
            if gpio is None:
                gpio = Adafruit_GPIO.get_platform_gpio()
            self._spi = SPI.BitBang(gpio, software_spi['clk'], software_spi['di'],
                                                  software_spi['do'], software_spi['cs'])
        else:
            raise ValueError(
                'Must specify either spi for for hardware SPI or clk, cs, and do for softwrare SPI!')
        self._spi.set_clock_hz(5000000)
        # According to Wikipedia (on SPI) and MAX31856 Datasheet:
        #   SPI mode 1 corresponds with correct timing, CPOL = 0, CPHA = 1
        self._spi.set_mode(1)
        self._spi.set_bit_order(SPI.MSBFIRST)

        self.cr1 = ((self.avgsel << 4) + self.tc_type)

        # Setup for reading continuously with T-Type thermocouple
        self._write_register(self.MAX31856_REG_WRITE_CR0, self.MAX31856_CR0_READ_CONT)
        self._write_register(self.MAX31856_REG_WRITE_CR1, self.cr1) 
开发者ID:johnrbnsn,项目名称:Adafruit_Python_MAX31856,代码行数:49,代码来源:max31856.py


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