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