stm32_hal_graphics_display_drivers icon indicating copy to clipboard operation
stm32_hal_graphics_display_drivers copied to clipboard

Support for DIYables 3.5 TFT LCD Color Touch Screen Shield

Open bicknell opened this issue 5 months ago • 2 comments

Changes necessary to make the DIYables 3.5 TFT LCD Color Touch Screen Shield work when connected to a NUCLEO-F103RB system. It has an 8-bit parallel interface using the GPIO driver. With these changes it appears to pass all tests quite well, and has a responsive touch interface that reports pressure. Several items are configuration items that likely shouldn't be committed to the master repo, but I wanted to first provide everything to make it work in case others want to reproduce and test.

The vendor's page: https://diyables.io/products/3.5-tft-lcd-color-touch-screen-shield-for-arduino-uno-mega-320x480-resolution-ili9488-driver-parallel-8-bit-interface-28pin-module-with-touch

Drivers/io_gpio/lcdts_io_gpio8_hal.c:

  • ADC_SAMPLETIME_15CYCLES is not present in my generated files. Use ADC_SAMPLETIME_1CYCLE_5 which seems to work, there are other choices that might be better. I believe this is due to my particular model of NUCLEO board or perhaps version of the STM32IDE, and not anything to do with the shield.

  • TS_IO_DetectToch() (intentional mispelling to match existing) would not detect touches. Referenced the DIYAbles code at https://github.com/DIYables/DIYables_TFT_Shield/blob/main/src/DIYables_TFT_Shield.cpp and rewrote the function. This screen detects the touch pressure, so instead of the function simply returning true (1) or false (0) it now returns the pressure. Values under 10 are returned as 0 to prevent spurious readings, although my unit pretty reliably returns 0 when there is no press.

    Wrap the new and old function in the TS_PRESSURE flag.

Drivers/io_gpio/lcdts_io_gpio8_hal.h:

  • Set TS_RS_ADCCH and TS_WR_ADCCH to match the NUCLEO-F103RB ADC channels.

  • Ran the App/TouchCalib and generated a new TS_CINDEX value to match my device.

  • Add a new TS_PRESSURE flag.

Drivers/lcd/ili9488.c:

  • The SETWINDOW and SETCURSOR functions do not need to be changed based on the ILI9488_ORIENTATION parameter with this board. Add a new #if DIYABLES_QUIRK == 1 section that always uses the standard functions.

    Proper operation with all 4 values of ILI9488_ORIENTATION was confirmed after this change.

  • In ili9488_Init() this board needs to have "ILI9488_INVON" set to get the proper colors. That's right, INVON = not inverted while INVOFF = inverted. Also wrap this in a #if DIYABLES_QUIRK == 1.

Drivers/lcd/ili9488.h:

  • This board has a parallel interface, so set ILI9488_INTERFACE 2.

  • Set the new variable DIYABLES_QUIRK to 1 to trigger the quirk handling above.

bicknell avatar Jun 03 '25 15:06 bicknell

I have discovered that the touch screen is not working properly. I've tried a number of combinations with no luck to get proper readings from it. I continue to work on that.

The LCD display part of this patch continues to work just fine.

bicknell avatar Jun 04 '25 11:06 bicknell

I went back and started from scratch and tested all of my changes over again one at a time. The result is a new branch in my fork with three commas: https://github.com/bicknell/stm32_hal_graphics_display_drivers/tree/fixes-take-two

The first commit is the minimal changes required to compile with my HAL layer.

The second commit is the changes necessary to produce a working LCD display with proper colors and orientation. With this patch LCD performance seems quite good, but the touch screen doesn't work.

The third commit modifies some of the low level routines to match method in the manufacturers sample code. It is absolutely a different sequence than this library has coded, so I presume it's a different make/model/interface of touch screen. It provides good touch detection, reasonably good Y values, but the X performance is horrible.

I would appreciate any help or insight making the touch portion work.

bicknell avatar Jun 04 '25 18:06 bicknell