News:

SMF - Just Installed!

Main Menu

ILI9341 SPI Touch LCD?

Started by AeonKen, February 06, 2023, 12:29:07 PM

Previous topic - Next topic

AeonKen

Hello again!
So I have started planing my Pistomp build, and as it turns out, I have an ILI9341 touch enabled LCD screen. Is there any way to add touch capability with the LCD UI you have programmed, and if so, what files would need to be modified/called? Like what file is actually handling the UI itself? Im not really used to OOP.

Randall (Admin)

#1
I assume you're asking about the software side.  I assume you've got the hardware side figured out.

The pi-Stomp LCD UI was designed to be navigated using a encoder (w/ switch).   Sure you could adapt it to select objects via touch instead of scrolling.  Be prepared for some more than trivial coding though.

In the current implementation, there is a encoder state machine which keeps track of user interaction:
https://github.com/TreeFallSound/pi-stomp/blob/master/modalapi/mod.py

selectable_items, universal_encoder_select() (line 325) and universal_select() keep track of which screen object/type is selected

universal_encoder_sw() (line 268) handles switch actions

I'm imagining a touch display would handle touch actions, similar to universal_encoder_sw(), but would correlate the touched x/y to a specific object (from the selectable_items array) and then decide which action to take.


That said, we've been working on a replacement UI which isn't state machine based.  It could be simpler to add touch to, but probably still not trivial.  I'm guessing that'll merge to mainline in the next 2 to 3 months.  I'm not against considering if touch could be shoehorned in as an alternative form of navigation, but also not willing to delay it for that.  The touch displays I've seen that are reasonably priced are resistive touch not capacitive touch, and unless they can reuse the exact 3 GPIO's used by the Nav encoder, I'm not willing to create a GPIO conflict with other functionality.


AeonKen

#2
Oh, yeah! Having GPIO conflict would be a major multi moth headache and could ruin everything. I kinda obsess over details during the planing stage of projects, so I will wait until the update regardless. Working on the current UI, just to have that work be for nothig would be a shame. Indeed the screen I have is indeed capacitive touch. The accuracy is obismal when using a pen, but acceptable when using ones' finger. The touch interface uses the SPI bus with a seperate Chip Select pin. So another module acting as a parser of touch areas converted into commands which the UI module can recognize could work. I dont know how you plan to write the new UI, but I will be looking into it to come up with a good solution. I may just pivot into having the touchscreen act as a XY pad sending MIDI or some sort of gesture control. We will see. Thanks for the Information though! I look forward to the new UI, and would love a similar explanation when it drops! Or is the branch up on github already?

And yes... It will not be trivial at all! But who needs sanity :o