Adafruit Feather ESP32-S2 Reverse TFT Help #391
Replies: 8 comments 8 replies
-
Hi, Add this before including LovyanGFX.hpp, the other include (LGFX_AUTODETECT.hpp) is implicit so you probably won't need it after adding the macro.
Adafruit boards have dedicated bootloaders that do a lot of stuff under the hood (e.g. USB magic). The different state at boot may interfer with LGFX autodetect, if adding LFX_AUTODETECT didn't work, you may have to condiser disabling it and use a separate config block. |
Beta Was this translation helpful? Give feedback.
-
So trying a few different variations of what you suggested didn't seem to work either. This variation is one of the ones that got the LCD backlight to turn on but nothing displaying. #define LGFX_FEATHER_ESP32_S2_TFT Doing: #define LGFX_AUTODETECT Results in the screen not lighting up at all. You may be right about a different config block, but I'm just learning how to code, so im unsure what that entails. Thanks! |
Beta Was this translation helpful? Give feedback.
-
If you have a working example with all pinout documented (e.g. TFT_eSPI, Arduino_GFX), it's worth comparing with the pin configuration used in the autodetect sequence If you have a doubt on the autodetect sequence, it's still possible to disable autodetect and create a custom config from the basic config example, and flash it using the default However, troubleshooting this requires more information e.g. you'll have to share details about the IDE/platform versions and settings, and also the sketch. |
Beta Was this translation helpful? Give feedback.
-
So this code works with the display using the Adafruit GFX Library, no surprise there. I went though and checked all the pin outs on the LGFX configs for this board and they all seemed to check out. I also tried going through the adafruit GFX library to see what they are doing differently but that codes above my head and I cant make heads or tails of it. I cant even find where they are defining the Pins. The one thing I did find is that they are using I2C power to power on the TFT, In the code below they define a pin for the power and then set it to high.
Im unsure if this has anything to do with that. I tried setting up the User Settings for this display as well and it compiles but does not work, I can post that code as well if you think it might help. Unsure whats going on here, its probably me since Im new at this.
|
Beta Was this translation helpful? Give feedback.
-
you don't need to find where they are, you just need to know their value, just use your serial console: Serial.printf("Pin value of TFT_I2C_POWER=%d\n", TFT_I2C_POWER ); you won't find those pin definitions in the driver folder anyway, they're in the variants folder from the espressif core: ~/.arduino15/packages/esp32/hardware/esp32/2.0.7/variants/adafruit_feather_esp32_v2/pins_arduino.h I don't have a feather to test with, so I can't use printf to reveal those values, but ideally you should fill all the missing blanks in this table (I've filled the LGFX part from the autodectect sequence) and confirm that everything matches.
yes please do post the LGFX snippet, it should have both Panel_ST7789 and Light_PWM (TFT_BL) objects |
Beta Was this translation helpful? Give feedback.
-
Also heres the LGFX Snippet for the edited User Settings.
#include <LovyanGFX.hpp>
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ST7789 _panel_instance;
lgfx::Bus_SPI _bus_instance;
lgfx::Light_PWM _light_instance;
public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.spi_host = SPI2_HOST;
cfg.spi_mode = 0;
cfg.freq_write = 40000000;
cfg.freq_read = 16000000;
cfg.spi_3wire = true;
//cfg.use_lock = true;
cfg.dma_channel = SPI_DMA_CH_AUTO;
cfg.pin_sclk = 36;
cfg.pin_mosi = 35;
cfg.pin_miso = -1;
cfg.pin_dc = 39;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{
auto cfg = _panel_instance.config();
cfg.pin_cs = 7; // (-1 = disable)
cfg.pin_rst = 40; // (-1 = disable)
cfg.pin_busy = -1; // (-1 = disable)
cfg.panel_width = 135;
cfg.panel_height = 240;
cfg.offset_x = 52;
cfg.offset_y = 40;
cfg.offset_rotation = 1;
cfg.dummy_read_pixel = 8;
cfg.dummy_read_bits = 1;
cfg.readable = false;
cfg.invert = true;
cfg.rgb_order = false;
//cfg.dlen_16bit = false;
//cfg.bus_shared = true;
_panel_instance.config(cfg);
}
{
auto cfg = _light_instance.config();
cfg.pin_bl = 45;
cfg.invert = false;
cfg.freq = 12000;
//cfg.pwm_channel = 7;
_light_instance.config(cfg);
_panel_instance.setLight(&_light_instance);
}
setPanel(&_panel_instance);
}
};
LGFX display;
void setup(void)
{
display.init();
display.setTextSize((std::max(display.width(), display.height()) + 255) >> 8);
if (display.touch())
{
if (display.width() < display.height()) display.setRotation(display.getRotation() ^ 1);
display.setTextDatum(textdatum_t::middle_center);
display.drawString("touch the arrow marker.", display.width()>>1, display.height() >> 1);
display.setTextDatum(textdatum_t::top_left);
std::uint16_t fg = TFT_WHITE;
std::uint16_t bg = TFT_BLACK;
if (display.isEPD()) std::swap(fg, bg);
display.calibrateTouch(nullptr, fg, bg, std::max(display.width(), display.height()) >> 3);
}
display.fillScreen(TFT_BLACK);
}
uint32_t count = ~0;
void loop(void)
{
display.startWrite();
display.setRotation(++count & 7);
display.setColorDepth((count & 8) ? 16 : 24);
display.setTextColor(TFT_WHITE);
display.drawNumber(display.getRotation(), 16, 0);
display.setTextColor(0xFF0000U);
display.drawString("R", 30, 16);
display.setTextColor(0x00FF00U);
display.drawString("G", 40, 16);
display.setTextColor(0x0000FFU);
display.drawString("B", 50, 16);
display.drawRect(30,30,display.width()-60,display.height()-60,count*7);
display.drawFastHLine(0, 0, 10);
display.endWrite();
int32_t x, y;
if (display.getTouch(&x, &y)) {
display.fillRect(x-2, y-2, 5, 5, count*7);
}
}
|
Beta Was this translation helpful? Give feedback.
-
So the Code snippet you pasted worked when set to false. I added it at the beginning of the code I've been working on and it finally displays. There seems to be an issue with deep sleep waking up randomly after it goes to sleep but I can troubleshoot that more later. Is there a way I can simplify this code so that I don't need to call it all at the beginning of my sketch? Also I wasn't able to find the values for Mosi and SCK even with the changes to the names, I did however notice something in adafruit_ST7789.cpp.
it appears that those values aren't needed for the hardware spi? At least that's what I'm assuming since that's what I called at the top of the adafruit code snippet. Maybe thats why I couldnt get values for them? |
Beta Was this translation helpful? Give feedback.
-
Thanks again for your help, This solved my issues, I'm posting the User Setup below that I'm using for the Adafruit ESP32 Reverse Feather TFT if anyone else has issues Hopeful this will help. Also I changed the frequency of the write to 80000000 because I was getting a nasty flicker when ever the tft turned on. Idk if this is the right value but it seems to work and eliminate the flicker. Thanks Again @tobozo !! #include <LovyanGFX.hpp>
#include "driver/rtc_io.h" //you can ignore this if you aren't using RTC memory to pullup deepsleep pins
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ST7789 _panel_instance;
lgfx::Bus_SPI _bus_instance;
lgfx::Light_PWM _light_instance;
public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.spi_host = SPI2_HOST; // not sure about this, comment out if unsure
cfg.spi_mode = 0; // not sure about this, comment out if unsure
cfg.freq_write = 80000000;
cfg.freq_read = 16000000;
cfg.dma_channel = SPI_DMA_CH_AUTO;
bool use_i2c_pins = false; // change this to test one or another confirugation
if( use_i2c_pins ) {
cfg.pin_sclk = SCL;
cfg.pin_mosi = SDA;
cfg.pin_miso = -1;
cfg.spi_3wire = true; // only necessary when pin_miso=-1
} else {
cfg.pin_mosi = MOSI;
cfg.pin_sclk = SCK;
cfg.pin_miso = MISO;
}
cfg.pin_dc = TFT_DC;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{
auto cfg = _panel_instance.config();
cfg.pin_cs = TFT_CS; // (-1 = disable)
cfg.pin_rst = TFT_RST; // (-1 = disable)
cfg.pin_busy = -1; // (-1 = disable)
cfg.panel_width = 135;
cfg.panel_height = 240;
cfg.offset_x = 52;
cfg.offset_y = 40;
cfg.offset_rotation = 1;
cfg.dummy_read_pixel = 8;
cfg.dummy_read_bits = 1;
cfg.readable = false;
cfg.invert = true;
cfg.rgb_order = false;
_panel_instance.config(cfg);
}
{
auto cfg = _light_instance.config();
cfg.pin_bl = TFT_BACKLITE;
cfg.invert = false;
cfg.freq = 12000;
_light_instance.config(cfg);
_panel_instance.setLight(&_light_instance);
}
setPanel(&_panel_instance);
}
};
LGFX display;
|
Beta Was this translation helpful? Give feedback.
-
Hi, sorry if this questions a little dumb. But I cant seem to get my display Adafruit Display to work with this library. I was previously using the TTGO T-Display and using this code at the start of my sketch (Which Worked) :
#define LGFX_AUTODETECT
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
Though when I try this on my Adafruit display it doesn't seem to work. I even tried defining the exact display with:
#define LGFX_FEATHER_ESP32_S2_TFT
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>
But this didn't seem to work either. Is there a specific way you need to set up this display or am I just missing something
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions