完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
STM32f429+ FreeRTOS +EMWIN + 5寸屏
使用GUI_WIDGET_CREATE_INFO 资源表创建窗体, 1)主窗体使用: hWinMain = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog_main, WM_HBKWIN, 0, 0); 2)外部实体按键检测到对应的键值,发送自定义消息,WM_SendMessageNoPara(WM_GetClientWindow(hWinMain), MSG_DCV); 3)自定义消息处理--》_cbDialog_main 回调函数 -- case MSG_DCV: hDCV = GUI_CreateDialogBox(_aDialogCreate_DCV, GUI_COUNTOF(_aDialogCreate_DCV), _cbCallback_DCV_new, WM_HBKWIN, 0, 0); 4)创建窗体显示控件 但是下个几个情况: ① 在 case WM_INIT_DIALOG中对EDIT 进行WM_SetFocus操作时,窗体不能正确显示;单独在MainTask函数调用是正常的; 假若在MainTask.c 文件使用hWinMain = GUI_CreateDialogBox(_aDialogCreate_DCV, GUI_COUNTOF(_aDialogCreate_DCV), _cbCallback_DCV_new, 0, 0, 0); 直接创建,窗体可以正常显示,也能聚焦到EDIT0, ② 在 case WM_INIT_DIALOG中对BUTTON 进行BUTTON_SetFocusable(hutem,0)操作时,窗体不能正确显示; ③ case MSG_Set_Limit: 外部实体按键发送自定义消息,收到后对EDIT0设置焦点,Focus_index的值仿真也变成01,下面的EDIT_SetSel(hItem,0,-1); 本意是对EDIT0 的内容全选, 实际的测试结果不正常 单片机死机 ; ============================================================================= ① 的问题,仿真运行程序发现,程序运行卡死在 _cbCallback_DCV_new回调函数中的WM_INIT_DIALOG部分的 hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2); 这个位置;如若将这部分代码注释掉,则卡死在后面的代码语句; ============================================================================= // 窗体资源表 static const GUI_WIDGET_CREATE_INFO _aDialogCreate_DCV[] = { { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 800, 480, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 660, 20, 120, 40, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 660, 80, 120, 40, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Button", ID_BUTTON_2, 660, 140, 120, 40, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Button", ID_BUTTON_3, 660, 200, 120, 40, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Button", ID_BUTTON_4, 660, 260, 120, 40, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Button", ID_BUTTON_5, 660, 320, 120, 40, 0, 0x0, 0 }, { BUTTON_CreateIndirect, "Button", ID_BUTTON_6, 660, 380, 120, 40, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_0, 260, 10, 90, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_1, 450, 107, 55, 38, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_2, 530, 88, 80, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_3, 530, 120, 80, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_4, 90, 200, 40, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_8, 40, 91, 420, 64, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_9, 280, 200, 80, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_11, 20, 340, 80, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_12, 90, 340, 120, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_13, 190, 340, 80, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_14, 20, 385, 140, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_15, 130, 385, 120, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_16, 250, 385, 120, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_17, 360, 384, 120, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_21, 470, 340, 121, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_23, 470, 385, 90, 32, 0, 0x0, 0 }, { TEXT_CreateIndirect, "Text", ID_TEXT_24, 571, 385, 80, 32, 0, 0x0, 0 }, { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 90, 335, 100, 37, 0, 0x0, 0 }, { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 580, 335, 60, 37, 0, 0x0, 0 }, { EDIT_CreateIndirect, "Edit", ID_EDIT_2, 128, 200, 150, 37, 0, 0x0, 0 }, { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 90, 335, 100, 37, 0, 0x0, 0 }, { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 580, 335, 60, 37, 0, 0x0, 0 }, { EDIT_CreateIndirect, "Edit", ID_EDIT_2, 128, 200, 150, 37, 0, 0x0, 0 }, }; // 回调函数 static void _cbCallback_DCV_new(WM_MESSAGE * pMsg) { int NCode, Id; WM_HWIN hWin = pMsg->hWin; WM_HWIN hItem; unsigned char Focus_index; switch (pMsg->MsgId) { case WM_PAINT : //GUI_SetBkColor(0xff87CEEB); GUI_SetBkColor(0xCCE8CF); GUI_Clear(); GUI_SetPenSize(4); GUI_SetColor(0x993333); GUI_DrawLine(10,330,645,330); GUI_DrawLine(10,330,10,430); GUI_DrawLine(645,330,645,430); GUI_DrawLine(10,430,645,430); GUI_DrawLine(10,375,645,375); GUI_DrawLine(240,330,240,430); GUI_DrawLine(460,330,460,430); break; case WM_INIT_DIALOG: hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetFont(hItem,GUI_FONT_32B_1); BUTTON_SetText(hItem,""); //WM_DisableWindow(hItem); //BUTTON_SetFocusable(hItem,0); //WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetFont(hItem,GUI_FONT_32B_1); BUTTON_SetText(hItem,"+ -"); //BUTTON_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2); BUTTON_SetFont(hItem,GUI_FONT_32B_1); BUTTON_SetText(hItem,"Limit"); //BUTTON_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3); BUTTON_SetFont(hItem,GUI_FONT_32B_1); BUTTON_SetText(hItem,"Voltage"); //BUTTON_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_4); BUTTON_SetFont(hItem,GUI_FONT_32B_1); BUTTON_SetText(hItem,"Gear"); //BUTTON_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_5); BUTTON_SetFont(hItem,GUI_FONT_32B_1); BUTTON_SetText(hItem,""); //BUTTON_SetFocusable(hItem,0); //WM_DisableWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_6); BUTTON_SetFont(hItem,GUI_FONT_32B_1); BUTTON_SetText(hItem,"Reback"); //BUTTON_SetFocusable(hItem,0); //WM_DisableWindow(hItem); //WIDGET_SetFocusable(hItem,0); #if 0 hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); WM_DisableWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); WM_DisableWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2); WM_DisableWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3); WM_DisableWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_4); WM_DisableWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_5); WM_DisableWindow(hItem); //hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_6); //WM_DisableWindow(hItem); #endif hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); EDIT_SetFont(hItem, GUI_FONT_32B_1); EDIT_SetTextColor(hItem, EDIT_CI_ENABLED,GUI_RED); EDIT_SetText(hItem,"100.00"); WIDGET_SetFocusable(hItem,1); // 程序运行此条语句,窗体不能正常显示 //WM_SetFocus(hItem); //EDIT_EnableBlink(hItem,1000,1); //EDIT_SetSel(hItem,0,-1); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1); EDIT_SetText(hItem,"5"); EDIT_SetTextColor(hItem, EDIT_CI_ENABLED,GUI_MAGENTA); EDIT_SetFont(hItem, GUI_FONT_32_1); WIDGET_SetFocusable(hItem,1); EDIT_SetpfAddKeyEx(hItem, _cbEditAddKey); //WM_DisableWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2); EDIT_SetText(hItem,"100.00"); EDIT_SetTextColor(hItem, EDIT_CI_ENABLED,GUI_BLUE); EDIT_SetFont(hItem, GUI_FONT_32_1); WIDGET_SetFocusable(hItem,1); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetFont(hItem,GUI_FONT_32B_1); TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"DC-V"); WIDGET_SetFocusable(hItem,0); WM_DisableWindow(hItem); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"V"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetFont(hItem,GUI_FONT_32B_1); TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x000000FF)); TEXT_SetText(hItem,"OFF"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetFont(hItem,GUI_FONT_32B_1); TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"Hand"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"V_"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8); TEXT_SetFont(hItem,GUI_FONT_D64); TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"0.000000"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_9); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"V"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_11); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"Limit"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_13); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"V"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_14); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"R_Error"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_15); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetTextColor(hItem,GUI_BLUE); TEXT_SetText(hItem,"0.000%"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_16); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"A_Error"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_17); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetTextColor(hItem,GUI_BLUE); TEXT_SetText(hItem,"0.000%"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_21); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"Division"); WIDGET_SetFocusable(hItem,0); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_23); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"Status"); hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_24); TEXT_SetFont(hItem,GUI_FONT_32B_1); //TEXT_SetTextColor(hItem,GUI_MAKE_COLOR(0x00800000)); TEXT_SetText(hItem,"OK"); WIDGET_SetFocusable(hItem,0); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { } break; case WM_TIMER: break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_TAB: break; case GUI_KEY_LEFT://GUI_KEY_LEFT break; case GUI_KEY_RIGHT://GUI_KEY_LEFT break; case GUI_KEY_ENTER: break; } break; case MSG_Set_Limit: hItem = WM_GetDialogItem(pMsg->hWin,ID_EDIT_0); WM_SetFocus(hItem); Focus_index = WM_HasFocus(WM_GetDialogItem(pMsg->hWin,ID_EDIT_0)); EDIT_SetSel(hItem,0,-1); break; default: WM_DefaultProc(pMsg); break; } } |
|
相关推荐
1个回答
|
|
CV, WM_HBKWIN, 0, 0); 创建子窗体,但是子窗体不能正常显示。
要解决这个问题,可以尝试以下几种方法: 1. 确保资源表_aDialogCreate_DCV中的窗体控件配置正确。检查窗体的大小、位置、颜色等属性是否正确设置。 2. 检查DialogCreate_DCV数组的长度是否正确。使用GUI_COUNTOF(_aDialogCreate_DCV)获取数组的长度,确保长度是正确的。 3. 确保在创建子窗体时使用了正确的父窗口句柄。在第三个参数中指定正确的父窗口句柄,这样子窗体才能正确附加到父窗口上。 4. 检查是否在创建子窗体之后调用了GUI_Exec函数。在创建了所有窗体之后,需要调用GUI_Exec函数以启动emWin图形界面的绘制。 5. 确保FreeRTOS的任务调度正常工作。检查FreeRTOS的配置文件以及任务创建、优先级设置等是否正确,确保所有任务都能正常运行。 如果以上方法都没有解决问题,建议使用调试工具来跟踪代码执行过程,查看是否有错误发生,以及确定具体出现问题的位置。可以使用调试器来查看代码的执行流程、变量的值等信息,以便更准确地定位和解决问题。 |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1617 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1543 浏览 1 评论
977 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
683 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1595 浏览 2 评论
1863浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
644浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
515浏览 3评论
531浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
504浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 04:17 , Processed in 0.647948 second(s), Total 48, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号