当前位置: 首页>>代码示例>>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;未经允许,请勿转载。