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

Moderator: igrr

User avatar
By spapadim
#29403 The second link is the one I actually have (same vendor, too, I think). Don't see why the first one would not work (I see MOSI/MISO on that header, no?). As for the last one, touch driver is the same, but it doesn't say what TFT driver it has -- for larger displays I usually see either SSD1351 (which is not supported by ugclib, see https://github.com/olikraus/ucglib/issues/53, perhaps other libraries do?) or ILI9841 (have to check the datasheet and see how similar commands are.. some day :).

In the meantime, earlier today I had a d-oh moment, just switched SPI clock to 32MHz (1-line change), and I now get >15fps across the board, which I think is pretty cool! Proof:

At 40MHz the ILI seems to drop bits and garbles image (reaches ~20fps on text), didn't try values in-between -- but this is not bad!

SwiCago wrote:Very nice example...Has anyone tried a larger cheap display?
would these from fleabay be compatible?
4.3"
http://www.ebay.com/itm/3-2inch-TFT-LCD ... 46383e4bca
2.4"
http://www.ebay.com/itm/240x320-2-4-SPI ... 4adab6ab15

This one would be cool too, but I don't think it uses same chips
http://www.ebay.com/itm/New-3-5-TFT-LCD ... 33a9635d1a
User avatar
By spapadim
#29431 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().
User avatar
By schufti
#29432 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.