waveshare_esp32_s3_touch_lcd_2.py: register with InputManager

This commit is contained in:
Thomas Farstrike
2026-03-18 13:37:36 +01:00
parent 7635c52baa
commit d92c70c7d9
2 changed files with 6 additions and 27 deletions
@@ -11,6 +11,7 @@ import lcd_bus
import lvgl as lv
import machine
import mpos.ui
from mpos import InputManager
# Pin configuration
SPI_BUS = 2
@@ -83,7 +84,8 @@ mpos.ui.main_display.set_backlight(100)
# Touch handling:
i2c_bus = i2c.I2C.Bus(host=I2C_BUS, scl=TP_SCL, sda=TP_SDA, freq=I2C_FREQ, use_locks=False)
touch_dev = i2c.I2C.Device(bus=i2c_bus, dev_id=TP_ADDR, reg_bits=TP_REGBITS)
indev=cst816s.CST816S(touch_dev,startup_rotation=lv.DISPLAY_ROTATION._180) # button in top left, good
indev = cst816s.CST816S(touch_dev, startup_rotation=lv.DISPLAY_ROTATION._180) # button in top left, good
InputManager.register_indev(indev)
mpos.ui.main_display.set_rotation(lv.DISPLAY_ROTATION._90) # must be done after initializing display and creating the touch drivers, to ensure proper handling
@@ -7,6 +7,8 @@ focus management, and input device registration.
All methods are class methods, so no instance creation is needed.
"""
import lvgl as lv
class InputManager:
"""
@@ -68,36 +70,11 @@ class InputManager:
@classmethod
def has_pointer(cls):
"""Check if any registered input device is a pointer/touch device."""
import lvgl as lv
if cls.has_indev_type(lv.INDEV_TYPE.POINTER):
return True
get_next = getattr(lv, "indev_get_next", None)
if get_next:
indev = get_next(None)
while indev:
try:
if indev.get_type() == lv.INDEV_TYPE.POINTER:
return True
except Exception:
pass
indev = get_next(indev)
get_active = getattr(lv, "indev_active", None) or getattr(lv, "indev_get_act", None)
if get_active:
try:
indev = get_active()
except Exception:
indev = None
if indev:
try:
return indev.get_type() == lv.INDEV_TYPE.POINTER
except Exception:
return False
return False
return cls.has_indev_type(lv.INDEV_TYPE.POINTER)
@classmethod
def pointer_xy(cls):
"""Get current pointer/touch coordinates."""
import lvgl as lv
indev = lv.indev_active()
if indev:
p = lv.point_t()