Skip to content

Instantly share code, notes, and snippets.

@sukesh-ak
Last active March 2, 2024 00:15
Show Gist options
  • Save sukesh-ak/610508bc84779a26efdcf969bf51a2d1 to your computer and use it in GitHub Desktop.
Save sukesh-ak/610508bc84779a26efdcf969bf51a2d1 to your computer and use it in GitHub Desktop.
WT32-SC01-Plus Test sample using LovyanGFX driver
/*
Simple Touch Drawing sample for WT32-SC01-Plus_ESP32-S3
Requirements:
- Development board : WT32-SC01-Plus_ESP32-S3
- 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 "esp32-hal-psram.h"
// Portrait
#define TFT_WIDTH 320
#define TFT_HEIGHT 480
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ST7796 _panel_instance; // ST7796UI
lgfx::Bus_Parallel8 _bus_instance; // MCU8080 8B
lgfx::Light_PWM _light_instance;
lgfx::Touch_FT5x06 _touch_instance;
public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.freq_write = 40000000;
cfg.pin_wr = 47;
cfg.pin_rd = -1;
cfg.pin_rs = 0;
// LCD data interface, 8bit MCU (8080)
cfg.pin_d0 = 9;
cfg.pin_d1 = 46;
cfg.pin_d2 = 3;
cfg.pin_d3 = 8;
cfg.pin_d4 = 18;
cfg.pin_d5 = 17;
cfg.pin_d6 = 16;
cfg.pin_d7 = 15;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{
auto cfg = _panel_instance.config();
cfg.pin_cs = -1;
cfg.pin_rst = 4;
cfg.pin_busy = -1;
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 = false;
cfg.invert = true;
cfg.rgb_order = false;
cfg.dlen_16bit = false;
cfg.bus_shared = false;
_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 = 319;
cfg.y_min = 0;
cfg.y_max = 479;
cfg.pin_int = 7;
cfg.bus_shared = true;
cfg.offset_rotation = 0;
cfg.i2c_port = 1;//I2C_NUM_1;
cfg.i2c_addr = 0x38;
cfg.pin_sda = 6;
cfg.pin_scl = 5;
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!\n");
lcd.setCursor(0,300);
// Get flash size and display
lcd.printf("FLASH size: %d bytes",ESP.getFlashChipSize());
lcd.setCursor(0,310);
// Initialize PSRAM (if available) and show the total size
if (psramFound()) {
lcd.printf("PSRAM size: %d bytes",heap_caps_get_total_size(MALLOC_CAP_SPIRAM));
} else {
lcd.printf("No PSRAM found.");
}
}
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);
}
}
@cdctx07
Copy link

cdctx07 commented Jan 28, 2023

Thanks for this! I bought one of these and had so much trouble with it. It eventually got to where it would only connect to my PC for a second, drop, reconnect, drop, etc. I got a new one and have started with this code, and this new one is playing nice. I can now work from this :)

@sukesh-ak
Copy link
Author

Thanks for this! I bought one of these and had so much trouble with it. It eventually got to where it would only connect to my PC for a second, drop, reconnect, drop, etc. I got a new one and have started with this code, and this new one is playing nice. I can now work from this :)

You can check the fully built sample template here

https://github.com/sukesh-ak/ESP32-TUX

@cdctx07
Copy link

cdctx07 commented Jan 29, 2023

Oh yeah, I got that to work on the first WT32-SC01, but I'm more familiar working with Arduino, so this code let me check that all does actually work with this board and Arduino. I need to become better with ESP-IDF.

@sukesh-ak
Copy link
Author

Oh yeah, I got that to work on the first WT32-SC01, but I'm more familiar working with Arduino, so this code let me check that all does actually work with this board and Arduino. I need to become better with ESP-IDF.

Difference between Arduino & ESP-IDF.
sukesh-ak/ESP32-TUX#19

@Hienix
Copy link

Hienix commented Mar 4, 2023

Finally a sketch that I could use and know that my WT32-SC01 Plus is working fine, the touch part wasn't working. Thank you for the great job.

@sukesh-ak
Copy link
Author

Finally a sketch that I could use and know that my WT32-SC01 Plus is working fine, the touch part wasn't working. Thank you for the great job.

Thanks. A full project with source is here.
https://github.com/sukesh-ak/ESP32-TUX

Also you can flash it from
https://tux.sukesh.me

@ScitiveX
Copy link

Very Helpful, finally solved my problem. Thanks

@thecodingfrog
Copy link

Damn I can't get it to work :(

@jkrasinger
Copy link

@cdctx07 I have the same problem with connecting, disconnecting, connecting ... with my Wt32 SC01 Plus. I can load the sketch, but it does not start. Is this really a problem with the HW. Have you replaced your SC01?

@thecodingfrog
Copy link

@cdctx07 I have the same problem with connecting, disconnecting, connecting ... with my Wt32 SC01 Plus. I can load the sketch, but it does not start. Is this really a problem with the HW. Have you replaced your SC01?

I was able to run another project with platform.io

@Bobby2000
Copy link

@cdctx07 I have the same problem with connecting, disconnecting, connecting ... with my Wt32 SC01 Plus. I can load the sketch, but it does not start. Is this really a problem with the HW. Have you replaced your SC01?

Not sure if this is related? A faint memory tells me I ran into a similar issue some time ago. As far as I remember I solved the issue by lowering the upload speed.

@ScitiveX
Copy link

@cdctx07 I have the same problem with connecting, disconnecting, connecting ... with my Wt32 SC01 Plus. I can load the sketch, but it does not start. Is this really a problem with the HW. Have you replaced your SC01?

I also had this connecting disconnecting problem but later came to know that it had selected hardware esp32_sc_01 on 8ms.xyz platform while this board is esp32_sc_01 PLUS so for PLUS version ZX3D50CE02S_USRC_4832 is to be selected. And after that when I burn the bin file with the help of esp tool, the problem is solved.

@sukesh-ak
Copy link
Author

Connection/Disconnection issue is related to ESP32-S3 native USB switching.
Its better to get the debugger board from Wireless tag to make life easier.

Link for purchase is here

@jkrasinger
Copy link

jkrasinger commented May 21, 2023

After pulling GPIO0 to ground, pushing the res key and releasing GPIO0 again, the download of code is perfectly working. But just a few minutes ago i found i very interesting problem: After loading the Code the screen stays dark, i can see the connect/disconnect in my syslog. Yesterday evening i stopped working with this board and today, just before, i connected the board to a USB power Supply ... and the code was running perfectly. I disconnected again and reconnected to my PC, it was working again. Then I disconnected once more and reconnected again, and now nothing happens anymore? Must i wait until tomorrow to have the code running again? Has anybody seen this problem also?
Does anybody know exactly which board to select and/or build flags to use in platformio for the WT32 SC01 plus?

@sukesh-ak
Copy link
Author

sukesh-ak commented May 21, 2023

@jkrasinger

Check the discussion here
sukesh-ak/ESP32-TUX#18

@jkrasinger
Copy link

jkrasinger commented May 21, 2023

@sukesh-ak

Thanks for the link, but i do not have an upload problem, as i fixed it as described in my last comment in the same manner as in the discussion in your link.
My problem is that the sketch does not start after uploading, even after powering down and up again. I must wait ~10 minutes (maybe a little bit less ) before the sketch can run.

@sukesh-ak
Copy link
Author

That does not sound like a hardware issue :)

@thecodingfrog
Copy link

I didn't experienced this using pio

@searayca
Copy link

This worked great. I was about to send board back. Thank you.

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