Lvgl draw a red Canvas

would you share a simulator project (with RGB565)on windows?i pull windows simulator (with RGB888)form gitlib .

when i modify color depth as RGB565.simulator does not works as expect

when i test my code in simulator,it does not display as expect

would you help to check my setting of lvgl?
lvgl setting file

when i modify color depth as 16 on simulator,display as picture


Your lv_ex_canvas_test code, from where did you get this code?

Have you read the lvgl docu pages (https://docs.lvgl.io/v7/en/html/widgets/canvas.html) about canvas?

What does the example code show?
It shows this for defining the buffer:

static lv_color_t buffer[LV_CANVAS_BUF_SIZE_TRUE_COLOR(width, height)]. LV_CANVAS_BUF_SIZE_... 

The used type is lv_color_t, but you use uint8_t.

And also for the lv_canvas_set_palette it is correct to use LV_IMG_CF_TRUE_COLOR.

And please, if you want to show code, don’t do screenshots and post the images.
When you post it as ‘code’ it is easy to copy and paste your code for us for doing some investigations.
And it is enough to post it as ‘code’ and not as ‘code’ and screenshot.

So this code is showing a red rectangle on my screen (on real hardware)

#define CANVAS_WIDTH   50
#define CANVAS_HEIGHT  50

void lv_ex_canvas_test (void)
{
    static lv_color_t  cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR (CANVAS_WIDTH, CANVAS_HEIGHT)];

    lv_obj_t* canvas = lv_canvas_create (lv_scr_act (), NULL);

    lv_canvas_set_buffer (canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR);

    lv_canvas_set_palette (canvas, 1, LV_COLOR_RED);
    lv_obj_align          (canvas, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
    lv_canvas_fill_bg     (canvas, LV_COLOR_RED, LV_OPA_TRANSP);
}

i got test code from lvgl docu page(https://docs.lvgl.io/latest/en/html/widgets/canvas.html)
when i test your code on windows simulator,it display as pitcure.
i modify color depth as 16 and modify simulator size same as my LCD
image
image

here is flush_cb() on simulater
int32_t x;

for(y = area->y1; y <= area->y2 && y < disp_drv->ver_res; y++) {
    for(x = area->x1; x <= area->x2; x++) {
        printf("----->>color_p=%x\r\n", *color_p);
        printf("lv_color_to16(*color_p)=%x\r\n", lv_color_to16(*color_p));
        monitor.tft_fb[y *disp_drv->hor_res + x] = lv_color_to16(*color_p);
        color_p++;
        //printf("%04x\r\n", monitor.tft_fb[y * disp_drv->hor_res + x]);
    }

}

i want to got correct color value from simulator,then debug my lcd used correct color value

I’ve taken the simulator (VS Studio)
added this function to LVGL.Simulator.cpp:

#define CANVAS_WIDTH  50
#define CANVAS_HEIGHT  50

void lv_ex_canvas_test (void)
{
    static lv_color_t  cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR (CANVAS_WIDTH, CANVAS_HEIGHT)];

    lv_obj_t* canvas = lv_canvas_create (lv_scr_act (), NULL);

    lv_canvas_set_buffer (canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR);

    lv_canvas_set_palette (canvas, 1, LV_COLOR_RED);
    lv_obj_align (canvas, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
    lv_canvas_fill_bg (canvas, LV_COLOR_RED, LV_OPA_TRANSP);
}

Changed the lv_conf to this:

/* Maximal horizontal and vertical resolution to support by the library.*/
//#define LV_HOR_RES_MAX          (800)
//#define LV_VER_RES_MAX          (480)

#define LV_HOR_RES_MAX          (320)
#define LV_VER_RES_MAX          (240)

/* Color depth:
 * - 1:  1 byte per pixel
 * - 8:  RGB332
 * - 16: RGB565
 * - 32: ARGB8888
 */
#define LV_COLOR_DEPTH     16

Changed in main (LVGL.Simulator.cpp)

    /*
     * Demos, benchmarks, and tests.
     *
     * Uncomment any one (and only one) of the functions below to run that
     * item.
     */

    lv_ex_canvas_test ();
//    lv_demo_widgets();

and, as expected, I get this when running the simulator:

Simulator

would you share the windows simulator you used?maybe we used different windows simulator

I use the Visual Studio simulator from here: https://github.com/lvgl/lv_sim_visual_studio.

I did the download today.

image
i wnat to make sure about LV_BIG_ENDIAN_SYSTEM setting.
lvgl used little endian by defaukt and if my systerm is big endian,i need to modify to 1,right?

Another question:
how to support mutiple language display?

would you share a example to display a image?

does lvgl support display QR code?

This forum supports a forum search function!
Right at the top, the magnifier symbol.

For the QR code you would find the following: QRCODE display with littlevgl
Searching for internationalization (or i18n for short) : Print in other languages

What’s about your simulator problem?
Is your red rectangle example working now?

yes,lvgl works fine on my real device now.Thanks

i want to select list item by keyboard.when click down key,list item pop.
how to implement it?please give guidance

LVGL work on my real device nonw.Thank for your support.Just some function need to implement.

when i switch screen,i found new screen load slowly.