- Sat Sep 19, 2015 7:17 am
#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().