Embedded GUI—Littlevgl

Littlevgl introduction and porting

1 Introduction

        Littlevgl is a GUI written in pure C language. There are many and beautiful controls. It is easy to transplant. As long as it is connected to a display interface, add a touch control interface for those that need to be touched.

2. Transplant 

        Display interface migration:

        

        static void tft_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p)
        {
               /*Truncate the area to the screen*/
              int32_t act_x1 = x1 < 0 ? 0 : x1;
              int32_t act_y1 = y1 < 0 ? 0 : y1;
              int32_t act_x2 = x2 > LV_HOR_RES ? LV_HOR_RES  : x2;
              int32_t act_y2 = y2 > LV_VER_RES ? LV_VER_RES  : y2;

             uint32_t x;
             uint32_t y;

             /*Put the map to the remaining area*/
            for(y = act_y1; y <= act_y2; y++)      //填充屏幕的像素点
            {
               for(x = act_x1; x <= act_x2; x++)
               {
                    GUI_Point(x, y,  color_p->full);
                   color_p++;
               }
            }
             lv_flush_ready();
       }

       Register display interface:

             lv_disp_drv_t disp;

             lv_disp_drv_init(&disp);
             disp.disp_flush = tft_flush;
             disp.disp_fill = lv_disp_fill; //Single point filling
             disp.disp_map = lv_disp_map; //Same as
             tft_flush lv_disp_drv_register(&disp);  

      Touch interface:

             * Indev lv_indev_t static;
             lv_indev_drv_t indev_drv;
             lv_indev_drv_init (& indev_drv);
             indev_drv.read = my_input_read; // return the pressing state of the touch screen and the touch position
             indev_drv.type = LV_INDEV_TYPE_POINTER; // There are several types, here is a touch screen
             indev = lv_indev_drv_register ( &indev_drv);

     After the above interfaces are connected, they are basically transplanted.

3. Chinese characters display

        Littlevgl itself does not have a Chinese font library. You need to add a Chinese font library after taking the modulus. Here is an offline modulo software Lvgl Font Tool V0.3 to add the Chinese characters that need to be displayed and automatically generate the file.

       Reference: Assuming that the file name generated by changing the software is myfont.c, you need to add it to the lv_font.h file before use

            LV_FONT_DECLARE(myfont); //In fact, it is an extern statement

       Then you can call this file font library.

       transfer:

       1. Style call

           style.text.font = &my_font_name;

       2. Font mix

           lv_font_add(&myfont, &parent_font);

   Note: To use Chinese in keil, you must modify the encoding method to UTF-8.

 

 

Guess you like

Origin blog.csdn.net/tulongyongshi/article/details/105904363