Anybody know how to set this display up to run 2 wire on the XIAO ESP32
The example code is for an old arduino using Ports and throws compile errors
The other libraries for tft ST7789 use the more wire setup, also i am using XIAO Grove Expansion Board so i need to use pin sets that are on that board connector
Hi there,
I’m pretty sure it’s not I2C , but SPI with not MISO(9) SCL would be (8)SCLK and MOSI(10) for SDA
ie. no Address associated with it being I2C but try a scanner run first to verify it’s not an I2C obscured address device. Also note with any spi device the init needs to Assert the pins prior to the SPI.begin();
HTH
GL PJ
If it’s the RGB-OLED ST7789 ver. 1.0
I have one around this pile somewhere If I’m able to locate it I’ll try it out and post.
I think you are right, that is about as far as my troubleshooting has got me
The problem being that XIAO Expansion boards do not expose 8 and 10 together in a port
So i need a software solution
Can i define any pin, i think that was what the original “Fast” lib was trying to do was bit bang the output… I am sure it is something simple i dont know YET… lol I tried many different libs and have not gotten it to work, and i think a large part of the problem is the grove connector,… no one else is writing libs or tutorials to service this ecosystem
I am wondering if their is a 2 wire constructor that i do not know
Remember I posed the question of Grove SPI on the Discord… but did not get any engagement!
Maybe Citric would know… but I try not to monopolize
I dont like being Helplessly Hopeless … or Hoplessly Helpless…
Looks good, BRIGHT!! I’ll try the Nrf52840 and ESP32’s as time permits. Long and short of it is it’s not I2C and probably needs SPI to run on the others.
HTH
GL PJ
Thanks boss… I also have been working… I pulled out my male and female dupont connector to Grove connectors and hardwired
Also working on a source code that had a bunch of unnecessary extras and trying to clean it up … right now the code is blocking my serial montor… as soon as the code uploads the USB link goes down… i think the code is manipulating the pins the USB is on…
Hi there,
-1 for the reset , makes it use the arduino’s or mcu’s , You must define a CS even if you don’t use one the LIB requires it. also you have to Set and reset the SCL and SDA pins prior to the Begin();(that’s what the FAST lib is doing also.
on the uno it only worked on the PINS allowed to be spi pins, the i2c pins were a no go as well.
HTH
GL PJ
/***************************************************
This is a library for the ST7789 IPS SPI display.
****************************************************/
#include <Adafruit_GFX.h> // Core graphics library by Adafruit
#include <Arduino_ST7789.h> // Hardware-specific library for ST7789 (with or without CS pin)
#include <SPI.h>
#define TFT_DC -1
#define TFT_RST -1
#define TFT_MOSI 10 // for hardware SPI data pin (all of available pins)
#define TFT_SCLK 8 // for hardware SPI sclk pin (all of available pins)
Arduino_ST7789 tft = Arduino_ST7789(TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK); //for display without CS pin
//Arduino_ST7789 tft = Arduino_ST7789(TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_CS); //for display with CS pin
float p = 3.1415926;
void setup(void)
{//Begin Main Setup
Serial.begin(19200);
Serial.println("Hello! ST7789 TFT Test");
tft.init(240, 240); // initialize a ST7789 chip, 240x240 pixels
}// End Main Setup
void testlines(uint16_t color)
{//Begin testlines
tft.fillScreen(BLACK);
for (int16_t x=0; x < tft.width(); x+=6)
{//Begin for
tft.drawLine(0, 0, x, tft.height()-1, color);
}// End for
for (int16_t y=0; y < tft.height(); y+=6)
{//Begin for
tft.drawLine(0, 0, tft.width()-1, y, color);
}// End for
tft.fillScreen(BLACK);
for (int16_t x=0; x < tft.width(); x+=6)
{//Begin for
tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);
}// End for
for (int16_t y=0; y < tft.height(); y+=6)
{//Begin for
tft.drawLine(tft.width()-1, 0, 0, y, color);
}// End for
tft.fillScreen(BLACK);
for (int16_t x=0; x < tft.width(); x+=6)
{//Begin for
tft.drawLine(0, tft.height()-1, x, 0, color);
}// End for
for (int16_t y=0; y < tft.height(); y+=6)
{//Begin for
tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);
}// End for
tft.fillScreen(BLACK);
for (int16_t x=0; x < tft.width(); x+=6)
{//Begin for
tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);
}// End for
for (int16_t y=0; y < tft.height(); y+=6)
{//Begin for
tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);
}// End for
}// End testlines
void testdrawtext(char *text, uint16_t color)
{//Begin testdrawtext
tft.setCursor(0, 0);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
}// End testdrawtext
void testfastlines(uint16_t color1, uint16_t color2)
{//Begin testfastlines
tft.fillScreen(BLACK);
for (int16_t y=0; y < tft.height(); y+=5)
{//Begin for
tft.drawFastHLine(0, y, tft.width(), color1);
}// End for
for (int16_t x=0; x < tft.width(); x+=5)
{//Begin for
tft.drawFastVLine(x, 0, tft.height(), color2);
}// End for
}// End testfastlines
void testdrawrects(uint16_t color)
{//Begin testdrawrects
tft.fillScreen(BLACK);
for (int16_t x=0; x < tft.width(); x+=6)
{//Begin for
tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color);
}// End for
}// End testdrawrects
void testfillrects(uint16_t color1, uint16_t color2)
{//Begin testfillrects
tft.fillScreen(BLACK);
for (int16_t x=tft.width()-1; x > 6; x-=6)
{//Begin for
tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1);
tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2);
}// End for
}// End testfillrects
void testfillcircles(uint8_t radius, uint16_t color)
{//Begin testfillcircles
for (int16_t x=radius; x < tft.width(); x+=radius*2)
{//Begin for-1
for (int16_t y=radius; y < tft.height(); y+=radius*2)
{//Begin for-2
tft.fillCircle(x, y, radius, color);
}// End for-2
}// End for-1
}// End testfillcircles
void testdrawcircles(uint8_t radius, uint16_t color)
{//Begin testdrawcircles
for (int16_t x=0; x < tft.width()+radius; x+=radius*2)
{//Begin for-1
for (int16_t y=0; y < tft.height()+radius; y+=radius*2)
{//Begin for-2
tft.drawCircle(x, y, radius, color);
}// End for-2
}// End for-1
}// End testdrawcircles
void testtriangles()
{//Begin testtriangles
tft.fillScreen(BLACK);
int color = 0xF800;
int t;
int w = tft.width()/2;
int x = tft.height()-1;
int y = 0;
int z = tft.width();
for(t = 0 ; t <= 15; t++)
{//Begin for
tft.drawTriangle(w, y, y, x, z, x, color);
x-=4;
y+=4;
z-=4;
color+=100;
}// End for
}// End testtriangles
void testroundrects()
{//Begin testroundrects
tft.fillScreen(BLACK);
int color = 100;
int i;
int t;
for(t = 0 ; t <= 4; t+=1)
{//Begin for-1
int x = 0;
int y = 0;
int w = tft.width()-2;
int h = tft.height()-2;
for(i = 0 ; i <= 16; i+=1)
{//Begin for-2
tft.drawRoundRect(x, y, w, h, 5, color);
x+=2;
y+=3;
w-=4;
h-=6;
color+=1100;
}// End for-2
color+=100;
}// End for-1
}// End testroundrects
void tftPrintTest()
{//Begin tftPrintTest
tft.setTextWrap(false);
tft.fillScreen(BLACK);
tft.setCursor(0, 30);
tft.setTextColor(RED);
tft.setTextSize(1);
tft.println("Hello DSTIKE");
tft.setTextColor(YELLOW);
tft.setTextSize(2);
tft.println("Hello DSTIKE");
tft.setTextColor(GREEN);
tft.setTextSize(3);
tft.println("Hello DSTIKE");
tft.setTextColor(BLUE);
tft.setTextSize(4);
tft.print(1234.567);
delay(1500);
tft.setCursor(0, 0);
tft.fillScreen(BLACK);
tft.setTextColor(WHITE);
tft.setTextSize(0);
tft.println("DSTIKE!");
tft.setTextSize(1);
tft.setTextColor(GREEN);
tft.print(p, 6);
tft.println(" Want pi?");
tft.println(" ");
tft.print(8675309, HEX); // print 8,675,309 out in HEX!
tft.println(" Print HEX!");
tft.println(" ");
tft.setTextColor(WHITE);
tft.println("Sketch has been");
tft.println("running for: ");
tft.setTextColor(MAGENTA);
tft.print(millis() / 1000);
tft.setTextColor(WHITE);
tft.print(" seconds.");
}// End tftPrintTest
void mediabuttons()
{//Begin mediabuttons
// play
tft.fillScreen(BLACK);
tft.fillRoundRect(25, 10, 78, 60, 8, WHITE);
tft.fillTriangle(42, 20, 42, 60, 90, 40, RED);
delay(500);
// pause
tft.fillRoundRect(25, 90, 78, 60, 8, WHITE);
tft.fillRoundRect(39, 98, 20, 45, 5, GREEN);
tft.fillRoundRect(69, 98, 20, 45, 5, GREEN);
delay(500);
// play color
tft.fillTriangle(42, 20, 42, 60, 90, 40, BLUE);
delay(50);
// pause color
tft.fillRoundRect(39, 98, 20, 45, 5, RED);
tft.fillRoundRect(69, 98, 20, 45, 5, RED);
// play color
tft.fillTriangle(42, 20, 42, 60, 90, 40, GREEN);
tft.setCursor(60, 200);
tft.setTextColor(RED);
tft.setTextSize(4);
tft.println("DSTIKE");
}// End mediabuttons
void tftLoop(void)
{//Begin tftLoop
Serial.println("Begin TFT Loop");
uint16_t time = millis();
tft.fillScreen(BLACK);
time = millis() - time;
Serial.println(time, DEC);
delay(500);
// large block of text
tft.fillScreen(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. ", WHITE);
delay(1000);
// tft print function
tftPrintTest();
delay(2000);
// a single pixel
tft.drawPixel(tft.width()/2, tft.height()/2, GREEN);
delay(500);
// line draw test
testlines(YELLOW);
delay(500);
// optimized lines
testfastlines(RED, BLUE);
delay(500);
testdrawrects(GREEN);
delay(500);
testfillrects(YELLOW, MAGENTA);
delay(500);
tft.fillScreen(BLACK);
testfillcircles(10, BLUE);
testdrawcircles(10, WHITE);
delay(500);
testroundrects();
delay(500);
testtriangles();
delay(500);
mediabuttons();
delay(500);
tft.invertDisplay(true);
delay(500);
tft.invertDisplay(false);
delay(500);
Serial.println("done");
delay(500);
}// End tftLoop
void loop()
{//Begin Main Loop Function
tftLoop(); //tft Demo Loop
}// End Main Loop Function
I got this working on XIAO ESP32C3… i get the serial monitor feedback… but screen is backlight on but screen black
Hi there,
Yea , I dabbled a bit with TFT_eSPI.lib, but you still need to do some SPI transaction code in front of it to get it to work, FYI. Also RUN the “Read_User_Setup.ino” (in examples, under diags) code after you edit your config.h to see the settings.
I have found they must be SPot on and agree with the PINOUTs to work.
HTH
GL PJ
output like this.
[code]
TFT_eSPI ver = 2.4.2
Processor = Generic
Transactions = Yes
Interface = SPI
Display driver = 7789
Display width = 240
Display height = 320
MOSI = GPIO -1
MISO = GPIO -1
SCK = GPIO -1
TFT_CS = GPIO -1
TFT_DC = GPIO -1
TFT_RST = GPIO -1
Font GLCD loaded
Font 2 loaded
Font 4 loaded
Font 6 loaded
Font 7 loaded
Font 8 loaded
Smooth font enabled
Display SPI frequency = 10.00
[/code]
Go watch this Video , to help you make sense of it all.
do you know how to declare the user setup in the code and not the lib? I am thinking an include… but which one do you remove? i know the lib has some error checking to keep you from double defining…
It’s in the first few lines of the TFT_eSPI.h thats loaded by the include of the main LIB. LiB say’s #include user setups selects.h" kinda thing.
GL PJ
also when you are done with edits. copy "USER_SETUP.h " to the root LIBRARY folder for it to take.