Description
What MCU/Processor/Board and compiler are you using?
STM32F411CEU6
What do you want to achieve?
I am trying to use LVGL with the 1.28inch LCB module GC9A01A display.
What have you tried so far?
In my tft.c I have created a simple driver displays which uses the “LCD_1IN28_DrawPaint()” function from the waveshare library “https://www.waveshare.com/wiki/1.28inch_LCD_Module#Resources” to flush the display. The demo spinner kind of appears but there seems to be artifacts as seen in the photo. Does anyone know how I can solve this issue? Thanks!
Code to reproduce
#include "lv_conf.h"
#include "lvgl/lvgl.h"
#include <string.h>
#include <stdlib.h>
#include "tft.h"
#include "Utilities/User/Config/Debug.h"
#include "Utilities/User/Config/DEV_Config.h"
#include "Utilities/User/Fonts/Fonts.h"
#include "Utilities/User/LCD/LCD_1in28.h"
#include "Utilities/User/LCD/Touch_Driver.h"
#include "Utilities/User/GUI_DEV/GUI_Paint.h"
/*********************
* DEFINES
*********************/
#if LV_COLOR_DEPTH != 16 && LV_COLOR_DEPTH != 24 && LV_COLOR_DEPTH != 32
#error LV_COLOR_DEPTH must be 16, 24, or 32
#endif
//Frame buffers
#define BYTES_PER_PIXEL (LV_COLOR_FORMAT_GET_SIZE(LV_COLOR_FORMAT_RGB565)) /*will be 2 for RGB565 */
#define BUFF_SIZE (240 * 10 * BYTES_PER_PIXEL)
static uint8_t buf_1[BUFF_SIZE];
static uint8_t buf_2[BUFF_SIZE];
void ex_disp_flush(lv_display_t * disp, const lv_area_t * area, lv_color_t * color_p);
/**********************
* STATIC VARIABLES
**********************/
#if LV_COLOR_DEPTH == 16
typedef uint16_t uintpixel_t;
#elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
typedef uint32_t uintpixel_t;
#endif
void tft_init(void)
{
//Initialise display
DEV_Module_Init();
//Set display's brightness
LCD_1IN28_SetBackLight(1000);
//Set display's orientation
LCD_1IN28_Init(VERTICAL);
lv_display_t * disp = lv_display_create(TFT_HOR_RES, TFT_VER_RES); /*Basic initialization with horizontal and vertical resolution in pixels*/
static uint8_t buf[TFT_HOR_RES * 68 * 2];
lv_display_set_buffers(disp, buf_1, buf_2, sizeof(buf_1), LV_DISPLAY_RENDER_MODE_PARTIAL); /* Set an initialized buffer */
lv_display_set_flush_cb(disp, ex_disp_flush);
}
void ex_disp_flush(lv_display_t * disp, const lv_area_t * area, lv_color_t * color_p)
{
int32_t x;
int32_t y;
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
uint16_t color_full = (color_p->red << 11) | (color_p->green << 5) | (color_p->blue);
LCD_1IN28_DrawPaint(x, y, color_full);
color_p++;
}
}
lv_display_flush_ready(disp);
}
void tft_test(void)
{
/* Change Active Screen's background color */
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN);
lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN);
//Create a spinner
lv_obj_t * spinner = lv_spinner_create(lv_screen_active());
lv_obj_set_size(spinner, 64, 64);
lv_obj_align(spinner, LV_ALIGN_CENTER, 0, 0);
}