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


Python digitalio.DigitalInOut方法代码示例

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


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

示例1: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(
        self, pin, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None
    ):
        if not pixel_order:
            pixel_order = GRB if bpp == 3 else GRBW
        else:
            if isinstance(pixel_order, tuple):
                order_list = [RGBW[order] for order in pixel_order]
                pixel_order = "".join(order_list)

        super().__init__(
            n, brightness=brightness, byteorder=pixel_order, auto_write=auto_write
        )

        self.pin = digitalio.DigitalInOut(pin)
        self.pin.direction = digitalio.Direction.OUTPUT 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_NeoPixel,代码行数:18,代码来源:neopixel.py

示例2: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(self):
        # Only create the cpb module member when we aren't being imported by Sphinx
        if (
            "__module__" in dir(digitalio.DigitalInOut)
            and digitalio.DigitalInOut.__module__ == "sphinx.ext.autodoc"
        ):
            return

        super().__init__()

        self._sample = None

        # Define mic/sound sensor:
        self._mic = audiobusio.PDMIn(
            board.MICROPHONE_CLOCK,
            board.MICROPHONE_DATA,
            sample_rate=16000,
            bit_depth=16,
        )
        self._samples = None 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_CircuitPlayground,代码行数:22,代码来源:bluefruit.py

示例3: tapped

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def tapped(self):
        """
        True if a tap was detected recently. Whether its a single tap or double tap is
        determined by the tap param on ``set_tap``. ``tapped`` may be True over
        multiple reads even if only a single tap or single double tap occurred if the
        interrupt (int) pin is not specified.

        The following example uses ``i2c`` and specifies the interrupt pin:

        .. code-block:: python

            import adafruit_lis3dh
            import digitalio

            i2c = busio.I2C(board.SCL, board.SDA)
            int1 = digitalio.DigitalInOut(board.D11) # pin connected to interrupt
            lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)
            lis3dh.range = adafruit_lis3dh.RANGE_8_G

        """
        if self._int1 and not self._int1.value:
            return False
        raw = self._read_register_byte(_REG_CLICKSRC)
        return raw & 0x40 > 0 
开发者ID:tinypico,项目名称:tinypico-micropython,代码行数:26,代码来源:lis3dh.py

示例4: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(self):
        super().__init__()

        i2c = board.I2C()

        if i2c is not None:
            self._accelerometer = adafruit_lsm6ds.LSM6DS33(i2c)

        # NeoPixels
        self._neopixels = neopixel.NeoPixel(
            board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB
        )

        self._buttons = GamePad(
            digitalio.DigitalInOut(board.BUTTON_A),
            digitalio.DigitalInOut(board.BUTTON_B),
        ) 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_PyBadger,代码行数:19,代码来源:clue.py

示例5: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(self):
        Sensor.__init__(self)

        self.moisture_min = float(self.config["soil"]["min"])
        self.moisture_max = float(self.config["soil"]["max"])

        # create SPI bus
        spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)

        # create the cs (chip select)
        cs = digitalio.DigitalInOut(board.D8)

        # create the mcp object
        mcp = MCP.MCP3008(spi, cs)
        
        # create an analog input channel
        self.pin = []
        self.pin.append(AnalogIn(mcp, MCP.P0))
        self.pin.append(AnalogIn(mcp, MCP.P1))
        self.pin.append(AnalogIn(mcp, MCP.P2))
        self.pin.append(AnalogIn(mcp, MCP.P3))
        self.pin.append(AnalogIn(mcp, MCP.P4))
        self.pin.append(AnalogIn(mcp, MCP.P5))
        self.pin.append(AnalogIn(mcp, MCP.P6))
        self.pin.append(AnalogIn(mcp, MCP.P7)) 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:27,代码来源:soil.py

示例6: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(self):
        # Only create the cpx module member when we aren't being imported by Sphinx
        if (
            "__module__" in dir(digitalio.DigitalInOut)
            and digitalio.DigitalInOut.__module__ == "sphinx.ext.autodoc"
        ):
            return

        super().__init__() 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_CircuitPlayground,代码行数:11,代码来源:express.py

示例7: init_button

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def init_button(pin):
    button = digitalio.DigitalInOut(pin)
    button.switch_to_input()
    button.pull = digitalio.Pull.UP
    return button


# pylint: disable=too-few-public-methods 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_RGB_Display,代码行数:10,代码来源:rgb_display_pillow_animated_gif.py

示例8: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(
        self,
        rs,
        en,
        db4,
        db5,
        db6,
        db7,
        columns,
        lines,
        red,
        green,
        blue,
        read_write=None,
    ):

        # Define read_write (rw) pin
        self.read_write = read_write

        # Setup rw pin if used
        if read_write is not None:
            self.read_write.direction = digitalio.Direction.OUTPUT

        # define color params
        self.rgb_led = [red, green, blue]

        for pin in self.rgb_led:
            if hasattr(pin, "direction"):
                # Assume a digitalio.DigitalInOut or compatible interface:
                pin.direction = digitalio.Direction.OUTPUT
            elif not hasattr(pin, "duty_cycle"):
                raise TypeError(
                    "RGB LED objects must be instances of digitalio.DigitalInOut"
                    " or pulseio.PWMOut, or provide a compatible interface."
                )

        self._color = [0, 0, 0]
        super().__init__(rs, en, db4, db5, db6, db7, columns, lines) 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_CharLCD,代码行数:40,代码来源:character_lcd.py

