lvgl8.0.0移植后颜色显示不正常

原来使用的lvgl6.0.0的系统,所有的组件颜色显示都是正常,然而移植完8.0.0版本后颜色缺不正常,发现给的颜色为白色rgb(r8,g8,b8)565格式,实际显示成了rg(r8,b8,0)的颜色,其中b的颜色被砍了,变成了0,检查lv_conf.h文件跟原来给的是一样的16位深的设置,是哪里还需要修改吗,有能解惑么?

  • 这篇博客: LVGL8.1笔记2–触摸移植(2022-0603)中的 下面列出我移植完成的.c和.h文件 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • lv_port_indev.h

    /**
     * @file lv_port_indev_templ.h
     *
     */
    
     /*Copy this file as "lv_port_indev.h" and set this value to "1" to enable content*/
    #if 1
    
    #ifndef LV_PORT_INDEV_H
    #define LV_PORT_INDEV_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    /*********************
     *      INCLUDES
     *********************/
    #include "lvgl.h"
    
    /*********************
     *      DEFINES
     *********************/
    
    /**********************
     *      TYPEDEFS
     **********************/
    
    /**********************
     * GLOBAL PROTOTYPES
     **********************/
    void lv_port_indev_init(void);
    /**********************
     *      MACROS
     **********************/
    
    #ifdef __cplusplus
    } /*extern "C"*/
    #endif
    
    #endif /*LV_PORT_INDEV_TEMPL_H*/
    
    #endif /*Disable/Enable content*/
    
    

    lv_port_indev.c

    /**
     * @file lv_port_indev_templ.c
     *
     */
    
     /*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/
    #if 1
    
    /*********************
     *      INCLUDES
     *********************/
    #include "lv_port_indev.h"
    #include "../../lvgl.h"
    
    #include "touch.h"
    
    /*********************
     *      DEFINES
     *********************/
    
    /**********************
     *      TYPEDEFS
     **********************/
    
    /**********************
     *  STATIC PROTOTYPES
     **********************/
    
    static void touchpad_init(void);
    static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
    static bool touchpad_is_pressed(void);
    static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y);
    
    /**********************
     *  STATIC VARIABLES
     **********************/
    lv_indev_t * indev_touchpad;
    
    /**********************
     *      MACROS
     **********************/
    
    /**********************
     *   GLOBAL FUNCTIONS
     **********************/
    
    void lv_port_indev_init(void)
    {
        /**
         * Here you will find example implementation of input devices supported by LittelvGL:
         *  - Touchpad
         *  - Mouse (with cursor support)
         *  - Keypad (supports GUI usage only with key)
         *  - Encoder (supports GUI usage only with: left, right, push)
         *  - Button (external buttons to press points on the screen)
         *
         *  The `..._read()` function are only examples.
         *  You should shape them according to your hardware
         */
    
        static lv_indev_drv_t indev_drv;
    
        /*------------------
         * Touchpad
         * -----------------*/
    
        /*Initialize your touchpad if you have*/
        touchpad_init();
    
        /*Register a touchpad input device*/
        lv_indev_drv_init(&indev_drv);
        indev_drv.type = LV_INDEV_TYPE_POINTER;
        indev_drv.read_cb = touchpad_read;
        indev_touchpad = lv_indev_drv_register(&indev_drv);
    }
    
    /**********************
     *   STATIC FUNCTIONS
     **********************/
    
    /*------------------
     * Touchpad
     * -----------------*/
    
    /*Initialize your touchpad*/
    static void touchpad_init(void)
    {
        /*Your code comes here*/
    }
    
    /*Will be called by the library to read the touchpad*/
    static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
    {
        static lv_coord_t last_x = 0;
        static lv_coord_t last_y = 0;
    
        /*Save the pressed coordinates and the state*/
        if(touchpad_is_pressed()) {
            touchpad_get_xy(&last_x, &last_y);
            data->state = LV_INDEV_STATE_PR;
        } else {
            data->state = LV_INDEV_STATE_REL;
        }
    
        /*Set the last pressed coordinates*/
        data->point.x = last_x;
        data->point.y = last_y;
    }
    
    /*Return true is the touchpad is pressed*/
    static bool touchpad_is_pressed(void)
    {
        /*Your code comes here*/
        if(TP_PRES_DOWN & tp_dev.sta)
        {
            return true;
        }
        return false;
    }
    
    /*Get the x and y coordinates if the touchpad is pressed*/
    static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
    {
        /*Your code comes here*/
    
        (*x) = tp_dev.x[0];
        (*y) = tp_dev.y[0];
    }
    
    
    
    #else /*Enable this file at the top*/
    
    /*This dummy typedef exists purely to silence -Wpedantic.*/
    typedef int keep_pedantic_happy;
    #endif