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._keys = keypad.ShiftRegisterKeys( clock=board.BUTTON_CLOCK, data=board.BUTTON_OUT, latch=board.BUTTON_LATCH, key_count=4, value_when_pressed=True, ) self._buttons = KeyStates(self._keys) 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)
def __init__(self) -> None: super().__init__() i2c = None if i2c is None: try: i2c = board.I2C() except RuntimeError: self._accelerometer = None if i2c is not None: _i2c_devices = [] for _ in range(10): # try lock 10 times to avoid infinite loop in sphinx build if i2c.try_lock(): _i2c_devices = i2c.scan() i2c.unlock() break # PyBadge LC doesn't have accelerometer if int(0x18) in _i2c_devices or int(0x19) in _i2c_devices: 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._keys = keypad.ShiftRegisterKeys( clock=board.BUTTON_CLOCK, data=board.BUTTON_OUT, latch=board.BUTTON_LATCH, key_count=8, value_when_pressed=True, ) self._buttons = KeyStates(self._keys) self._light_sensor = analogio.AnalogIn(board.A7)
def __init__(self): super().__init__() self._keys = keypad.Keys( [ board.BUTTON_O, board.BUTTON_X, board.BUTTON_Z, board.BUTTON_RIGHT, board.BUTTON_DOWN, board.BUTTON_UP, board.BUTTON_LEFT, ], value_when_pressed=False, pull=True, ) self._buttons = KeyStates(self._keys)
def __init__(self) -> None: super().__init__() i2c = board.I2C() if i2c is not None: self._accelerometer = adafruit_lsm6ds.lsm6ds33.LSM6DS33(i2c) # NeoPixels self._neopixels = neopixel.NeoPixel(board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB) self._keys = keypad.Keys([board.BUTTON_A, board.BUTTON_B], value_when_pressed=False, pull=True) self._buttons = KeyStates(self._keys)
def __init__(self) -> None: super().__init__() _i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA) _int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT) self.accelerometer = adafruit_lis3dh.LIS3DH_I2C(_i2c, address=0x19, int1=_int1) self.accelerometer.range = adafruit_lis3dh.RANGE_8_G self.display = tft_gizmo.TFT_Gizmo() self._display_brightness = 1.0 # NeoPixels self._neopixels = neopixel.NeoPixel( board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB ) self._keys = keypad.Keys( [board.BUTTON_A, board.BUTTON_B], value_when_pressed=True, pull=True ) self._buttons = KeyStates(self._keys) self._light_sensor = analogio.AnalogIn(board.LIGHT)