本文整理汇总了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
示例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
示例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
示例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),
)
示例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))
示例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__()
示例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)
示例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
示例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)
示例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
示例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
示例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)
示例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)
示例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),
)