RTGUI视图使用问题
void workbench_panel1(void* parameter){
rt_mq_t mq;
rtgui_view_t* view;
rtgui_label_t* label;
struct rtgui_workbench* workbench;
rtgui_rect_t rect={0, 0, 320, 240};
mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO);
rtgui_thread_register(rt_thread_self(), mq);
workbench = rtgui_workbench_create("main", "workbench #1");
if (workbench == RT_NULL) return;
view = rtgui_view_create("view");
if (view == RT_NULL) return;
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = blue;
label = rtgui_label_create("RT-Thread");
rect.x1 = 10; rect.y1 = 10;
rect.x2 = 210; rect.y2 = 50;
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
rtgui_workbench_add_view(workbench, view);
rtgui_view_show(view, RT_FALSE);
rtgui_workbench_event_loop(workbench);
rtgui_thread_deregister(rt_thread_self());
/* delete message queue */
rt_mq_delete(mq);
}
/* workbench */
void workbench_init()
{
rt_thread_t tid;
tid = rt_thread_create("wb", workbench_panel1, RT_NULL, 3072, 20, 5);
if (tid != RT_NULL) rt_thread_startup(tid);
}
extern rt_err_t rt_hw_lcd_init(void);
void gui_init()
{
rtgui_rect_t rect;
rt_device_t lcd;
/*LCD*/
rt_hw_lcd_init();
lcd = rt_device_find("lcd");
if (lcd != RT_NULL)
{
rt_device_init(lcd);
rtgui_graphic_set_device(lcd);
/* RT-Thread/GUI server */
rtgui_system_server_init();
rect.x1 = 0;
rect.y1 = 0;
rect.x2 = 320;
rect.y2 = 240;
rtgui_panel_register("main", &rect);
rtgui_panel_set_default_focused("main");
rt_device_init_all();
/* workbench */
workbench_init();
}
}
这是一个stm32_radio里的example文件夹下的4_gui_single_ panel里的例子,图形驱动已经完成的。主要是程序执行RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = blue;时没对整个屏幕设置成蓝色,就是X方向上留下几列没设置成蓝色。而且我看程序也没对view的大小进行设置,所以不是太明白。求高人指点
我现在又在程序里加了rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);我看了rect的值是全屏的?奇怪啊 为什么 RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = blue;不全屏啊
我记得veiw应该就不是需要设定大小的,它的大小有pannel的大小确定。 非常感谢回复,原因自己找到了,主要是LCD设备驱动设计时屏幕的宽高我搞反了,我太粗心了 {:sweat:}。。。。我只是来围观的。。- -
页:
[1]