示例9: color

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def color(self, color):
        self._color = color
        for number, pin in enumerate(self.rgb_led):
            if hasattr(pin, "duty_cycle"):
                # Assume a pulseio.PWMOut or compatible interface and set duty cycle:
                pin.duty_cycle = int(_map(color[number], 0, 100, 65535, 0))
            elif hasattr(pin, "value"):
                # If we don't have a PWM interface, all we can do is turn each color
                # on / off.  Assume a DigitalInOut (or compatible interface) and write
                # 0 (on) to pin for any value greater than 0, or 1 (off) for 0:
                pin.value = not color[number] > 1 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_CharLCD,代码行数:13,代码来源:character_lcd.py

示例10: test_context_manager

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def test_context_manager(self):
        import digitalio
        from testing.board import default_pin

        """Deinitialisation is triggered by __exit__() and should dispose machine.pin reference"""
        dio = digitalio.DigitalInOut(default_pin)
        self.assertIsNotNone(dio._pin)
        with dio:
            pass
        self.assertIsNone(dio._pin) 
开发者ID:adafruit,项目名称:Adafruit_Blinka,代码行数:12,代码来源:adafruit_blinka.py

示例11: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(self, config: dict, main_thread_running, system_ready):
        self.config = config
        self.main_thread_running = main_thread_running
        self.system_ready = system_ready
        self.node_ready = False

        spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)
        cs = digitalio.DigitalInOut(ADCMCP3008Worker.PINS[config['pin']])

        self.mcp = MCP.MCP3008(spi, cs)

        self.sensors = []
        self.init_sensors()

        self.node_ready = True 
开发者ID:mudpi,项目名称:mudpi-core,代码行数:17,代码来源:adc_worker.py

示例12: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(self):
        self._light_sensor = None
        self._accelerometer = None
        self._label = label
        self._y_position = 1
        self._background_group = None
        self._background_image_filename = None
        self._lines = []
        self._created_background = False

        # Display
        self.display = board.DISPLAY
        self._display_brightness = 1.0

        self._neopixels = None

        # Auto dim display based on movement
        self._last_accelerometer = None
        self._start_time = time.monotonic()

        # Define audio:
        if hasattr(board, "SPEAKER_ENABLE"):
            self._speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
            self._speaker_enable.switch_to_output(value=False)
        self._sample = None
        self._sine_wave = None
        self._sine_wave_sample = None 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_PyBadger,代码行数:29,代码来源:pybadger_base.py

示例13: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(self):
        super().__init__()

        i2c = None

        if i2c is None:
            try:
                i2c = board.I2C()
            except RuntimeError:
                self._accelerometer = None

        if i2c is not None:
            int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
            try:
                self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(
                    i2c, address=0x19, int1=int1
                )
            except ValueError:
                self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)

        # NeoPixels
        self._neopixels = neopixel.NeoPixel(
            board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB
        )

        self._buttons = GamePadShift(
            digitalio.DigitalInOut(board.BUTTON_CLOCK),
            digitalio.DigitalInOut(board.BUTTON_OUT),
            digitalio.DigitalInOut(board.BUTTON_LATCH),
        )

        self._light_sensor = analogio.AnalogIn(board.A7) 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_PyBadger,代码行数:34,代码来源:pybadge.py

示例14: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(self):
        super().__init__()

        i2c = board.I2C()

        int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
        try:
            self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(
                i2c, address=0x19, int1=int1
            )
        except ValueError:
            self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)

        # NeoPixels
        self._neopixels = neopixel.NeoPixel(
            board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB
        )

        self._buttons = GamePadShift(
            digitalio.DigitalInOut(board.BUTTON_CLOCK),
            digitalio.DigitalInOut(board.BUTTON_OUT),
            digitalio.DigitalInOut(board.BUTTON_LATCH),
        )

        self._pygamer_joystick_x = analogio.AnalogIn(board.JOYSTICK_X)
        self._pygamer_joystick_y = analogio.AnalogIn(board.JOYSTICK_Y)

        self._light_sensor = analogio.AnalogIn(board.A7) 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_PyBadger,代码行数:30,代码来源:pygamer.py

示例15: __init__

# 需要导入模块: import digitalio [as 别名]
# 或者: from digitalio import DigitalInOut [as 别名]
def __init__(self):
        super().__init__()

        self._buttons = GamePad(
            digitalio.DigitalInOut(board.BUTTON_O),
            digitalio.DigitalInOut(board.BUTTON_X),
            digitalio.DigitalInOut(board.BUTTON_Z),
            digitalio.DigitalInOut(board.BUTTON_RIGHT),
            digitalio.DigitalInOut(board.BUTTON_DOWN),
            digitalio.DigitalInOut(board.BUTTON_UP),
            digitalio.DigitalInOut(board.BUTTON_LEFT),
        ) 
开发者ID:adafruit,项目名称:Adafruit_CircuitPython_PyBadger,代码行数:14,代码来源:pewpewm4.py


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