Touch UI example


#1

Anyone have an example of a Touch/Graphical UI where someone can click on a button drawn on the screen, and fire off some code. This would be a fun extension to the T-Deck or any touch enabled display.

I’m thinking a tutorial for a remote control where you click on buttons and it fires off emails/wifi api calls/ or logging of sensor data might be fun. Or list out mp3s on your sdcard and play them. I got mp3s playing on the t-deck in the past, but the library wasn’t compatible with the one that uLisp uses. If memory served one used C++ style calls while the other was C.


#2

There is an example of a set of functions for working with the touch panel:

https://github.com/molnija2/uLisp-touchscreen-example


#3

Some headers and libraries need to be included.

#if defined(ESP32_2432S028R)

#if defined(touchscreen_support)

#include <SPI.h>
#include <TFT_Touch.h> // Touchscreen driver chip

#define XPT2046_IRQ 36
#define XPT2046_MOSI 32
#define XPT2046_MISO 39
#define XPT2046_CLK 25
#define XPT2046_CS 33
TFT_Touch tft_touch = TFT_Touch(XPT2046_CS, XPT2046_CLK, XPT2046_MOSI, XPT2046_MISO) ;

#endif // TOUCHSCREEN_DRIVERS
#endif // ESP32_2432S028R


#4

Oh, this is great!

It would be nice to add a library of common UI elements: Buttons (with a parameter of button text, and what function to fire off when pressed), a slider, radio button, check box, and perhaps some charts and graphs.


#5

Btw I got the touchscreen working on the t-deck, see this post for details.


#6

hasnOlife, thank you very much for the useful idea!


#7

Dear friends, good day!
I am trying to write a UI library with a touchscreen, using a simple object system proposed by David. It is planned to make it possible to automatically arrange the elements of the dialog in the window. Now the buttons and other elements are arranged automatically horizontally by line or by several lines. So far, only the message output has been written. (There was little time)

(Message '(string1 string2...) '(button1 button2 ...))

I wanted to add a function (kbhit) to check the key press.

object *fn_kbhit (object *args, object *env) {
  (void) env;

  if(Serial.available()>0) return tee ;

  return  nil;
}

const char string_kbhit[] = "kbhit" ;
const char doc_kbhit[] = "(kbhit) - test whether any keyboard keys
 hits.\n"
" Returns t if any char symbols are available"
"and otherwise returns nil.";

But for some reason it does not work normally. Perhaps UART has a built-in FIFO. So far I have not found a way to bypass this.

But even without this, the library works. The library and an example message on github.
https://github.com/molnija2/uLisp-touchscreen-example

For everyone who wants to, you can use it by adding your own functions. Perhaps you will have some ideas.