init_sequence_tl040hds20 = bytes()
tft_timings = { "frequency": 16000000, "width": 720, "height": 720, "hsync_pulse_width": 2, "hsync_front_porch": 46, "hsync_back_porch": 44, "vsync_pulse_width": 2, "vsync_front_porch": 16, "vsync_back_porch": 18, "hsync_idle_low": False, "vsync_idle_low": False, "de_idle_high": False, "pclk_active_high": False, "pclk_idle_high": False, }
from displayio import release_displays release_displays() import displayio import busio import board import dotclockframebuffer from framebufferio import FramebufferDisplay tft_pins = dict(board.TFT_PINS) tft_timings = { "frequency": 16000000, "width": 720, "height": 720, "hsync_pulse_width": 2, "hsync_front_porch": 46, "hsync_back_porch": 44, "vsync_pulse_width": 2, "vsync_front_porch": 16, "vsync_back_porch": 18, "hsync_idle_low": False, "vsync_idle_low": False, "de_idle_high": False, "pclk_active_high": False, "pclk_idle_high": False, } init_sequence_tl040hds20 = bytes() board.I2C().deinit() i2c = busio.I2C(board.SCL, board.SDA) tft_io_expander = dict(board.TFT_IO_EXPANDER) #tft_io_expander['i2c_address'] = 0x38 # uncomment for rev B dotclockframebuffer.ioexpander_send_init_sequence(i2c, init_sequence_tl040hds20, **tft_io_expander) i2c.deinit() bitmap = displayio.OnDiskBitmap("/display-ruler-720p.bmp") fb = dotclockframebuffer.DotClockFramebuffer(**tft_pins, **tft_timings) display = FramebufferDisplay(fb, auto_refresh=False) # Create a TileGrid to hold the bitmap tile_grid = displayio.TileGrid(bitmap, pixel_shader=bitmap.pixel_shader) # Create a Group to hold the TileGrid group = displayio.Group() # Add the TileGrid to the Group group.append(tile_grid) # Add the Group to the Display display.root_group = group display.auto_refresh = True # Loop forever so you can enjoy your image while True: pass
Download the following image into the root folder of of your CIRCUITPY drive:
Go ahead and save the example you your CircuitPython code.py and run the code. Your display should now look like this:
Text editor powered by tinymce.