OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3125|回复: 3

ucosIII+emwin,其中创建界面其中一个按钮开启或者关闭定时器,一按下按钮就卡死了

[复制链接]

2

主题

8

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2016-4-5
在线时间
5 小时
发表于 2016-11-2 09:28:29 | 显示全部楼层 |阅读模式
1金钱
ucosIII+emwin,其中创建界面其中一个按钮开启或者关闭定时器,一按下按钮就卡死了,如果注释掉开启或者关闭定时器的代码,就可以运行




#include "DIALOG.h"
#include "windowdlg.h"
#include "timstart.h"

//计步开始标志位
extern u8 Mpu6050_Start_Flag;
//mpu6050跑步走路标志位
extern u8 Walk_Run_Flag;
//mpu6050运动步数
extern u32 Mpu6050_Count;
//mpu6050运动时间
extern u32 Mpu6050_Time;
//mpu6050运动时间更新标志
extern u8 Mpu6050_Timer_Flag;
//mpu6050运动速度
extern float Mpu6050_Speed;
//mpu6050运动消耗的卡路里
extern u32 Mpu6050_Kcal;

WM_HWIN hWin_Mpu6050_Count;
WM_HWIN hWin_Mpu6050_Time;
WM_HWIN hWin_Mpu6050_Start_Button;
WM_HWIN hWin_Mpu6050_Clear_Button;
WM_HWIN hWin_Mpu6050_Run_Walk_RADIO;
WM_HWIN hWin_Mpu6050_Edit_count;
WM_HWIN hWin_Mpu6050_Edit_time;

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_0 (GUI_ID_USER + 0x02)
#define ID_RADIO_0 (GUI_ID_USER + 0x04)
#define ID_EDIT_0 (GUI_ID_USER + 0x05)
#define ID_BUTTON_1 (GUI_ID_USER + 0x06)
#define ID_TEXT_0 (GUI_ID_USER + 0x07)
#define ID_TEXT_1 (GUI_ID_USER + 0x08)
#define ID_EDIT_1 (GUI_ID_USER + 0x09)

// 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[] = {
  { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 144, 20, 95, 27, 0, 0x0, 0 },
  { RADIO_CreateIndirect, "Radio", ID_RADIO_0, 21, 25, 80, 60, 0, 0x2802, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 44, 136, 80, 20, 0, 0x64, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 143, 65, 97, 27, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_0, 43, 115, 80, 20, 0, 0x64, 0 },
    { TEXT_CreateIndirect, "Text", ID_TEXT_1, 161, 115, 80, 20, 0, 0x64, 0 },
  { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 166, 136, 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 'Button'
    //
    hWin_Mpu6050_Start_Button = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hWin_Mpu6050_Start_Button, "Start");
    //
    // Initialization of 'Radio'
    //
    hWin_Mpu6050_Run_Walk_RADIO = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0);
    RADIO_SetText(hWin_Mpu6050_Run_Walk_RADIO, "   Walk", 0);
    RADIO_SetText(hWin_Mpu6050_Run_Walk_RADIO, "   Run", 1);
    //
    // Initialization of 'Button'
    //
    hWin_Mpu6050_Clear_Button = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText(hWin_Mpu6050_Clear_Button, "Clear");
    //
    // Initialization of 'Text'
    //
    hWin_Mpu6050_Count = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetTextAlign(hWin_Mpu6050_Count, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetText(hWin_Mpu6050_Count, "Count");
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
       
       
         hWin_Mpu6050_Edit_count = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
        EDIT_SetTextAlign(hWin_Mpu6050_Edit_count, GUI_TA_HCENTER | GUI_TA_VCENTER);
       
        hWin_Mpu6050_Time = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetTextAlign(hWin_Mpu6050_Time, GUI_TA_HCENTER | GUI_TA_VCENTER);
    TEXT_SetText(hWin_Mpu6050_Time, "Time");
       
           hWin_Mpu6050_Edit_time = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
    EDIT_SetTextAlign(hWin_Mpu6050_Edit_time, GUI_TA_HCENTER | GUI_TA_VCENTER);
               
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_0: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
                  if(Mpu6050_Start_Flag==0)  
                  {
                        Mpu6050_Start_Flag=1;     
                        BUTTON_SetText(hWin_Mpu6050_Start_Button,"Stop");
                          Tim2_Start_Stop(1);      //开启定时器
                  }
                 else if(Mpu6050_Start_Flag==1)
                 {
                        Mpu6050_Start_Flag=0;
                       
                        BUTTON_SetText(hWin_Mpu6050_Start_Button,"Start");
                 }
        // 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_RADIO_0: // Notifications sent by 'Radio'
      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_0: // 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:
                  Walk_Run_Flag=RADIO_GetValue(hWin_Mpu6050_Run_Walk_RADIO);
        // 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_BUTTON_1: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
                  Mpu6050_Count=0;
                  EDIT_SetText(hWin_Mpu6050_Edit_count,"000");
                EDIT_SetText(hWin_Mpu6050_Edit_time,"000");
                  
        // 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
      }
    // 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
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateWindow
*/

WM_HWIN CreateWindow(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 MPU6050_Demo(void)
{

CreateWindow();
}

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

2

主题

8

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2016-4-5
在线时间
5 小时
 楼主| 发表于 2016-11-2 09:29:54 | 显示全部楼层
把  Tim2_Start_Stop(1);     注释掉就可以运行了,求助时咋回事
回复

使用道具 举报

2

主题

8

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2016-4-5
在线时间
5 小时
 楼主| 发表于 2016-11-2 09:30:15 | 显示全部楼层
人工置顶,人工置顶,急急急
回复

使用道具 举报

2

主题

8

帖子

0

精华

新手上路

积分
36
金钱
36
注册时间
2016-4-5
在线时间
5 小时
 楼主| 发表于 2016-11-2 16:29:17 | 显示全部楼层
人工置顶
回复

使用道具 举报

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

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2024-11-22 20:58

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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