Skip to content

Guition ESP32-4848S040 touch GT911 error. #537

@zx158252

Description

@zx158252

Based on the discussion https://github.com/lvgl-micropython/lvgl_micropython/discussions/76 - managed to program the display and get an image (label,slider).

Image

Image

But I have trouble with touch.
This fragment causes an error.
81 indev = gt911.GT911(touch_i2c, debug=False)

output:

Traceback (most recent call last):
  File "main.py", line 81, in <module>
  File "gt911.py", line 83, in __init__
  File "gt911.py", line 103, in hw_reset
  File "gt911.py", line 50, in _write_reg
  File "i2c.py", line 123, in write_mem
  File "i2c.py", line 82, in writeto_mem
OSError: [Errno 116] ETIMEDOUT

Please help me get started or tell me what I'm doing wrong.
This is my program code.

from micropython import const
import lcd_bus
from spi3wire import Spi3Wire
import st7701
import lvgl as lv
import gt911
import i2c
import task_handler

import time

WIDTH = const(480)
HEIGHT = const(480)

BUFFER_SIZE = int(WIDTH * HEIGHT * 2 // 20)  # 2 bytes per pixel for RGB565

display_bus = lcd_bus.RGBBus(
    hsync=16,
    vsync=17,
    de=18,
    pclk=21,
    data0=4,
    data1=5,
    data2=6,
    data3=7,
    data4=15,
    data5=8,
    data6=20,
    data7=3,
    data8=46,
    data9=9,
    data10=10,
    data11=11,
    data12=12,
    data13=13,
    data14=14,
    data15=0,
    freq=12000000,
    hsync_pulse_width=8,
    hsync_back_porch=20,
    hsync_front_porch=10,
    vsync_pulse_width=8,
    vsync_back_porch=10,
    vsync_front_porch=10
)

spi3wire = Spi3Wire(
    scl=48,   
    sda=47,  
    cs=39,    
    freq=500000
    )

spi3wire.init(8, 8)  # cmd_bits=8, param_bits=8

fb1 = display_bus.allocate_framebuffer(BUFFER_SIZE, lcd_bus.MEMORY_SPIRAM)  # Use PSRAM for LVGL buffer too

display = st7701.ST7701(
    display_bus,
    spi3wire,
    WIDTH,
    HEIGHT,
    frame_buffer1=fb1,
    frame_buffer2=None,
    backlight_pin=38,
    color_space=lv.COLOR_FORMAT.RGB565,
    rgb565_byte_swap=False,
    bus_shared_pins=False
)



print('Hello LCD')

display.set_power(True)
display.init(type=9)
display.set_backlight(100)

i2c_bus = i2c.I2C.Bus(host=1, scl=45, sda=19, freq=100000)
touch_i2c = i2c.I2C.Device(i2c_bus, gt911.I2C_ADDR, gt911.BITS)
indev = gt911.GT911(touch_i2c, debug=False)


scr = lv.screen_active()
scr.set_style_bg_color(lv.color_hex(0xFF0000), 0)

label = lv.label(scr)
label.set_style_text_font(lv.font_montserrat_36, lv.PART.MAIN)
label.set_pos(10,20)
label.set_text('montserrat_36')

label1 = lv.label(scr)
label1.set_style_text_font(lv.font_montserrat_48, lv.PART.MAIN)
label1.set_pos(10,90)
label1.set_text('montserrat_48')
label1.set_style_text_color(lv.color_hex(0x330000),0)

slider = lv.slider(scr)
slider.set_size(300, 40)
slider.center()

label2 = lv.label(scr)
label2.set_style_text_font(lv.font_montserrat_30, lv.PART.MAIN)
label2.set_pos(215,290)
label2.set_text('0')



th = task_handler.TaskHandler()
i=0
try:
    while True:
        time.sleep_ms(2000)
        label2.set_text(str(i))
        i += 1
        #print(str(i))
except Exception as e:
    print('Error occurred: ', e)
except KeyboardInterrupt:
    print('Program Interrupted by the user')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions