硬汉嵌入式论坛

 找回密码
 立即注册
查看: 1281|回复: 4
收起左侧

[emWin] 关于EMWIN的BUTTON按键问题

[复制链接]

1

主题

2

回帖

1

积分

新手上路

积分
1
发表于 2017-9-22 16:14:52 | 显示全部楼层 |阅读模式
用GUIBuilder做了一个界面,在UP和DOWN设置了两个LED灯亮灭的功能,我发现只要WM_INIT_DIALOG:中不加入FRAMEWIN_SetTextColor(hItem, 0x0000FFFF);设置标题颜色按键就不会响应是屏幕上所有按键都无效,设置了之后才会响应,到底是怎么回事?谢谢!


#include "..\User\usart\bsp_usart1.h"
#include "DIALOG.h"
#include "..\User\lcd\bsp_ili9341_lcd.h"
#include "..\User\led\bsp_led.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0    (GUI_ID_USER + 0x00)
#define ID_BUTTON_0    (GUI_ID_USER + 0x02)
#define ID_BUTTON_1    (GUI_ID_USER + 0x03)
#define ID_BUTTON_2    (GUI_ID_USER + 0x04)
#define ID_BUTTON_3    (GUI_ID_USER + 0x05)
#define ID_BUTTON_4    (GUI_ID_USER + 0x06)
#define ID_BUTTON_5    (GUI_ID_USER + 0x07)
#define ID_BUTTON_6    (GUI_ID_USER + 0x08)
#define ID_BUTTON_7    (GUI_ID_USER + 0x09)
#define ID_BUTTON_8    (GUI_ID_USER + 0x0A)
#define ID_TEXT_0    (GUI_ID_USER + 0x0B)
#define ID_TEXT_1    (GUI_ID_USER + 0x0C)
#define ID_TEXT_2    (GUI_ID_USER + 0x0D)
#define ID_TEXT_3    (GUI_ID_USER + 0x0E)
#define ID_TEXT_4    (GUI_ID_USER + 0x0F)
#define ID_EDIT_0    (GUI_ID_USER + 0x12)
#define ID_EDIT_1    (GUI_ID_USER + 0x13)
#define ID_EDIT_2    (GUI_ID_USER + 0x14)
#define ID_EDIT_3    (GUI_ID_USER + 0x15)
#define ID_TEXT_5    (GUI_ID_USER + 0x16)
#define ID_TEXT_6    (GUI_ID_USER + 0x18)
#define ID_EDIT_4    (GUI_ID_USER + 0x19)
#define ID_TEXT_7    (GUI_ID_USER + 0x1A)
#define ID_TEXT_8    (GUI_ID_USER + 0x1B)
#define ID_EDIT_5    (GUI_ID_USER + 0x1C)


// USER START (Optionally insert additional defines)
// USER END

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

// USER START (Optionally insert additional static data)
// USER END

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { FRAMEWIN_CreateIndirect, "JT", ID_FRAMEWIN_0, 0, 0, 240, 320, 0, 0x64, 0 },
  { BUTTON_CreateIndirect, "Rest", ID_BUTTON_0, 17, 205, 50, 20, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Speed", ID_BUTTON_1, 149, 270, 50, 20, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Down", ID_BUTTON_2, 83, 270, 50, 20, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Spindle", ID_BUTTON_3, 17, 270, 50, 20, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Right", ID_BUTTON_4, 149, 238, 50, 20, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Measure", ID_BUTTON_5, 83, 238, 50, 20, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Left", ID_BUTTON_6, 17, 238, 50, 20, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, &quotrint", ID_BUTTON_7, 149, 205, 50, 20, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Up", ID_BUTTON_8, 83, 205, 50, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Torque:", ID_TEXT_0, 9, 22, 80, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "SP:", ID_TEXT_1, 18, 59, 16, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "C", ID_TEXT_2, 182, 22, 10, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "T:", ID_TEXT_3, 128, 22, 10, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "%", ID_TEXT_4, 90, 22, 10, 20, 0, 0x0, 0 },
  { EDIT_CreateIndirect, "0.0", ID_EDIT_0, 48, 20, 40, 20, 0, 0x64, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 140, 20, 40, 20, 0, 0x64, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_2, 48, 57, 40, 20, 0, 0x64, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_3, 125, 57, 45, 20, 0, 0x64, 0 },
  { TEXT_CreateIndirect, "RPM", ID_TEXT_5, 174, 59, 80, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Viscosity:", ID_TEXT_6, 12, 93, 45, 20, 0, 0x0, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_4, 58, 90, 60, 20, 0, 0x64, 0 },
  { TEXT_CreateIndirect, "mPa.s", ID_TEXT_7, 122, 93, 80, 20, 0, 0x0, 0 },
  { TEXT_CreateIndirect, &quot/T:", ID_TEXT_8, 16, 130, 25, 20, 0, 0x0, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_5, 42, 128, 80, 20, 0, 0x64, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

// USER START (Optionally insert additional static code)
// USER END

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  int     NCode;
  int     Id;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'JT'
    //
    hItem = pMsg->hWin;
    FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
          FRAMEWIN_SetTextColor(hItem, 0x0000FFFF);  //去掉屏幕所有地方都不响应
    //
    // Initialization of '0.0'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
    EDIT_SetText(hItem, "0.0");
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
    EDIT_SetText(hItem, "0.0");
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2);
    EDIT_SetText(hItem, "0");
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_3);
    EDIT_SetText(hItem, "000.0");
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_4);
    EDIT_SetText(hItem, "0");
    //
    // Initialization of 'Edit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_5);
    EDIT_SetText(hItem, "00:00");
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_0: // Notifications sent by 'Rest'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by 'Speed'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_2: // Notifications sent by 'Down'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
                                LED2_TOGGLE;
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_3: // Notifications sent by 'Spindle'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END

        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_4: // Notifications sent by 'Right'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_5: // Notifications sent by 'Measure'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_6: // Notifications sent by 'Left'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_7: // Notifications sent by &#39rint'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_8: // Notifications sent by 'Up'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
                                LED1_TOGGLE;
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_0: // Notifications sent by '0.0'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_1: // Notifications sent by 'Edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_2: // Notifications sent by 'Edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_3: // Notifications sent by 'Edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_4: // Notifications sent by 'Edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_EDIT_5: // Notifications sent by 'Edit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateJT
*/
WM_HWIN CreateJT(void);
WM_HWIN CreateJT(void) {
  WM_HWIN hWin;

hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);

  return hWin;
}

// USER START (Optionally insert additional public code)
// USER END

/*************************** End of file ****************************/
void MainTask(void)
{

//WM_SetCreateFlags(WM_CF_MEMDEV);

  GUI_Init();


  CreateJT();

        LCD_BK_EN;
  while(1)
{

  GUI_Delay(10);
}
}
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107604
QQ
发表于 2017-9-23 01:20:00 | 显示全部楼层
单看你的程序,没有问题的,你用了RTOS没有,用了的话,加大下emWin任务的任务栈看看。
回复

使用道具 举报

1

主题

2

回帖

1

积分

新手上路

积分
1
 楼主| 发表于 2017-9-29 10:54:06 | 显示全部楼层
确实是堆栈问题,我没有用RTOS,上网查了试着加大了堆栈,结果就没问题了,谢谢
回复

使用道具 举报

1

主题

2

回帖

1

积分

新手上路

积分
1
 楼主| 发表于 2017-9-29 10:54:37 | 显示全部楼层

回 eric2013 的帖子

eric2013:单看你的程序,没有问题的,你用了RTOS没有,用了的话,加大下emWin任务的任务栈看看。 (2017-09-23 01:20) 
确实是堆栈问题,我没有用RTOS,上网查了试着加大了堆栈,结果就没问题了,谢谢
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107604
QQ
发表于 2017-9-30 00:25:45 | 显示全部楼层

回 jingtian 的帖子

jingtian:确实是堆栈问题,我没有用RTOS,上网查了试着加大了堆栈,结果就没问题了,谢谢 (2017-09-29 10:54) 
任务堆栈小的时候,会有这种奇怪问题,让人摸不着头脑
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-6-7 21:07 , Processed in 0.192758 second(s), 31 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表