Bodmer / TFT_eSPI

Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips
Other
3.69k stars 1.07k forks source link

ST7789 Screen (no CS pin) issues getting it working #2427

Closed fenixsong closed 1 year ago

fenixsong commented 1 year ago
          > Changling spi0 to spi1 in the TFT_eSPI.cpp and Processors/TFT_eSPI_RP2040.h and Processors/TFT_eSPI_RP2040.c should work.

LEt me know how you get on and it can be made a configuration option (as is used for the STM32 processors).

As a side note, I can confirm that replacing spi0 with spi1 seems to work fine. Touch_calibrate and Bouncy_circles both work fine on spi1 using Earle Philhower core.

_Originally posted by @justinschoeman in https://github.com/Bodmer/TFT_eSPI/issues/1278#issuecomment-940392826_

I appreciate the guidance from this post but can't seem to get anything to work. A different screen but similar and common type. GMT130-V1.0 From GoldenMorning (looks the same as many off of Amazon etc.)

EDIT: I just realized I ended up here from a link from the arduino-pico site... very sorry - I will adjust this post as I try more from this library and learn more, but the same type of questions apply. I'll adjust soon if I still have issues.

Could you please show the code you used to get it working (and pin out)? I've tried every combo I can think of but can't get it to display anything. I don't know what is meant when devs here say "wired GP2 to GP10" etc...is that a thing? What way do you mean if not a software config?

Also, of important note: The screen does work! and with Arduino. I had a Teensy 3.6 lying around and tried it and it works fine; displaying the whole demo perfectly. So just wanted to clear that up that I know the screen works, just not with the pico and arduino-pico. :(

This is the code that works on the Teensy (tried it and many variations on pico)

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>

  // For the breakout board, you can use any 2 or 3 pins.
  // These pins will also work for the 1.8" TFT shield.
#define TFT_CS        -1
#define TFT_RST       0 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC        1

// OPTION 1 (recommended) is to use the HARDWARE SPI pins, which are unique
// to each board and not reassignable. For Arduino Uno: MOSI = pin 11 and
// SCLK = pin 13. This is the fastest mode of operation and is required if
// using the breakout board's microSD card.

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

// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.
//#define TFT_MOSI 3  // Data out
//#define TFT_SCLK 2  // Clock out

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

float p = 3.1415926;

void setup(void) {
  //SPI.setSCK(2);
  //SPI.setRX(4);
  //SPI.setTX(3);
  //SPI.setDataMode(SPI_MODE3);
  Serial.begin(9600);
  while (!Serial);
  Serial.println(F("Hello! Teensy ST77xx TFT Test"));

//SPI.begin(true);
  // Use this initializer (uncomment) if using a 1.3" or 1.54" 240x240 TFT:
tft.init(240, 240, SPI_MODE3);           // Init ST7789 240x240
tft.setSPISpeed(1000000);
  uint16_t time = millis();
  tft.fillScreen(ST77XX_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  // large block of text
  tft.fillScreen(ST77XX_BLACK);
//  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);
//  delay(1000);

  // tft print function!
  tftPrintTest();
  delay(4000);

Code of what exactly works here would be very appreciated and the pinout that is required. I also tried various SPI or SPI1 (&SPI1) combos to no avail - but could use guidance on what really works for that - I could use SPI0 or SPI1...it doesn't matter here - anything that would work. Thank you, please help!

fenixsong commented 1 year ago

Sorry about this- its still an issue for me but this is in the wrong place for now. I'll try the discussion board until I learn more about what's going on.