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


Python busio.I2C屬性代碼示例

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


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

示例1: clear

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def clear(self):
        """Clears everything displayed on the LCD.

        The following example displays, "Hello, world!", then clears the LCD.

        .. code-block:: python

            import time
            import board
            import busio
            import adafruit_character_lcd.character_lcd_i2c as character_lcd

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)

            lcd.message = "Hello, world!"
            time.sleep(5)
            lcd.clear()
        """
        self._write8(_LCD_CLEARDISPLAY)
        time.sleep(0.003) 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:23,代碼來源:character_lcd.py

示例2: cursor

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def cursor(self):
        """True if cursor is visible. False to stop displaying the cursor.

        The following example shows the cursor after a displayed message:

        .. code-block:: python

            import time
            import board
            import busio
            import adafruit_character_lcd.character_lcd_i2c as character_lcd

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)

            lcd.cursor = True
            lcd.message = "Cursor! "
            time.sleep(5)

        """
        return self.displaycontrol & _LCD_CURSORON == _LCD_CURSORON 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:23,代碼來源:character_lcd.py

示例3: blink

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def blink(self):
        """
        Blink the cursor. True to blink the cursor. False to stop blinking.

        The following example shows a message followed by a blinking cursor for five seconds.

        .. code-block:: python

            import time
            import board
            import busio
            import adafruit_character_lcd.character_lcd_i2c as character_lcd

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)

            lcd.blink = True
            lcd.message = "Blinky cursor!"
            time.sleep(5)
            lcd.blink = False
        """
        return self.displaycontrol & _LCD_BLINKON == _LCD_BLINKON 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:24,代碼來源:character_lcd.py

示例4: display

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def display(self):
        """
        Enable or disable the display. True to enable the display. False to disable the display.

        The following example displays, "Hello, world!" on the LCD and then turns the display off.

        .. code-block:: python

            import time
            import board
            import busio
            import adafruit_character_lcd.character_lcd_i2c as character_lcd

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)

            lcd.message = "Hello, world!"
            time.sleep(5)
            lcd.display = False
        """
        return self.displaycontrol & _LCD_DISPLAYON == _LCD_DISPLAYON 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:23,代碼來源:character_lcd.py

示例5: message

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def message(self):
        """Display a string of text on the character LCD.
        Start position is (0,0) if cursor_position is not set.
        If cursor_position is set, message starts at the set
        position from the left for left to right text and from
        the right for right to left text. Resets cursor column
        and row to (0,0) after displaying the message.

        The following example displays, "Hello, world!" on the LCD.

        .. code-block:: python

            import time
            import board
            import busio
            import adafruit_character_lcd.character_lcd_i2c as character_lcd

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)

            lcd.message = "Hello, world!"
            time.sleep(5)
        """
        return self._message 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:26,代碼來源:character_lcd.py

示例6: move_right

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def move_right(self):
        """Moves displayed text right one column.

        The following example scrolls a message to the right off the screen.

        .. code-block:: python

            import time
            import board
            import busio
            import adafruit_character_lcd.character_lcd_i2c as character_lcd

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)

            scroll_message = "Scroll -->"
            lcd.message = scroll_message
            time.sleep(2)
            for i in range(len(scroll_message) + 16):
                lcd.move_right()
                time.sleep(0.5)
        """
        self._write8(_LCD_CURSORSHIFT | _LCD_DISPLAYMOVE | _LCD_MOVERIGHT) 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:25,代碼來源:character_lcd.py

示例7: text_direction

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def text_direction(self):
        """The direction the text is displayed. To display the text left to right beginning on the
        left side of the LCD, set ``text_direction = LEFT_TO_RIGHT``. To display the text right
        to left beginning on the right size of the LCD, set ``text_direction = RIGHT_TO_LEFT``.
        Text defaults to displaying from left to right.

        The following example displays "Hello, world!" from right to left.

        .. code-block:: python

            import time
            import board
            import busio
            import adafruit_character_lcd.character_lcd_i2c as character_lcd

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)

            lcd.text_direction = lcd.RIGHT_TO_LEFT
            lcd.message = "Hello, world!"
            time.sleep(5)
        """
        return self._direction 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:25,代碼來源:character_lcd.py

示例8: __init__

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def __init__(self, i2c, columns, lines, address=None, backlight_inverted=False):
        """Initialize character LCD connected to backpack using I2C connection
        on the specified I2C bus with the specified number of columns and
        lines on the display. Optionally specify if backlight is inverted.
        """

        if address:
            mcp = MCP23008(i2c, address=address)
        else:
            mcp = MCP23008(i2c)
        super().__init__(
            mcp.get_pin(1),
            mcp.get_pin(2),
            mcp.get_pin(3),
            mcp.get_pin(4),
            mcp.get_pin(5),
            mcp.get_pin(6),
            columns,
            lines,
            backlight_pin=mcp.get_pin(7),
            backlight_inverted=backlight_inverted,
        ) 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:24,代碼來源:character_lcd_i2c.py

示例9: left_button

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def left_button(self):
        """The left button on the RGB Character LCD I2C Shield or Pi plate.

        The following example prints "Left!" to the LCD when the left button is pressed:

        .. code-block:: python

            import board
            import busio
            from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = Character_LCD_RGB_I2C(i2c, 16, 2)

            while True:
                if lcd.left_button:
                    lcd.message = "Left!"

        """
        return not self._left_button.value 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:22,代碼來源:character_lcd_rgb_i2c.py

示例10: up_button

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def up_button(self):
        """The up button on the RGB Character LCD I2C Shield or Pi plate.

        The following example prints "Up!" to the LCD when the up button is pressed:

        .. code-block:: python

            import board
            import busio
            from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = Character_LCD_RGB_I2C(i2c, 16, 2)

            while True:
                if lcd.up_button:
                    lcd.message = "Up!"

        """
        return not self._up_button.value 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:22,代碼來源:character_lcd_rgb_i2c.py

示例11: down_button

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def down_button(self):
        """The down button on the RGB Character LCD I2C Shield or Pi plate.

        The following example prints "Down!" to the LCD when the down button is pressed:

        .. code-block:: python

            import board
            import busio
            from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = Character_LCD_RGB_I2C(i2c, 16, 2)

            while True:
                if lcd.down_button:
                    lcd.message = "Down!"

        """
        return not self._down_button.value 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:22,代碼來源:character_lcd_rgb_i2c.py

示例12: right_button

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def right_button(self):
        """The right button on the RGB Character LCD I2C Shield or Pi plate.

        The following example prints "Right!" to the LCD when the right button is pressed:

        .. code-block:: python

            import board
            import busio
            from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = Character_LCD_RGB_I2C(i2c, 16, 2)

            while True:
                if lcd.right_button:
                    lcd.message = "Right!"

        """
        return not self._right_button.value 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:22,代碼來源:character_lcd_rgb_i2c.py

示例13: select_button

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def select_button(self):
        """The select button on the RGB Character LCD I2C Shield or Pi plate.

        The following example prints "Select!" to the LCD when the select button is pressed:

        .. code-block:: python

            import board
            import busio
            from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C

            i2c = busio.I2C(board.SCL, board.SDA)
            lcd = Character_LCD_RGB_I2C(i2c, 16, 2)

            while True:
                if lcd.select_button:
                    lcd.message = "Select!"

        """
        return not self._select_button.value 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CharLCD,代碼行數:22,代碼來源:character_lcd_rgb_i2c.py

示例14: write

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def write(self, buf, *, start=0, end=None, stop=True):
        """
        Write the bytes from ``buffer`` to the device. Transmits a stop bit if
        ``stop`` is set.

        If ``start`` or ``end`` is provided, then the buffer will be sliced
        as if ``buffer[start:end]``. This will not cause an allocation like
        ``buffer[start:end]`` will so it saves memory.

        :param bytearray buffer: buffer containing the bytes to write
        :param int start: Index to start writing from
        :param int end: Index to read up to but not include; if None, use ``len(buf)``
        :param bool stop: If true, output an I2C stop condition after the buffer is written
        """
        if end is None:
            end = len(buf)
        self.i2c.writeto(self.device_address, buf, start=start, end=end, stop=stop)

    # pylint: disable-msg=too-many-arguments 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_BusDevice,代碼行數:21,代碼來源:i2c_device.py

示例15: __probe_for_device

# 需要導入模塊: import busio [as 別名]
# 或者: from busio import I2C [as 別名]
def __probe_for_device(self):
        """
        Try to read a byte from an address,
        if you get an OSError it means the device is not there
        or that the device does not support these means of probing
        """
        while not self.i2c.try_lock():
            pass
        try:
            self.i2c.writeto(self.device_address, b"")
        except OSError:
            # some OS's dont like writing an empty bytesting...
            # Retry by reading a byte
            try:
                result = bytearray(1)
                self.i2c.readfrom_into(self.device_address, result)
            except OSError:
                raise ValueError("No I2C device at address: %x" % self.device_address)
        finally:
            self.i2c.unlock() 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_BusDevice,代碼行數:22,代碼來源:i2c_device.py


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