How to Run a Demo with M5stack

Description

Good,day!
I want to know how to run a demo in M5stack.

What MCU/Processor/Board and compiler are you using?

M5stack , VSCode with PlatformIO , LittlevGL(v6)

What do you want to achieve?

I want to use a LittlevGL in the screen that is implemented in the M5stack.

What have you tried so far?

I matched the pin assignment of the TFT_eSPI library to the M5stack.
However, I can only see the sandstorm.

Code to reproduce

TFT_eSPI/User_Setup.h
// For the M5Stack module use these #define lines
#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS   14  // Chip select control pin
#define TFT_DC   27  // Data Command control pin
#define TFT_RST  33  // Reset pin (could connect to Arduino RESET pin)
#define TFT_BL   32  // LED back-light (required for M5Stack)

Screenshot and/or video

Hi,
AFAIK the M5 has special version of the TFT_eSPI library. Are you using their special version or the standard one?

Thanks, Pablo.
I didn’t even know a special version existed.
I’ve been using the same TFT_ eSPI library for some time now.
It’s probably the standard version.
Where’s the special TFT_eSPI library?

So I’ve take simple look to the TFT_eSPI repo and… look ma’ what I’ve found: https://github.com/Bodmer/TFT_eSPI/blob/master/User_Setups/Setup12_M5Stack.h then I’ve used my friend Google to search for M5Stack library source and he found this https://github.com/m5stack/M5Stack/blob/master/src/M5Display.cpp so I was actually wrong - the is no special version of the library, but special user configuration in TFT_eSPI and special additional setup.

That’s great!!!
I checked “Setup12.M5stack.h” and it looks like I needed #define M5STACK.
When I added it, it was no longer a sandstorm.
However, the night theme is not adapted.I think the colors are reversed.

Do you know anything about this?

Unfortunately I don’t have any M5Stack, but can it be this https://github.com/m5stack/M5Stack/blob/e8085b06f26d59014cdb8950104aac33293edda6/src/M5Display.cpp#L36 ?

I referred to it, but it seems a bit esoteric to me.
The M5stack’s display driver appears to be a special ILI9341.
It seems to be using BGR for color representation, but I was able to fix that by setting up the TFT_eSPI library.
The problem is that the positives and negatives of the colors are reversed.

Is it still a setting on the TFT_ eSPI side?

I’m unable to say if it is in TFT_eSPI or in the color type in LVGL. You probably have to test the right colors with simple fill screen or something like this.

I have once again made a comparison with the project you told me about.
As a result, I found that I was hitting the registers directly with the display driver code.
I have mimicked it in my library.
image


With that, the theme color has been successfully returned!
Now you can play with M5stack. Thanks to you, Pablo!

Hi,
I’m trying to get my m5stack together with vscode + platformio running. But could not find a example to give me a kickstart.
I failed to transfer the esp32 example to platformio. Failed also with transfer the platformio example from stm32 to esp32. (Compiles for stm32 but not for esp32)
I’m not an expert - especially not for build environments.
Any hint where I can get a fresh quickstart?

hello I want show a button in lcd 800*480 and lvgl v7.11 my code is:

static lv_disp_buf_t disp_buf;
static lv_disp_drv_t disp_drv;
static lv_color_t buf[LV_HOR_RES_MAX * LV_VER_RES_MAX / 10];

uint16_t* LCD_FB=(uint16_t*)0xC0000000; // LCD FRAME Buffer

//**********************************************************************

lv_init();     

lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX*10);
lv_disp_drv_init(&disp_drv);

disp_drv.flush_cb = my_disp_flush;
disp_drv.buffer = &disp_buf;

disp_drv.hor_res = LV_HOR_RES_MAX; /Set the horizontal resolution of the display/
disp_drv.ver_res = LV_VER_RES_MAX; /Set the vertical resolution of the display/
lv_disp_drv_register(&disp_drv);

lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /Add a button the current screen/
lv_obj_set_pos(btn, 10, 10); /Set its position/
lv_obj_set_size(btn, 120, 50);

//*************************************************************

void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p)
{
int32_t x, y;
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
//set_pixel(x, y, color_p); / Put a pixel to the display.*/
LCD_FB[x+(y * LV_HOR_RES_MAX)]=(color_p->full);
color_p++;
}
}

lv_disp_flush_ready(disp);         /* Indicate you are ready with the flushing*/

}

//*************************************************************

but my lcd show it :

What do you think is the problem?