Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Tolipwen
#29457
spapadim wrote:Yes, the code in the linked video is the FPS example from Ucglib. In one of the other YouTube videos it's XPTPaint from my touch library.

Also, I found all datasheets for this module (TJCTM24024-SPI), after a fair amount of Googling, here: http://datasheets.gpio.dk/dl/2.4inch-tft-touch/ -- you may also find them useful.

For wiring, I'll describe what's in front of me. The order below is always

Display -> ESP

First, we have the shared SPI bus pins; these are hardware SPI and you *must* use the same pins on the ESP8266.

SDO(MISO) -> MISO (GPIO12)
SDI(MOSI) -> MOSI (GPIO13)
SCK -> SCLK (GPIO14)

If you have/use the touchscreen, you also must connect the touch driver to the same SPI bus pins:

T_DO -> MISO (GPIO12)
T_DIN -> MOSI (GPIO13)
T_CLK -> SCLK (GPIO14)

The rest of the pins are my (arbitrary) choices -- the only restriction is that T_IRQ cannot use GPIO16 if you plan to use ISRs for touch (because that pin doesn't support interrupts), otherwise you can choose as you wish. My library does not register an ISR, though.

For the TFT driver (ILI9341):

D/C -> GPIO2
CS -> GPIO4
RESET -> GPIO5

If you use those, then you can instantiate Ucglib with (you'll have to add it to the Ucglib examples; in the XPT2046 library examples, it's already there):
Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 2 , /*cs=*/ 4, /*reset=*/ 5);

For the touch driver:

T_CS -> GPIO16 (aka XPD ?)
T_IRQ -> GPIO0 (must disconnect every time you reflash!!)

If you use those, you can initalize my library with
XPT2046 touch(/*cs=*/ 16, /*irq=*/ 0);
In retrospect, GPIO0 was less than ideal for T_IRQ (but I had hooked up everything else when I got to touch, and I'm ashamed to say I've been too lazy to swap :) ): T_IRQ has a 10K pullup, and GPIO0 needs to be low on powerup to reflash, so on my ESP board I have to disconnect either T_IRQ or the display module's power.

Finally, don't forget the power pins:

VCC -> 3.3V
LED -> 3.3V
GND -> GND

Total draw (including ESP) is ~160mA from my bench PSU @5V (LDO input), so make sure you can supply that power + safety margin. Also, you may need more if you use wifi. Sparkfun Thing and Adafruit breakout have regulators rated for at least 500mA, so you should be fine -- but please double-check for your board.

In the end, you are left with UART TX and RX (also GPIO 7 and 8) free. If you want backlight control, you need to PWM the LED pin on the display module through a high-side switch (unfortunately, the module breaks out only the backlight anode, and connects all four cathodes to GND, so you can't use a low side-switch which would be fewer components). Don't connect LED directly to GPIO as it can draw over 50mA (don't know what ESP's current limits are, but they should definitely be *much* lower).

Please note that my Ucglib fork on github leaves the SPI clock at about 8MHz. I'll have to check if the XPT2046 can handle 32MHz (I doubt?) and, if not, add support for SPI transactions on both Ucglib and my library. If you're not using touch, for now you can just SPI.setFrequency(32000000) *after* calling ucg.begin().


Thank you for sharing! Can't wait for my display to arrive and start playing with it.
I'm sure I'll have further questions once I start tinkering with it. I hope you don't mind me pestering you a little (that's what you get for providing that library of yours :D )
User avatar
By Oldmicroguy
#29460 Hello,
In Windows 10, the path to make the changes is:
C:\Users\computer name\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\

I made those edits
Then I downloaded and unzipped https://github.com/spapadim/ucglib and added them to
Ucglib_Arduino-1.3.3 and added esp8266 to library.properties.

Then I tried to compile the example HowToUseFonts for my NodeMCU but Arduino generated a lot of errors.

Can you see any missteps ?

Oldmicroguy
User avatar
By spapadim
#29462 You're probably right -- I saw separate CS pins, so I guessed it does SPI for the TFT as well (not just touch), but now I can't see access to the ILI's IM pins (interface mode select; other breakout boards expose them via solder jumpers). So it appears to be hardwired for parallel mode (even if MISO/MOSI is connected to both chips).

schufti wrote:the one from the first link is parallel only. unfortunately they didn't bring out the interface select pins on the pin header (usually they are accessible on the flex connector).
So maybe one could lift the panel and look for solder jumpers below to change the interface typ.
Additionally there are no SPI signals from the display on the pin header, so they might be missing or joined with the touch controller.
User avatar
By spapadim
#29463
Oldmicroguy wrote:Hello,
...
Then I tried to compile the example HowToUseFonts for my NodeMCU but Arduino generated a lot of errors.
Can you see any missteps ?


You need to run tools/release/arduino/create_release.sh to make a zip with directories in Arduino library layout (or use tools/release/arduino_new_lib_format/create_release.sh but remove the git commit and pandoc stuff).