mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-02-07 01:44:41 +08:00
fix:[stm32][lcd]Error in control call of lcd test function (#10040)
* Optimize the lcd_test function to call it in thread to prevent the CLI environment from being unavailable after execution.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||
* Copyright (c) 2006-2025 RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@@ -363,11 +363,9 @@ INIT_DEVICE_EXPORT(drv_lcd_hw_init);
|
||||
#ifndef ART_PI_TouchGFX_LIB
|
||||
#ifdef DRV_DEBUG
|
||||
#ifdef FINSH_USING_MSH
|
||||
int lcd_test()
|
||||
static void lcd_thread(void *arg)
|
||||
{
|
||||
struct drv_lcd_device *lcd;
|
||||
lcd = (struct drv_lcd_device *)rt_device_find("lcd");
|
||||
|
||||
struct drv_lcd_device *lcd = (struct drv_lcd_device *)arg;
|
||||
while (1)
|
||||
{
|
||||
if (lcd->lcd_info.pixel_format == RTGRAPHIC_PIXEL_FORMAT_RGB565)
|
||||
@@ -378,7 +376,7 @@ int lcd_test()
|
||||
lcd->lcd_info.framebuffer[2 * i] = 0x00;
|
||||
lcd->lcd_info.framebuffer[2 * i + 1] = 0xF8;
|
||||
}
|
||||
lcd->parent.control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_device_control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_thread_mdelay(1000);
|
||||
/* green */
|
||||
for (int i = 0; i < LCD_BUF_SIZE / 2; i++)
|
||||
@@ -386,7 +384,7 @@ int lcd_test()
|
||||
lcd->lcd_info.framebuffer[2 * i] = 0xE0;
|
||||
lcd->lcd_info.framebuffer[2 * i + 1] = 0x07;
|
||||
}
|
||||
lcd->parent.control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_device_control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_thread_mdelay(1000);
|
||||
/* blue */
|
||||
for (int i = 0; i < LCD_BUF_SIZE / 2; i++)
|
||||
@@ -404,7 +402,7 @@ int lcd_test()
|
||||
lcd->lcd_info.framebuffer[3 * i + 1] = 0x00;
|
||||
lcd->lcd_info.framebuffer[3 * i + 2] = 0xff;
|
||||
}
|
||||
lcd->parent.control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_device_control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_thread_mdelay(1000);
|
||||
/* green */
|
||||
for (int i = 0; i < LCD_BUF_SIZE / 3; i++)
|
||||
@@ -413,7 +411,7 @@ int lcd_test()
|
||||
lcd->lcd_info.framebuffer[3 * i + 1] = 0xff;
|
||||
lcd->lcd_info.framebuffer[3 * i + 2] = 0x00;
|
||||
}
|
||||
lcd->parent.control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_device_control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_thread_mdelay(1000);
|
||||
/* blue */
|
||||
for (int i = 0; i < LCD_BUF_SIZE / 3; i++)
|
||||
@@ -424,11 +422,34 @@ int lcd_test()
|
||||
}
|
||||
}
|
||||
|
||||
lcd->parent.control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_device_control(&lcd->parent, RTGRAPHIC_CTRL_RECT_UPDATE, RT_NULL);
|
||||
rt_thread_mdelay(1000);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT(lcd_test, lcd_test);
|
||||
int lcd_test(void)
|
||||
{
|
||||
struct drv_lcd_device *lcd;
|
||||
lcd = (struct drv_lcd_device *)rt_device_find("lcd");
|
||||
if(lcd == RT_NULL)
|
||||
{
|
||||
LOG_E("Failed to find LCD device!\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
const char *thread_name = "lcd_test";
|
||||
rt_thread_t thread = rt_thread_create(thread_name, lcd_thread, lcd, 256, RT_THREAD_PRIORITY_MAX - 1, 10);
|
||||
if (thread != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(thread);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_E("%s created failed.", thread_name);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
MSH_CMD_EXPORT(lcd_test, Create thread test lcd);
|
||||
#endif /* FINSH_USING_MSH */
|
||||
#endif /* DRV_DEBUG */
|
||||
#endif /* BSP_USING_LCD */
|
||||
|
||||
Reference in New Issue
Block a user