problem description
On the current screen when an object is hidden(lv_obj_set_hidden), it is not fully visible, and there are faint shadows
What MCU/Processor/Board and compiler are you using?
STM32F103RET6 compiler:arm-cc
What LVGL version are you using?
5.3(Replacement of libraries is less convenient)
What do you want to achieve?
The current interface consists of multiple objects, some of which are mutually exclusive (when object A is displayed, object B is not displayed), and during the display process, it is expected that after object B is hidden, it can be completely hidden without any shadow.
What have you tried so far?
- Attempts were made to increase buffers, as well as to use double buffers
- Attempts were made to modify the refresh frequency
- Attempts were made to modify the parent-child relationship of the object
- Replace the hardware
Code to reproduce
This draws everything correct until you interact with an object or an object value gets updated on screen.
static void vInitScreen( lv_obj_t *par )
{
/**<创建父界面样式*/
lv_style_copy( &s_styleScreen, &lv_style_plain );
s_styleScreen.body.main_color = LV_COLOR_BLACK;
s_styleScreen.body.grad_color = LV_COLOR_BLACK;
s_styleScreen.body.opa = LV_OPA_COVER;
lv_obj_set_style( par, &s_styleScreen );
/**<创建壁纸*/
do
{
/**<创建壁纸样式(纯黑)*/
lv_style_copy( &s_styleWallPaper, &lv_style_plain_color );
s_styleWallPaper.body.main_color = LV_COLOR_BLACK;
s_styleWallPaper.body.grad_color = LV_COLOR_BLACK;
s_styleWallPaper.body.opa = LV_OPA_COVER;
/**<创建壁纸(纯黑)*/
s_pWallPaper = lv_obj_create( par, NULL );
lv_obj_set_size( s_pWallPaper, 320, 240);
lv_obj_set_style( s_pWallPaper, &s_styleWallPaper );
lv_obj_align( s_pWallPaper, NULL, LV_ALIGN_CENTER, 3, 3 );
}while( 0 );
/**<创建基本底框*/
do
{
/**<创建场景1背景样式*/
lv_style_copy( &s_styleScene1Background, &lv_style_plain_color );
s_styleScene1Background.body.main_color = LV_COLOR_BACKGROUND;
s_styleScene1Background.body.grad_color = LV_COLOR_BACKGROUND;
s_styleScene1Background.body.opa = LV_OPA_COVER;
/**<创建场景1背景图片*/
s_pScene1Background = lv_obj_create( s_pWallPaper, NULL );
lv_obj_set_size( s_pScene1Background, 103, 240);
lv_obj_set_style( s_pScene1Background, &s_styleScene1Background );
lv_obj_align( s_pScene1Background, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0 );
/**<创建场景2背景样式*/
lv_style_copy( &s_styleScene2Background, &lv_style_plain_color );
s_styleScene2Background.body.main_color = LV_COLOR_BACKGROUND;
s_styleScene2Background.body.grad_color = LV_COLOR_BACKGROUND;
s_styleScene2Background.body.opa = LV_OPA_COVER;
/**<创建场景2背景图片*/
s_pScene2Background = lv_obj_create( s_pWallPaper, NULL );
lv_obj_set_size( s_pScene2Background, 103, 240);
lv_obj_set_style( s_pScene2Background, &s_styleScene2Background );
lv_obj_align( s_pScene2Background, s_pScene1Background, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
/**<创建场景3背景样式*/
lv_style_copy( &s_styleScene3Background, &lv_style_plain_color );
s_styleScene3Background.body.main_color = LV_COLOR_BACKGROUND;
s_styleScene3Background.body.grad_color = LV_COLOR_BACKGROUND;
s_styleScene3Background.body.opa = LV_OPA_COVER;
/**<创建场景3背景图片*/
s_pScene3Background = lv_obj_create( s_pWallPaper, NULL );
lv_obj_set_size( s_pScene3Background, 103, 117);
lv_obj_set_style( s_pScene3Background, &s_styleScene3Background );
lv_obj_align( s_pScene3Background, s_pScene2Background, LV_ALIGN_OUT_RIGHT_MID, 5, -62 );
/**<创建场景4背景样式*/
lv_style_copy( &s_styleScene4Background, &lv_style_plain_color );
s_styleScene4Background.body.main_color = LV_COLOR_BACKGROUND;
s_styleScene4Background.body.grad_color = LV_COLOR_BACKGROUND;
s_styleScene4Background.body.opa = LV_OPA_COVER;
/**<创建场景4背景图片*/
s_pScene4Background = lv_obj_create( s_pWallPaper, NULL );
lv_obj_set_size( s_pScene4Background, 103, 117);
lv_obj_set_style( s_pScene4Background, &s_styleScene4Background );
lv_obj_align( s_pScene4Background, s_pScene3Background, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5 );
} while (0);
/**<创建中间层*/
do
{
lv_style_copy( &s_styleInterlayer, &lv_style_plain_color );
s_styleInterlayer.body.main_color = LV_COLOR_BLACK;
s_styleInterlayer.body.grad_color = LV_COLOR_BLACK;
s_styleInterlayer.body.opa = LV_OPA_COVER;
s_pInterlayer = lv_obj_create( s_pWallPaper, NULL);
lv_obj_set_size( s_pInterlayer, 320, 232);
lv_obj_set_style( s_pInterlayer, &s_styleInterlayer );
lv_obj_align( s_pInterlayer, s_pWallPaper, LV_ALIGN_IN_TOP_LEFT, 0, 0 );
lv_style_copy( &s_styleInterlayerText, &lv_style_transp );
s_styleInterlayerText.text.font = &pingfang_28;
s_styleInterlayerText.text.opa = LV_OPA_70;
s_styleInterlayerText.text.color = LV_COLOR_WHITE;
s_styleInterlayerText.text.grad = 0;
s_pInterlayerText = lv_label_create( s_pInterlayer, NULL );
lv_label_set_style( s_pInterlayerText, &s_styleInterlayerText );
lv_label_set_long_mode(s_pInterlayerText,LV_LABEL_LONG_EXPAND);
lv_label_set_align(s_pInterlayerText,LV_LABEL_ALIGN_CENTER);
lv_label_set_text( s_pInterlayerText, "请在UIOT超级智慧家\nAPP内添加场景" );
lv_obj_align( s_pInterlayerText, s_pInterlayer, LV_ALIGN_CENTER, 0, 0 );
}while( 0 );
/**<创建场景1元素*/
do
{
/**<创建Logo背景*/
lv_style_copy( &s_styleScene1Background_image, &lv_style_transp );
s_styleScene1Background_image.image.opa = LV_OPA_COVER;
s_pScene1Background_image = lv_img_create( s_pScene1Background, NULL );
lv_img_set_src( s_pScene1Background_image, &image_yellow_background );
// lv_img_set_style( s_pScene1Background_image, &s_styleScene1Background_image );
lv_obj_align( s_pScene1Background_image, NULL, LV_ALIGN_CENTER, 0, 0 );
/**<创建Logo*/
lv_style_copy( &s_styleScene1Logo, &lv_style_transp );
s_styleScene1Logo.image.opa = LV_OPA_COVER;
s_pScene1Logo = lv_img_create( s_pScene1Background_image, NULL );
lv_img_set_src( s_pScene1Logo, &image_scene0_ui2_d );
lv_img_set_style( s_pScene1Logo, &s_styleScene1Logo );
lv_obj_align( s_pScene1Logo, s_pScene1Background_image, LV_ALIGN_CENTER, 0, -13 );
/**<创建Text*/
lv_style_copy( &s_styleScene1Text, &lv_style_transp );
s_styleScene1Text.text.font = &weiruan_28;
s_styleScene1Text.text.opa = LV_OPA_COVER;
s_styleScene1Text.text.letter_space = 1;
s_styleScene1Text.text.line_space = -5;
s_styleScene1Text.text.color = LV_COLOR_TEXT_YELLOW;
s_styleScene1Text.text.grad = 0;
s_pScene1Text = lv_label_create( s_pWallPaper, NULL );
lv_label_set_style( s_pScene1Text, &s_styleScene1Text );
lv_label_set_long_mode(s_pScene1Text,LV_LABEL_LONG_BREAK);
lv_label_set_align(s_pScene1Text,LV_LABEL_ALIGN_CENTER);
lv_obj_set_width( s_pScene1Text, 90 );
lv_label_set_text( s_pScene1Text, "回家模式" );
lv_obj_align( s_pScene1Text, s_pScene1Background_image, LV_ALIGN_OUT_BOTTOM_MID, 0, 30 );
/**<创建场景1空样式*/
lv_style_copy( &s_styleScene1Empty, &lv_style_plain_color );
s_styleScene1Empty.body.empty = 1;
s_styleScene1Empty.body.radius = LV_RADIUS_CIRCLE;
s_styleScene1Empty.body.opa = LV_OPA_COVER;
s_styleScene1Empty.body.border.color = LV_COLOR_CIRCLE_YELLOW;
s_styleScene1Empty.body.border.width = 2;
s_styleScene1Empty.body.border.opa = LV_OPA_COVER;
/**<创建场景1空图片*/
s_pScene1Empty = lv_obj_create( s_pScene1Background, NULL );
lv_obj_set_size( s_pScene1Empty, 10, 10);
lv_obj_set_style( s_pScene1Empty, &s_styleScene1Empty );
lv_obj_align( s_pScene1Empty, NULL, LV_ALIGN_CENTER, 0, 0 );
}while( 0 );
/**<创建场景2元素*/
do
{
/**<创建Logo背景*/
lv_style_copy( &s_styleScene2Background_image, &lv_style_transp );
s_styleScene2Background_image.image.opa = LV_OPA_COVER;
s_pScene2Background_image = lv_img_create( s_pScene2Background, NULL );
lv_img_set_src( s_pScene2Background_image, &image_yellow_background );
lv_img_set_style( s_pScene2Background_image, &s_styleScene2Background_image );
lv_obj_align( s_pScene2Background_image, NULL, LV_ALIGN_CENTER, 0, 0 );
/**<创建Logo*/
lv_style_copy( &s_styleScene2Logo, &lv_style_transp );
s_styleScene2Logo.image.opa = LV_OPA_COVER;
s_pScene2Logo = lv_img_create( s_pScene2Background_image, NULL );
lv_img_set_src( s_pScene2Logo, &image_scene0_ui2_d );
lv_img_set_style( s_pScene2Logo, &s_styleScene2Logo );
lv_obj_align( s_pScene2Logo, s_pScene2Background_image, LV_ALIGN_CENTER, 0, -13 );
/**<创建Text*/
lv_style_copy( &s_styleScene2Text, &lv_style_transp );
s_styleScene2Text.text.font = &weiruan_28;
s_styleScene2Text.text.opa = LV_OPA_COVER;
s_styleScene2Text.text.letter_space = 1;
s_styleScene2Text.text.line_space = -5;
s_styleScene2Text.text.color = LV_COLOR_TEXT_YELLOW;
s_styleScene2Text.text.grad = 0;
s_pScene2Text = lv_label_create( s_pWallPaper, NULL );
lv_label_set_style( s_pScene2Text, &s_styleScene2Text );
lv_label_set_long_mode(s_pScene2Text,LV_LABEL_LONG_BREAK);
lv_label_set_align(s_pScene2Text,LV_LABEL_ALIGN_CENTER);
lv_obj_set_width( s_pScene2Text, 90 );
lv_label_set_text( s_pScene2Text, "88888888" );
lv_obj_align( s_pScene2Text, s_pScene2Background_image, LV_ALIGN_OUT_BOTTOM_MID, 0, 30 );
/**<创建场景2空样式*/
lv_style_copy( &s_styleScene2Empty, &lv_style_plain_color );
s_styleScene2Empty.body.empty = 1;
s_styleScene2Empty.body.radius = LV_RADIUS_CIRCLE;
s_styleScene2Empty.body.opa = LV_OPA_COVER;
s_styleScene2Empty.body.border.color = LV_COLOR_CIRCLE_YELLOW;
s_styleScene2Empty.body.border.width = 2;
s_styleScene2Empty.body.border.opa = LV_OPA_COVER;
/**<创建场景2空图片*/
s_pScene2Empty = lv_obj_create( s_pScene2Background, NULL );
lv_obj_set_size( s_pScene2Empty, 10, 10);
lv_obj_set_style( s_pScene2Empty, &s_styleScene2Empty );
lv_obj_align( s_pScene2Empty, NULL, LV_ALIGN_CENTER, 0, 0 );
}while( 0 );
/**<创建场景3元素*/
do
{
/**<创建Logo背景*/
lv_style_copy( &s_styleScene3Background_image, &lv_style_transp );
s_styleScene3Background_image.image.opa = LV_OPA_COVER;
s_pScene3Background_image = lv_img_create( s_pScene3Background, NULL );
lv_img_set_src( s_pScene3Background_image, &image_blue_background );
lv_img_set_style( s_pScene3Background_image, &s_styleScene3Background_image );
lv_obj_align( s_pScene3Background_image, NULL, LV_ALIGN_CENTER, 0, -15 );
/**<创建Logo*/
lv_style_copy( &s_styleScene3Logo, &lv_style_transp );
s_styleScene3Logo.image.opa = LV_OPA_COVER;
s_pScene3Logo = lv_img_create( s_pScene3Background_image, NULL );
lv_img_set_src( s_pScene3Logo, &image_scene0_ui2_x );
lv_img_set_style( s_pScene3Logo, &s_styleScene3Logo );
lv_obj_align( s_pScene3Logo, s_pScene3Background_image, LV_ALIGN_CENTER, 0, -8 );
/**<创建Text*/
lv_style_copy( &s_styleScene3Text, &lv_style_transp );
s_styleScene3Text.text.font = &weiruan_28;
s_styleScene3Text.text.opa = LV_OPA_COVER;
s_styleScene3Text.text.letter_space = 1;
s_styleScene3Text.text.line_space = -5;
s_styleScene3Text.text.color = LV_COLOR_TEXT_BLUE;
s_styleScene3Text.text.grad = 0;
s_pScene3Text = lv_label_create( s_pWallPaper, NULL );
lv_label_set_style( s_pScene3Text, &s_styleScene3Text );
lv_label_set_long_mode(s_pScene3Text,LV_LABEL_LONG_BREAK);
lv_label_set_align(s_pScene3Text,LV_LABEL_ALIGN_CENTER);
lv_obj_set_width( s_pScene3Text, 90 );
lv_label_set_text( s_pScene3Text, "%%%%%%%%" );
lv_obj_align( s_pScene3Text, s_pScene3Background_image, LV_ALIGN_OUT_BOTTOM_MID, 0, 4 );
/**<创建场景3空样式*/
lv_style_copy( &s_styleScene3Empty, &lv_style_plain_color );
s_styleScene3Empty.body.empty = 1;
s_styleScene3Empty.body.radius = LV_RADIUS_CIRCLE;
s_styleScene3Empty.body.opa = LV_OPA_COVER;
s_styleScene3Empty.body.border.color = LV_COLOR_CIRCLE_BLUE;
s_styleScene3Empty.body.border.width = 2;
s_styleScene3Empty.body.border.opa = LV_OPA_COVER;
/**<创建场景3空图片*/
s_pScene3Empty = lv_obj_create( s_pScene3Background, NULL );
lv_obj_set_size( s_pScene3Empty, 10, 10);
lv_obj_set_style( s_pScene3Empty, &s_styleScene3Empty );
lv_obj_align( s_pScene3Empty, NULL, LV_ALIGN_CENTER, 0, 0 );
}while( 0 );
/**<创建场景4元素*/
do
{
/**<创建Logo背景*/
lv_style_copy( &s_styleScene4Background_image, &lv_style_transp );
s_styleScene4Background_image.image.opa = LV_OPA_COVER;
s_pScene4Background_image = lv_img_create( s_pScene4Background, NULL );
lv_img_set_src( s_pScene4Background_image, &image_blue_background );
lv_img_set_style( s_pScene4Background_image, &s_styleScene4Background_image );
lv_obj_align( s_pScene4Background_image, NULL, LV_ALIGN_CENTER, 0, -15 );
/**<创建Logo*/
lv_style_copy( &s_styleScene4Logo, &lv_style_transp );
s_styleScene4Logo.image.opa = LV_OPA_COVER;
s_pScene4Logo = lv_img_create( s_pScene4Background_image, NULL );
lv_img_set_src( s_pScene4Logo, &image_scene0_ui2_x );
lv_img_set_style( s_pScene4Logo, &s_styleScene4Logo );
lv_obj_align( s_pScene4Logo, s_pScene4Background_image, LV_ALIGN_CENTER, 0, -8 );
/**<创建Text*/
lv_style_copy( &s_styleScene4Text, &lv_style_transp );
s_styleScene4Text.text.font = &weiruan_28;
s_styleScene4Text.text.opa = LV_OPA_COVER;
s_styleScene4Text.text.letter_space = 1;
s_styleScene4Text.text.line_space = -5;
s_styleScene4Text.text.color = LV_COLOR_TEXT_BLUE;
s_styleScene4Text.text.grad = 0;
s_pScene4Text = lv_label_create( s_pWallPaper, NULL );
lv_label_set_style( s_pScene4Text, &s_styleScene4Text );
lv_label_set_long_mode(s_pScene4Text,LV_LABEL_LONG_BREAK);
lv_label_set_align(s_pScene4Text,LV_LABEL_ALIGN_CENTER);
lv_obj_set_width( s_pScene4Text, 90 );
lv_label_set_text( s_pScene4Text, "88888888" );
lv_obj_align( s_pScene4Text, s_pScene4Background_image, LV_ALIGN_OUT_BOTTOM_MID, 0, 4 );
/**<创建场景4空样式*/
lv_style_copy( &s_styleScene4Empty, &lv_style_plain_color );
s_styleScene4Empty.body.empty = 1;
s_styleScene4Empty.body.radius = LV_RADIUS_CIRCLE;
s_styleScene4Empty.body.opa = LV_OPA_COVER;
s_styleScene4Empty.body.border.color = LV_COLOR_CIRCLE_BLUE;
s_styleScene4Empty.body.border.width = 2;
s_styleScene4Empty.body.border.opa = LV_OPA_COVER;
/**<创建场景4空图片*/
s_pScene4Empty = lv_obj_create( s_pScene4Background, NULL );
lv_obj_set_size( s_pScene4Empty, 10, 10);
lv_obj_set_style( s_pScene4Empty, &s_styleScene4Empty );
lv_obj_align( s_pScene4Empty, NULL, LV_ALIGN_CENTER, 0, 0 );
}while( 0 );
}
void DialogSceneUI2_vInit( void )
{
lv_obj_t *pCurScreen = NULL;
pCurScreen = lv_scr_act();
if( pCurScreen != s_pScreen )
{
s_pScreen = lv_obj_create( NULL, NULL );
DialogUI_vLoadScree( &s_pScreen );
vInitScreen( s_pScreen );
}
Scene_Refresh_UI2();
}
static uint8 Scene_Status_Check(uint8 num)
{
uint8 cmp_buff[4] = {0};
// if(scene_overview[num].scene_num[0] == 0x00 && scene_overview[num].scene_num[1] == 0x00 && scene_overview[num].scene_num[2] == 0x00 && scene_overview[num].scene_num[3] == 0x00)
if(memcmp(scene_overview[num].scene_num,cmp_buff,4))
{
return 1;
}
else
{
return 0;
}
}
static uint8 Scene_Status_Check_All(void)
{
uint8 status = 0;
for (uint8 i = 0; i < 4; i++)
{
status |= Scene_Status_Check(i)<<i;
}
return status;
}
// //界面位置映射
// static void Scene_Num_Confirm(uint)
// {
// }
//界面刷新
void Scene_Refresh_UI2(void)
{
uint8 text[20] = {0};
const lv_img_dsc_t ** p = NULL;
uint8 align_val = 0;
uint8 logo_num = 0;
if(!Scene_Status_Check_All())
{
//隐藏所有场景,显示中间件以及文字
lv_obj_set_hidden( s_pScene1Background_image, true );
lv_obj_set_hidden( s_pScene1Logo, true );
lv_obj_set_hidden( s_pScene1Text, true );
lv_obj_set_hidden( s_pScene1Empty, true );
lv_obj_set_hidden( s_pScene2Background_image, true );
lv_obj_set_hidden( s_pScene2Logo, true );
lv_obj_set_hidden( s_pScene2Text, true );
lv_obj_set_hidden( s_pScene2Empty, true );
lv_obj_set_hidden( s_pScene3Background_image, true );
lv_obj_set_hidden( s_pScene3Logo, true );
lv_obj_set_hidden( s_pScene3Text, true );
lv_obj_set_hidden( s_pScene3Empty, true );
lv_obj_set_hidden( s_pScene4Background_image, true );
lv_obj_set_hidden( s_pScene4Logo, true );
lv_obj_set_hidden( s_pScene4Text, true );
lv_obj_set_hidden( s_pScene4Empty, true );
lv_obj_set_hidden( s_pInterlayerText, false );
s_styleInterlayerText.text.color = LV_COLOR_WHITE;
lv_label_set_style( s_pInterlayerText, &s_styleInterlayerText );
lv_obj_set_hidden( s_pInterlayer, false );
}
else
{
lv_obj_set_hidden( s_pInterlayer, true );
s_styleInterlayerText.text.color = LV_COLOR_BLACK;
lv_label_set_style( s_pInterlayerText, &s_styleInterlayerText );
lv_obj_set_hidden( s_pInterlayerText, true );
//先进行界面文字展示再进行界面对齐
for(uint8 i = 0; i < 4; i++)
{
logo_num = 0;
if(Scene_Status_Check(i) != 0)//说明有场景
{
memset(text,0,20);
lv_obj_set_hidden( *Scene_Logo_Background_Obj_Map[i], false );
lv_obj_set_hidden( *Scene_Logo_Obj_Map[i], false );
lv_obj_set_hidden( *Scene_Text_Obj_Map[i], false );
lv_obj_set_hidden( *Scene_Empty_Obj_Map[i], true );
//设置设置文字
gbkbuff_to_utf8(scene_overview[i].scene_name, text);
lv_label_set_text( *Scene_Text_Obj_Map[i], (char *)text);//(char *)scene_overview[i].scene_name );
//设置logo
if(i>1)
{
p = Scene_Logo_Source_x;
align_val = 4;
}
else
{
p = Scene_Logo_Source_d;
align_val = 30;
}
if(scene_overview[i].scene_logo<19)
{
logo_num = scene_overview[i].scene_logo;
}
lv_img_set_src( *Scene_Logo_Obj_Map[i], p[logo_num] );
//设置对齐
lv_obj_align( *Scene_Text_Obj_Map[i],*Scene_Logo_Background_Obj_Map[i], LV_ALIGN_OUT_BOTTOM_MID, 0, align_val );
}
else
{
lv_obj_set_hidden( *Scene_Logo_Background_Obj_Map[i], true );
lv_obj_set_hidden( *Scene_Logo_Obj_Map[i], true );
lv_obj_set_hidden( *Scene_Text_Obj_Map[i], true );
lv_obj_set_hidden( *Scene_Empty_Obj_Map[i], false );
}
}
}
}