Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
RT-Thread English
RT-Gui : a simple example
发布于 2011-01-18 03:57:55 浏览:8123
订阅该版
Hi all, I'm using stm32 radio project to understand RT-GUI by examples. I'm not able to implement a simple view with one button and one label. When I press the button I need to change the label. I don' understand how link the button to the handler. I use rtgui_button_set_onbutton(apply_button, apply_handler) but is not enough. Last thing : the button pressed image is different from button not pressed image or I have to create manually? Thanks Marco
查看更多
2
个回答
默认排序
按发布时间排序
Steva
2011-01-18
这家伙很懒,什么也没写!
Found it, only problems with touch calibration. static void apply_handler(struct rtgui_widget* widget, rtgui_event_t* event) { rt_uint32_t vol, bri; bri = 0; } void workbench_panel1(void* parameter) { rt_mq_t mq; rtgui_view_t* view; rtgui_label_t* label; struct rtgui_button* apply_button; struct rtgui_workbench* workbench; rtgui_rect_t rect; mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO); /* ×??á?±?°??????GUI???? */ rtgui_thread_register(rt_thread_self(), mq); /* ???¨?????¤×÷?¨ */ workbench = rtgui_workbench_create("main", "workbench #1"); rtgui_widget_set_event_handler(RTGUI_WIDGET(workbench), rtgui_workbench_event_handler); if (workbench == RT_NULL) return; view = rtgui_view_create("view"); if (view == RT_NULL) return; /* ???¨??????±??°?? */ RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = light_grey; /* ?í??????label */ label = rtgui_label_create("RT-Thread"); rect.x1 = 10; rect.y1 = 10; rect.x2 = 210; rect.y2 = 30; /* ?è??label?????? */ rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); rect.x1 = 50; rect.y1 = 50; rect.x2 = 210; rect.y2 = 90; apply_button = rtgui_button_create("Hello"); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(apply_button)) = blue; rtgui_widget_set_rect(RTGUI_WIDGET(apply_button), &rect); rtgui_button_set_onbutton(apply_button, apply_handler); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(apply_button)); /* ?í??????workbench?? */ rtgui_workbench_add_view(workbench, view); /* ·?????·??????????? */ rtgui_view_show(view, RT_FALSE); /* ?????¤×÷?¨???????· */ rtgui_workbench_event_loop(workbench); /* ??×??áGUI???? */ 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, 2048, 20, 5); if (tid != RT_NULL) rt_thread_startup(tid); } void gui_init() { extern void rtgui_touch_hw_init(void); extern rt_err_t load_setup(void); rtgui_rect_t rect; /* ??????RT-Thread/GUI server */ rtgui_system_server_init(); /* ×??á??°? */ rect.x1 = 0; rect.y1 = 0; rect.x2 = 240; rect.y2 = 320; rtgui_panel_register("main", &rect); rtgui_panel_set_default_focused("main"); /* ??????LCD???? */ rt_hw_lcd_init(); /* ???????ü?????? */ //rt_hw_key_init(); /* ???????????????? */ load_setup(); //touch×°???????? rtgui_touch_hw_init(); rt_device_init_all(); /* ??????workbench */ workbench_init(); }
撰写答案
登录
注册新账号
关注者
0
被浏览
8.1k
关于作者
Steva
这家伙很懒,什么也没写!
提问
3
回答
6
被采纳
0
关注TA
发私信
相关问题
1
Welcome to RT-Thread RTOS English discussion
2
good!
3
The speed of external SRAM of STM32
4
RT-Thread on ST Forum
5
Splay Tree
6
More RTGUI screenshot
7
STM32 pimer2
8
mini2440 support
9
Howto Run RT-Thread 0.4.0 on QEMU/mini2440
10
RT-Gui : how can use it?
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
机器人操作系统 (ROS2) 和 RT-Thread 通信
4
国产MCU移植系列教程汇总,欢迎查看!
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
NXP MCXN947测评(二)ETH设备使用
2
【RA8D1-Vision Board】适配 LVGL V8
3
VISION BOARD 第二弹 基础工程配置和点亮一个LED灯
4
musb移植问题记录【设备注册3次挂起】
5
关于使用CherryUSB时候使用外挂的usb phy 芯片配置的一点注意事项
热门标签
RT-Thread Studio
串口
LWIP
Env
SPI
Bootloader
AT
ART-Pi
Hardfault
CAN总线
FinSH
USB
文件系统
RT-Thread
DMA
SCons
线程
RT-Thread Nano
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
ota在线升级
WIZnet_W5500
I2C_IIC
UART
flash
cubemx
packages_软件包
freemodbus
潘多拉开发板_Pandora
PWM
定时器
ADC
BSP
中断
keil_MDK
编译报错
socket
MicroPython
GD32
msh
Debug
ulog
SDIO总线
SFUD
rt_mq_消息队列_msg_queue
C++_cpp
本月问答贡献
xiaorui
7
个答案
3
次被采纳
sakumisu
4
个答案
3
次被采纳
三世执戟
31
个答案
1
次被采纳
梦笑真美
18
个答案
1
次被采纳
踩姑娘的小蘑菇
14
个答案
1
次被采纳
本月文章贡献
Z_Y
2
篇文章
5
次点赞
Alipay
2
篇文章
3
次点赞
2345vor
2
篇文章
1
次点赞
比特饼干
1
篇文章
6
次点赞
Vangaoven
1
篇文章
3
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部