CPX + TFT + Arduino

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
lonbaf
 
Posts: 11
Joined: Tue Feb 01, 2022 1:23 pm

CPX + TFT + Arduino

Post by lonbaf »

Hi all -

I've got a Circuit Playground Express (CPX) and the 2.0" TFT breakout, unfortunately I can't seem to get the wiring right (I suspect), because the graphics tests are not working correctly. Does anyone know the recommended wiring?

My first try was:
TFT -> CPX
=============
VIN -> VOUT
3.3V -> 3.3V
GND -> GND
SCK -> A4
MISO -> SKIP
MOSI -> A5
LCD CS -> A6 (or RX)
RESET -> SKIP
D/C -> A7 (or TX)
SD CS -> SKIP
BACKLIGHT -> A3

My second try was:
TFT -> XPX
=============
VIN -> 3.3V
3.3V -> SKIP
GND -> GND
SCK -> A4
MISO -> SKIP
MOSI -> A5
LCD CS -> D10 (A3)
RESET -> SKIP
D/C -> D9 (A2)
SD CS -> SKIP
BACKLIGHT -> SKIP

Thanks!

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: CPX + TFT + Arduino

Post by dastels »

Have a look at the wiring of the TFT Gizmo https://learn.adafruit.com/adafruit-tft-gizmo/pinouts. That might get you up and running.

Dave

User avatar
lonbaf
 
Posts: 11
Joined: Tue Feb 01, 2022 1:23 pm

Re: CPX + TFT + Arduino

Post by lonbaf »

Thank you Dastels. That's where I looked to come up with that first wiring config I mentioned. I'm confident on the control wires (according to that post), however, not sure on the power. For instance they don't reference VIN. So I connected TFT's VIN to CPX's VOUT?

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: CPX + TFT + Arduino

Post by dastels »

I'd connect the display's Vin to the CPX's 3.3v output.

Dave

User avatar
lonbaf
 
Posts: 11
Joined: Tue Feb 01, 2022 1:23 pm

Re: CPX + TFT + Arduino

Post by lonbaf »

Thank you Dave! I'm continuing to struggle... I've now done that. So the wiring now looks like:

TFT -> CPX
=============
VIN -> 3.3V
3.3V -> SKIP
GND -> GND
SCK -> A4 (D3)
MISO -> SKIP
MOSI -> A5 (D2)
LCD CS -> A6 (D0)
RESET -> SKIP
D/C -> A7 (D1)
SD CS -> SKIP
BACKLIGHT -> A3 (D10)

Before I was just using pressure to hold the TFT connection, but just to ensure, I've now soldered it.

I've simplified the graphics test code down to the following. It runs, the output looks as expected (it runs completely and prints the statements). But, while the TFT blacklight comes on, nothing appears on the screen. I wondered whether it was the pin number defined at the top. I tried CS=6 & DC=7 and I've tried CS=0 & DC=1. Neither makes a difference.

Code: Select all

#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789

// ----- STATIC CODE -----
#define TFT_CS        6 
#define TFT_RST       -1 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC        7


// ----- VARIABLES -----
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);


// ----- FUNCTIONS -----

void setup() {
  Serial.begin(115200);
  while (!Serial) ; // while the serial stream is not open, do nothing
  Serial.println("Starting");
  
  tft.init(240, 320);           // Init ST7789 320x240
  Serial.println("Initialized");

  // Tests
  long time = millis();
  tft.fillScreen(ST77XX_BLACK);
  time = millis() - time;
  Serial.println("Screen black");
  Serial.println(time);

  time = millis();
  testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST77XX_WHITE);
  time = millis() - time;
  Serial.println("Screen text drawn");
  Serial.println(time);
}

void loop() {
  // put your main code here, to run repeatedly:
}

void testdrawtext(char *text, int color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.setTextWrap(true);
  tft.print(text);
}

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: CPX + TFT + Arduino

Post by dastels »

It should be 0 & 1.. or A6 and A7.

Reset isn't connected? Hmm.. you might need to. Either to a digital output (A2 or A1). There's a power-on-reset on the display board which should do the job. You could try hooking up a manual reset and see it that helps. I've had that be the case.

Dave

User avatar
lonbaf
 
Posts: 11
Joined: Tue Feb 01, 2022 1:23 pm

Re: CPX + TFT + Arduino

Post by lonbaf »

Thank you Dave! I had skipped reset because it seemed like that was simpler and an option per most of the guides. But I've now tied in the reset to 11 (A2) and set that variable. It didn't change anything when running. I'm not sure what you mean about power-on-reset on the display board or a manual reset. I don't see any physical button or other options for POR.

I've also read that I might need to defin the SCLK and MOSI pins, I've tried that as well, didn't seem to help.

I've tinkered with a bunch of other code options, but so far no good.

Maybe this display just doesn't work?

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: CPX + TFT + Arduino

Post by dastels »

Can you test the display on a different controller board?

"power-on-reset" is a circuit that generates a reset signal when power is first applied. There is one on the display board. Since hooking up a reset didn't help I suspect that's not the issue.

Yes, you may have to specify the pins since SPI isn't usual on the CPX. Then construct the display object as so:

Code: Select all

Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
Dave

User avatar
lonbaf
 
Posts: 11
Joined: Tue Feb 01, 2022 1:23 pm

Re: CPX + TFT + Arduino

Post by lonbaf »

Unfortunately I don't have another controller board. And that bit of code you pasted is exactly how I specified the MOSI and SCLK pins.

Is there some other code that's useful to validate that the TFT is even recognized? I see the backlight blink on, but also I notice if I touch the TFT the light flicker a bit. Maybe there's a loose connection?

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: CPX + TFT + Arduino

Post by dastels »

Touch -> flicker may very well indicate a loose connection. It's worth investigating. How do you have the wires connected?

Dave

User avatar
lonbaf
 
Posts: 11
Joined: Tue Feb 01, 2022 1:23 pm

Re: CPX + TFT + Arduino

Post by lonbaf »

Thank you again Dave!
I posted images of my wiring here:
https://postimg.cc/Lnvchd0M
https://postimg.cc/SjLFFY6R

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: CPX + TFT + Arduino

Post by dastels »

Thanks for these.

The soldering looks questionable. Try retouching it. See https://learn.adafruit.com/adafruit-gui ... -soldering and https://learn.adafruit.com/collins-lab-soldering.

Also, alligator clips are questionable for high speed communication connections like I2C and SPI. The fact that handling it causes problems backs that up. You need a better connection. you can use metal M3 nuts and bolts (wrap the end of the wire around the bolt head, put it through the hole in the CPX and tighten the not on the other side. Sort of like what I did here: https://learn.adafruit.com/circuit-play ... nstruction.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”