Skip to content

Instantly share code, notes, and snippets.

@sukesh-ak
Created November 30, 2022 16:04
Show Gist options
  • Save sukesh-ak/7bcafd2227a2c2fa727208f4ffa47308 to your computer and use it in GitHub Desktop.
Save sukesh-ak/7bcafd2227a2c2fa727208f4ffa47308 to your computer and use it in GitHub Desktop.
Makerfabs ESP32-S3 3.5" Parallel TFT - ESP32S335D - Test sample using LovyanGFX driver
/*
Simple Touch Drawing sample for Makerfabs ESP32-S3 3.5" Parallel TFT ( ESP32S335D )
Requirements:
- Development board : Makerfabs ESP32-S3 3.5" 16Bit Parallel TFT
- Arduino Library - Display/Touch : LovyanGFX
- Board selected in Arduino : ESP32S3 Dev Module
*/
#define LGFX_USE_V1 // set to use new version of library
#include <LovyanGFX.hpp> // main library
#include <driver/i2c.h>
// Portrait
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
static constexpr int I2C_PORT_NUM = I2C_NUM_0;
static constexpr int I2C_PIN_SDA = 38;
static constexpr int I2C_PIN_SCL = 39;
static constexpr int I2C_PIN_INT = 40;
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ILI9488 _panel_instance;
lgfx::Bus_Parallel16 _bus_instance;
lgfx::Light_PWM _light_instance;
lgfx::Touch_FT5x06 _touch_instance;
public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.port = 0;
cfg.freq_write = 20000000;
cfg.pin_wr = 35;
cfg.pin_rd = 48;
cfg.pin_rs = 36;
cfg.pin_d0 = 47;
cfg.pin_d1 = 21;
cfg.pin_d2 = 14;
cfg.pin_d3 = 13;
cfg.pin_d4 = 12;
cfg.pin_d5 = 11;
cfg.pin_d6 = 10;
cfg.pin_d7 = 9;
cfg.pin_d8 = 3;
cfg.pin_d9 = 8;
cfg.pin_d10 = 16;
cfg.pin_d11 = 15;
cfg.pin_d12 = 7;
cfg.pin_d13 = 6;
cfg.pin_d14 = 5;
cfg.pin_d15 = 4;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{
auto cfg = _panel_instance.config();
cfg.pin_cs = -1;
cfg.pin_rst = -1;
cfg.pin_busy = -1;
cfg.memory_width = TFT_WIDTH;
cfg.memory_height = TFT_HEIGHT;
cfg.panel_width = TFT_WIDTH;
cfg.panel_height = TFT_HEIGHT;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.offset_rotation = 0;
cfg.dummy_read_pixel = 8;
cfg.dummy_read_bits = 1;
cfg.readable = true;
cfg.invert = false;
cfg.rgb_order = false;
cfg.dlen_16bit = true;
cfg.bus_shared = true;
_panel_instance.config(cfg);
}
{
auto cfg = _light_instance.config();
cfg.pin_bl = 45;
cfg.invert = false;
cfg.freq = 44100;
cfg.pwm_channel = 7;
_light_instance.config(cfg);
_panel_instance.setLight(&_light_instance);
}
{
auto cfg = _touch_instance.config();
cfg.x_min = 0;
cfg.x_max = TFT_WIDTH;
cfg.y_min = 0;
cfg.y_max = TFT_HEIGHT;
cfg.pin_int = I2C_PIN_INT;
cfg.bus_shared = true;
cfg.offset_rotation = 0;
cfg.i2c_port = I2C_PORT_NUM;
cfg.i2c_addr = 0x38;
cfg.pin_sda = I2C_PIN_SDA;
cfg.pin_scl = I2C_PIN_SCL;
cfg.freq = 400000;
_touch_instance.config(cfg);
_panel_instance.setTouch(&_touch_instance);
}
setPanel(&_panel_instance);
}
};
static LGFX lcd; // declare display variable
// Variables for touch x,y
static int32_t x,y;
void setup(void)
{
lcd.init();
// Setting display to landscape
if (lcd.width() < lcd.height()) lcd.setRotation(lcd.getRotation() ^ 1);
lcd.setCursor(0,0);
lcd.printf("Ready to touch & draw!");
}
void loop()
{
if (lcd.getTouch(&x, &y)) {
lcd.fillRect(x-2, y-2, 5, 5, TFT_RED);
lcd.setCursor(380,0);
lcd.printf("Touch:(%03d,%03d)", x,y);
}
}
@ammaree
Copy link

ammaree commented Dec 11, 2022

OK, have changed to testing with ESP32-TUX, compiles and links but with some warnings.
/Users/andremaree/DevSpace/z-sdk/esp-idf/components/hal/esp32s3/include/hal/gdma_ll.h: In function 'void gdma_ll_rx_enable_interrupt(gdma_dev_t*, uint32_t, uint32_t, bool)': /Users/andremaree/DevSpace/z-sdk/esp-idf/components/hal/esp32s3/include/hal/gdma_ll.h:89:46: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile] 89 | dev->channel[channel].in.int_ena.val |= mask; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ /Users/andremaree/DevSpace/z-sdk/esp-idf/components/hal/esp32s3/include/hal/gdma_ll.h:91:46: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile] 91 | dev->channel[channel].in.int_ena.val &= ~mask; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ /Users/andremaree/DevSpace/z-sdk/esp-idf/components/hal/esp32s3/include/hal/gdma_ll.h: In function 'void gdma_ll_tx_enable_interrupt(gdma_dev_t*, uint32_t, uint32_t, bool)': /Users/andremaree/DevSpace/z-sdk/esp-idf/components/hal/esp32s3/include/hal/gdma_ll.h:327:47: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile] 327 | dev->channel[channel].out.int_ena.val |= mask; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ /Users/andremaree/DevSpace/z-sdk/esp-idf/components/hal/esp32s3/include/hal/gdma_ll.h:329:47: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile] 329 | dev->channel[channel].out.int_ena.val &= ~mask; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ In file included from /Users/andremaree/DevSpace/z-projects/ESP32-TUX/components/LovyanGFX/src/lgfx/v1/platforms/esp32s3/Bus_RGB.cpp:32: /Users/andremaree/DevSpace/z-sdk/esp-idf/components/hal/esp32s3/include/hal/lcd_ll.h: In function 'void lcd_ll_enable_interrupt(lcd_cam_dev_t*, uint32_t, bool)': /Users/andremaree/DevSpace/z-sdk/esp-idf/components/hal/esp32s3/include/hal/lcd_ll.h:557:33: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile] 557 | dev->lc_dma_int_ena.val |= mask & 0x03; | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ /Users/andremaree/DevSpace/z-sdk/esp-idf/components/hal/esp32s3/include/hal/lcd_ll.h:559:33: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile] 559 | dev->lc_dma_int_ena.val &= ~(mask & 0x03); | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~

and

[1164/1170] Building CXX object esp-idf/main/CMakeFiles/__idf_main.dir/main.cpp.objIn file included from /Users/andremaree/DevSpace/z-projects/ESP32-TUX/components/lvgl/src/core/lv_obj.h:140, from /Users/andremaree/DevSpace/z-projects/ESP32-TUX/components/lvgl/lvgl.h:35, from /Users/andremaree/DevSpace/z-projects/ESP32-TUX/main/helpers/helper_display.hpp:27, from /Users/andremaree/DevSpace/z-projects/ESP32-TUX/main/main.hpp:73, from /Users/andremaree/DevSpace/z-projects/ESP32-TUX/main/main.cpp:26: /Users/andremaree/DevSpace/z-projects/ESP32-TUX/components/lvgl/src/core/lv_obj_style.h: In function 'void lv_obj_remove_style_all(_lv_obj_t*)': /Users/andremaree/DevSpace/z-projects/ESP32-TUX/components/lvgl/src/core/lv_obj_style.h:94:48: warning: bitwise operation between different enumeration types '<unnamed enum>' and '<unnamed enum>' is deprecated [-Wdeprecated-enum-enum-conversion] 94 | lv_obj_remove_style(obj, NULL, LV_PART_ANY | LV_STATE_ANY); | ~~~~~~~~~~~~^~~~~~~~~~~~~~ In file included from /Users/andremaree/DevSpace/z-projects/ESP32-TUX/main/main.hpp:87, from /Users/andremaree/DevSpace/z-projects/ESP32-TUX/main/main.cpp:26: /Users/andremaree/DevSpace/z-projects/ESP32-TUX/main/gui.hpp: In function 'void create_footer(lv_obj_t*)': /Users/andremaree/DevSpace/z-projects/ESP32-TUX/main/gui.hpp:395:63: warning: bitwise operation between different enumeration types '<unnamed enum>' and '<unnamed enum>' is deprecated [-Wdeprecated-enum-enum-conversion] 395 | lv_obj_add_style(footerButtons, &style_glow,LV_PART_ITEMS | LV_BTNMATRIX_CTRL_CHECKED); // selected | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

Just to be sure, are these normal and you also get them, or is there something else I must look for ?

@sukesh-ak
Copy link
Author

I hope you are using IDF 5.0 released version and not the main branch which is being called IDF 5.1 I think.

If it's just warning you can ignore for now. Some of them are because of LVGL or C++ related.
https://stackoverflow.com/questions/7840714/on-enum-and-bitwise-operation

@yesnoj
Copy link

yesnoj commented Jul 11, 2023

Hi, thanks a lot for your config!Now i can use this one with my project!
I've just an issue, i'm trying to use this one with the LVGL library, i finally get working the screen, but i still can't get the touch working.
Can you help me?
Thanks in advance!!!

@sukesh-ak
Copy link
Author

sukesh-ak commented Jul 12, 2023

@yesnoj

You can check the full template project called ESP32-TUX
https://github.com/sukesh-ak/ESP32-TUX

@barnbrooksystems
Copy link

Finally an example that works for the Makerfabs 4.3 display - thank you. They should be paying you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment