Created
October 17, 2023 17:28
-
-
Save rsbohn/26a8e69c8fe80112a24e7de09177e8d9 to your computer and use it in GitHub Desktop.
Fun With TFT Bar Display
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
# use the TL032FWV01 320x820 Bar Display | |
init_sequence_tl032 = bytes(( | |
b'\x11\x80d' | |
b'\xff\x05w\x01\x00\x00\x13' | |
b'\xef\x01\x08' | |
b'\xff\x05w\x01\x00\x00\x10' | |
b'\xc0\x02\xe5\x02' | |
b'\xc1\x02\x0c\n' | |
b'\xc2\x02\x07\x0f' | |
b'\xc3\x01\x02' | |
b'\xcc\x01\x10' | |
b'\xcd\x01\x08' | |
b'\xb0\x10\x00\x08Q\r\xce\x06\x00\x08\x08\x1d\x02\xd0\x0fo6?' | |
b'\xb1\x10\x00\x10O\x0c\x11\x05\x00\x07\x07\x1f\x05\xd3\x11n4?' | |
b'\xff\x05w\x01\x00\x00\x11' | |
b'\xb0\x01M' | |
b'\xb1\x01\x1c' | |
b'\xb2\x01\x87' | |
b'\xb3\x01\x80' | |
b'\xb5\x01G' | |
b'\xb7\x01\x85' | |
b'\xb8\x01!' | |
b'\xb9\x01\x10' | |
b'\xc1\x01x' | |
b'\xc2\x01x' | |
b'\xd0\x81\x88d' | |
b'\xe0\x03\x80\x00\x02' | |
b'\xe1\x0b\x04\xa0\x00\x00\x05\xa0\x00\x00\x00``' | |
b'\xe2\r00``<\xa0\x00\x00=\xa0\x00\x00\x00' | |
b'\xe3\x04\x00\x0033' | |
b'\xe4\x02DD' | |
b'\xe5\x10\x06>\xa0\xa0\x08@\xa0\xa0\nB\xa0\xa0\x0cD\xa0\xa0' | |
b'\xe6\x04\x00\x0033' | |
b'\xe7\x02DD' | |
b'\xe8\x10\x07?\xa0\xa0\tA\xa0\xa0\x0bC\xa0\xa0\rE\xa0\xa0' | |
b'\xeb\x07\x00\x01NN\xeeD\x00' | |
b"\xed\x10\xff\xff\x04Vr\xff\xff\xff\xff\xff\xff'e@\xff\xff" | |
b'\xef\x06\x10\r\x04\x08?\x1f' | |
b'\xff\x05w\x01\x00\x00\x13' | |
b'\xe8\x02\x00\x0e' | |
b'\xff\x05w\x01\x00\x00\x00' | |
b'\x11\x80x' | |
b'\xff\x05w\x01\x00\x00\x13' | |
b'\xe8\x82\x00\x0c\n' | |
b'\xe8\x02\x00\x00' | |
b'\xff\x05w\x01\x00\x00\x00' | |
b'6\x01\x00' | |
b':\x01f' | |
b'\x11\x80x' | |
b')\x80x' | |
)) | |
tft_timings = { | |
"frequency": 16_000_000, | |
"width": 320, | |
"height": 820, | |
"hsync_pulse_width": 3, | |
"hsync_back_porch": 251, | |
"hsync_front_porch": 150, | |
"hsync_idle_low": False, | |
"vsync_pulse_width": 6, | |
"vsync_back_porch": 90, | |
"vsync_front_porch": 100, | |
"vsync_idle_low": False, | |
"pclk_active_high": False, | |
"pclk_idle_high": False, | |
"de_idle_high": False, | |
} | |
import displayio | |
displayio.release_displays() | |
import board | |
import busio | |
import dotclockframebuffer | |
from framebufferio import FramebufferDisplay | |
def get_display(): | |
board.I2C().deinit() | |
i2c = busio.I2C(board.SCL, board.SDA, frequency=400_000) | |
dotclockframebuffer.ioexpander_send_init_sequence( | |
i2c, init_sequence_tl032, **(dict(board.TFT_IO_EXPANDER))) | |
i2c.deinit() | |
fb = dotclockframebuffer.DotClockFramebuffer( | |
**(dict(board.TFT_PINS)), | |
**tft_timings) | |
display = FramebufferDisplay(fb, auto_refresh=True) | |
return display | |
display = get_display() | |
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
import board | |
from tl032 import display | |
from adafruit_display_text.label import Label | |
from terminalio import FONT | |
from adafruit_bitmap_font.bitmap_font import load_font | |
from adafruit_focaltouch import Adafruit_FocalTouch | |
import displayio | |
import time | |
display.rotation=90 | |
group = displayio.Group() | |
lora32 = load_font("/fonts/Lora-32.pcf") | |
fawes42 = load_font("/fonts/forkawesome-42.pcf") | |
label = Label(lora32, text="320x820 Bar Display", color=(44,240,44), | |
anchor_point=(0.5, 0.5), | |
anchored_position=(display.width//2, display.height*3//4)) | |
group.append(label) | |
debug = Label(fawes42, text="debug", color=(240,44,128), | |
anchor_point=(0.0,0.5), | |
anchored_position=(20, 32)) | |
group.append(debug) | |
focal = Adafruit_FocalTouch(board.I2C(), debug=False) | |
display.root_group=group | |
while True: | |
t = focal.touched | |
if t > 0: | |
debug.text="\uF1B0"*t | |
else: | |
debug.text="\uF069" | |
time.sleep(0.2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment