Created
September 25, 2023 16:33
-
-
Save jepler/5e590127311c306b4762944045cc0ffc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from displayio import release_displays | |
release_displays() | |
import time | |
import busio | |
import board | |
import digitalio | |
import microcontroller | |
import dotclockframebuffer | |
from framebufferio import FramebufferDisplay | |
from microcontroller import pin | |
init_sequence_tl021wvc02 = bytes(( | |
0xff, 0x05, 0x77, 0x01, 0x00, 0x00, 0x10, | |
0xc0, 0x02, 0x3b, 0x00, | |
0xc1, 0x02, 0x0b, 0x02, | |
0xc2, 0x02, 0x00, 0x02, | |
0xcc, 0x01, 0x10, | |
0xcd, 0x01, 0x08, | |
0xb0, 0x10, 0x02, 0x13, 0x1b, 0x0d, 0x10, 0x05, 0x08, 0x07, 0x07, 0x24, 0x04, 0x11, 0x0e, 0x2c, 0x33, 0x1d, | |
0xb1, 0x10, 0x05, 0x13, 0x1b, 0x0d, 0x11, 0x05, 0x08, 0x07, 0x07, 0x24, 0x04, 0x11, 0x0e, 0x2c, 0x33, 0x1d, | |
0xff, 0x05, 0x77, 0x01, 0x00, 0x00, 0x11, | |
0xb0, 0x01, 0x5d, | |
0xb1, 0x01, 0x43, | |
0xb2, 0x01, 0x81, | |
0xb3, 0x01, 0x80, | |
0xb5, 0x01, 0x43, | |
0xb7, 0x01, 0x85, | |
0xb8, 0x01, 0x20, | |
0xc1, 0x01, 0x78, | |
0xc2, 0x01, 0x78, | |
0xd0, 0x01, 0x88, | |
0xe0, 0x03, 0x00, 0x00, 0x02, | |
0xe1, 0x0b, 0x03, 0xa0, 0x00, 0x00, 0x04, 0xa0, 0x00, 0x00, 0x00, 0x20, 0x20, | |
0xe2, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0xe3, 0x04, 0x00, 0x00, 0x11, 0x00, | |
0xe4, 0x02, 0x22, 0x00, | |
0xe5, 0x10, 0x05, 0xec, 0xa0, 0xa0, 0x07, 0xee, 0xa0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0xe6, 0x04, 0x00, 0x00, 0x11, 0x00, | |
0xe7, 0x02, 0x22, 0x00, | |
0xe8, 0x10, 0x06, 0xed, 0xa0, 0xa0, 0x08, 0xef, 0xa0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0xeb, 0x07, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, | |
0xed, 0x10, 0xff, 0xff, 0xff, 0xba, 0x0a, 0xbf, 0x45, 0xff, 0xff, 0x54, 0xfb, 0xa0, 0xab, 0xff, 0xff, 0xff, | |
0xef, 0x06, 0x10, 0x0d, 0x04, 0x08, 0x3f, 0x1f, | |
0xff, 0x05, 0x77, 0x01, 0x00, 0x00, 0x13, | |
0xef, 0x01, 0x08, | |
0xff, 0x05, 0x77, 0x01, 0x00, 0x00, 0x00, | |
0x36, 0x01, 0x00, | |
0x3a, 0x01, 0x60, | |
0x11, 0x80, 0x64, | |
0x29, 0x80, 0x32, | |
)) | |
board.I2C().deinit() | |
i2c = busio.I2C(board.SCL, board.SDA, frequency=400_000) | |
dotclockframebuffer.ioexpander_send_init_sequence(i2c, init_sequence_tl021wvc02, **board.TFT_IO_EXPANDER) | |
i2c.deinit() | |
tft_pins = dict(board.TFT) | |
tft_timings = { | |
"frequency": 16_000_000, | |
"width": 480, | |
"height": 480, | |
"hsync_pulse_width": 20, | |
"hsync_front_porch": 40, | |
"hsync_back_porch": 40, | |
"vsync_pulse_width": 10, | |
"vsync_front_porch": 40, | |
"vsync_back_porch": 40, | |
"hsync_idle_low": False, | |
"vsync_idle_low": False, | |
"de_idle_high": False, | |
"pclk_active_high": True, | |
"pclk_idle_high": False, | |
} | |
fb = dotclockframebuffer.DotClockFramebuffer(**tft_pins, **tft_timings) | |
disp = FramebufferDisplay(fb, auto_refresh=False) | |
#send_gfx_init_code_spi9(cs=cs, sck=sck, mosi=mosi, initcode=TL021WVC02_init_operations) | |
while True: | |
print("\n" * 24) | |
for k, v in board.TFT.items(): | |
print(f"{k:<20} {v}") | |
disp.auto_refresh = True | |
time.sleep(6) | |
disp.auto_refresh = False | |
print("\n" * 24) | |
for k, v in tft_timings.items(): | |
print(f"{k:<20} {v}") | |
disp.auto_refresh = True | |
time.sleep(6) | |
disp.auto_refresh = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment