ST7789 Parallel Communication

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
masonhoward
 
Posts: 2
Joined: Fri May 05, 2023 6:59 pm

ST7789 Parallel Communication

Post by masonhoward »

First time posting, hope this in the right section. I've had a 1.3" TFT for a few years (without the breakout board) that I'm trying to set up using parallel communication (only got it working with SPI so far). I decided to use ChatGPT to help write the code. It nailed the SPI code on the first try, so I asked it to generate the code for parallel communication.

It produced the code below. It compiles fine, and defines 8 data pins for the bus using MCUFRIEND_kbv library. My current guess is bad timing or initialization is the problem, but I don't really know where to start. Could I get some human opinions/solutions? Thanks!

#include <MCUFRIEND_kbv.h>

#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 8
#define TFT_WR 11
#define TFT_RD 24

#define TFT_D0 0
#define TFT_D1 1
#define TFT_D2 2
#define TFT_D3 3
#define TFT_D4 4
#define TFT_D5 5
#define TFT_D6 6
#define TFT_D7 7

MCUFRIEND_kbv tft;

#define BLACK 0x0000
#define WHITE 0xFFFF
#define RED 0xF800
#define GREEN 0x07E0
#define BLUE 0x001F

void setup() {
// Set bus direction and initialize
pinMode(TFT_D0, OUTPUT);
pinMode(TFT_D1, OUTPUT);
pinMode(TFT_D2, OUTPUT);
pinMode(TFT_D3, OUTPUT);
pinMode(TFT_D4, OUTPUT);
pinMode(TFT_D5, OUTPUT);
pinMode(TFT_D6, OUTPUT);
pinMode(TFT_D7, OUTPUT);
pinMode(TFT_WR, OUTPUT);
pinMode(TFT_RD, OUTPUT);
pinMode(TFT_DC, OUTPUT);
pinMode(TFT_CS, OUTPUT);
pinMode(TFT_RST, OUTPUT);

digitalWrite(TFT_WR, HIGH);
digitalWrite(TFT_RD, HIGH);
digitalWrite(TFT_DC, HIGH);
digitalWrite(TFT_CS, HIGH);
digitalWrite(TFT_RST, HIGH);

digitalWrite(TFT_D0, LOW);
digitalWrite(TFT_D1, LOW);
digitalWrite(TFT_D2, LOW);
digitalWrite(TFT_D3, LOW);
digitalWrite(TFT_D4, LOW);
digitalWrite(TFT_D5, LOW);
digitalWrite(TFT_D6, LOW);
digitalWrite(TFT_D7, LOW);

tft.begin(0x7789); // Initialize display driver
tft.setRotation(3);
tft.fillScreen(GREEN);
}

void loop() {
// Draw some shapes on the screen
tft.fillScreen(WHITE);
tft.fillRoundRect(40, 40, 160, 160, 20, GREEN);
tft.fillCircle(120, 120, 40, RED);
tft.fillRect(60, 100, 120, 40, BLUE);
tft.setCursor(50, 50);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.println("Hello, World!");
delay(1000);
}

User avatar
adafruit_support_mike
 
Posts: 67391
Joined: Thu Feb 11, 2010 2:51 pm

Re: ST7789 Parallel Communication

Post by adafruit_support_mike »

Step 1: Don't use ChatGPT to write code.

ChatGPT is an ambitious copy-and-paste system. It doesn't have a concept of code 'meaning' or 'doing' things, only a table of strings that tend to occur together with high probability. The absolute best case is that it will parrot back code that someone else wrote for the same purpose.

The typical case is that you'll get a crazy-quilt of lines that occur within a certain information-theoretical 'distance' from the keywords it extracted from your input.

The fact that people can get code generated by ChatGPT to run is neither new nor interesting. It's merely a new front-end for genetic programming techniques that have been around since the 1980s. With enough generations of random modification and a utility function (in this case, a user deciding whether the code does what they want), you can generate practically anything.


I can't see any evidence that the MCUFRIEND_kbv library even supports parallel control of an ST7789 display. That library inherits much of its basic code from our GFX library, and any support for ST7789 displays would come from our ST7735/ST7789 library:

https://github.com/adafruit/Adafruit-ST7735-Library

which also has no support for parallel control of that display driver.


A bit of Googling located this TFT library, which does seem to support parallel control and ST7789 displays:

https://github.com/Bodmer/TFT_eSPI

Take a look through the documentation and see if it supports 'parallel control -of- ST7789 displays'.

User avatar
masonhoward
 
Posts: 2
Joined: Fri May 05, 2023 6:59 pm

Re: ST7789 Parallel Communication

Post by masonhoward »

Thank you! I'll give that library a shot!

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

Return to “Microcontrollers”