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)
def __init__(self): 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 ) _a_btn = digitalio.DigitalInOut(board.BUTTON_A) _a_btn.switch_to_input(pull=digitalio.Pull.DOWN) _b_btn = digitalio.DigitalInOut(board.BUTTON_B) _b_btn.switch_to_input(pull=digitalio.Pull.DOWN) self._buttons = GamePad(_a_btn, _b_btn) self._light_sensor = analogio.AnalogIn(board.LIGHT)
import time from random import randrange import displayio from adafruit_gizmo import tft_gizmo # Create the TFT Gizmo display display = tft_gizmo.TFT_Gizmo() # You can now use the display to do whatever you want # Here we show how to draw random pixels # Create a bitmap with two colors bitmap = displayio.Bitmap(display.width, display.height, 2) # Create a two color palette palette = displayio.Palette(2) palette[0] = 0x000000 palette[1] = 0xffffff # Create a TileGrid using the Bitmap and Palette tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette) # Create a Group group = displayio.Group() # Add the TileGrid to the Group group.append(tile_grid) # Add the Group to the Display display.show(group)