Event based indev (input device) data processing

Hi Baldhead. I was too thinking this would be a nice feature, but as i started looking into it I just added to touchpad_read() to only read I2C if an interrrupt has occured. Now there is very little overhead when nothing is being updated on the display.

BTW, first post - stumbled upon this library and am really enjoying using it!

3 Likes

So currently I have the need to stop the constant polling of the TOUCH driver.
I am trying to connect three devices to the spi bus… sd card, display and touch.
All devices connect to the SBI bus (example shown below) but when I list directory in a while loop, periodically it returns errors.
This is due to collisions between the SD card and the touch driver.
By using touch.indev_drv.set_read_cb(None) prevents the read function from running that causes the collision.
But now I need a manual way to monitor an IRQ Pin to fire the touch read() function.
So I need a method to remove the auto polling to a manual IRQ Pin touch.
Collisions still will happen but I’m hoping to use some type of flag to prioritize SD over touch.

I believe LVGL should be dormant until called upon to refresh a screen or to react to a touch via an IRQ.
I am trying to stop as much unnecessary traffic on the SPI bus as we are trying to troubleshoot lost interrupts and other issues that is causing crashes within hours to days.

If I comment out… touch.indev_drv.set_read_cb(None)
I get [Errno 5] EIO

Example…

import lvgl as lv
from ili9XXX import ili9341
from xpt2046 import xpt2046
import os, time, sdcard
from machine import SPI, Pin

# Mount SD Card
sd = sdcard.SDCard(SPI(2), Pin(14), baudrate=10000000)
os.mount(sd, '/sd')
# Load Graphics Touch Drivers
lv.init()
disp = ili9341(spihost=2, miso=-1, mosi=-1, clk=-1, cs=15, mhz=10, dc=13, rst=-1, power=-1, factor=48, half_duplex=False, double_buffer=True, backlight=27, backlight_on=1)
touch = xpt2046(spihost=2, cs=5, mhz=1, half_duplex=False)

def button_cb(e):
	if e.get_code() == lv.EVENT.CLICKED:
		u_name.set_text('Got Clicked')
		print('clicked !!!')
scr = lv.scr_act()
u_name = lv.label(scr)
u_name.align(lv.ALIGN.TOP_MID, 0, 40)
u_name.set_style_text_font(lv.font_montserrat_20, 0)
u_name.set_text('S P I  Issues')
btn = lv.btn(scr)
btn.align(lv.ALIGN.TOP_MID, 0, 200)
btn.add_event(button_cb, lv.EVENT.CLICKED, None)
btn_lbl = lv.label(btn)
btn_lbl.set_text("CLICK Me")
lv.scr_load(scr)

touch.indev_drv.set_read_cb(None)		# stops touch from (reading) !!!!!

da_num = 1
while True:
	try:
		u_name.set_text(str(da_num))
		time.sleep_ms(50)	# THIS IS VERY IMPORTANT !!!!!!!!!!!!!!!!!
		print(os.listdir('sd/data'))
	except Exception as e:
		print(e)
	da_num += 1
	time.sleep_ms(500)

How can I stop this “indev task” and assign this to an IRQ?
btw, I am using lv_micropython master (v9)

Help much appreciated