當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。