基本信息
源码名称:使用图形界面控制LED的亮灭
源码大小:17.53M
文件格式:.zip
开发语言:C/C++
更新时间:2019-11-29
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
在stm32单片机上显示两个按钮,分别控制两个灯(LED0,LED1)。





//EMWIN(图形界面) 灯控

/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.26                          *
*        Compiled Aug  8 2014, 14:49:54                              *
*        (c) 2013 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

#include "LED.h"
#include "DIALOG.h"
#include "BUTTON.h"


/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0        (GUI_ID_USER 0x00)
#define ID_BUTTON_0        (GUI_ID_USER 0x01)
#define ID_BUTTON_1        (GUI_ID_USER 0x02)


// 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, "LightControl", ID_FRAMEWIN_0, 3, 0, 390, 350, 0, 0x64, 0 },
  { BUTTON_CreateIndirect, "LED2", ID_BUTTON_0, 200, 156, 105, 37, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "LED1", ID_BUTTON_1, 30, 156, 105, 37, 0, 0x0, 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 'LightControl'
    //
        hItem = pMsg->hWin;
        FRAMEWIN_SetText(hItem, "LightControl");
        FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
        FRAMEWIN_SetTitleHeight(hItem, 40);
        FRAMEWIN_SetFont(hItem, GUI_FONT_32B_1);
  //³õʼ»¯BUTTON0
    hItem=WM_GetDialogItem(pMsg->hWin,ID_BUTTON_0);
    BUTTON_SetFont(hItem,GUI_FONT_COMIC24B_ASCII);
    BUTTON_SetText(hItem,"LED0");
  //³õʼ»¯BUTTON1
    hItem=WM_GetDialogItem(pMsg->hWin,ID_BUTTON_1);
    BUTTON_SetFont(hItem,GUI_FONT_COMIC24B_ASCII);
    BUTTON_SetText(hItem,"LED1");
 
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id)
{
        case ID_BUTTON_0: // Notifications sent by 'LED2'
        switch(NCode) {
                    case WM_NOTIFICATION_CLICKED:
                    // USER START (Optionally insert code for reacting on notification message)
                    // USER END
                    break;
                   case WM_NOTIFICATION_RELEASED:
                    LED0=~LED0;
                    break;
                   // USER START (Optionally insert additional code for further notification handling)
                   // USER END
                                }
      break;
    case ID_BUTTON_1: // Notifications sent by 'LED1'
      switch(NCode) {
                          case WM_NOTIFICATION_CLICKED:
                            // USER START (Optionally insert code for reacting on notification message)
                            // USER END
                            break;
                          case WM_NOTIFICATION_RELEASED:
                               LED1=~LED1;
                            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
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateLightControl
*/
WM_HWIN CreateLightControl(void);
WM_HWIN CreateLightControl(void) {
  WM_HWIN hWin;

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


//BUTTONÑÝʾº¯Êý
void Main_task(void)
{
    WM_HWIN hWIN;
    hWIN=CreateLightControl();
    while(1)
    {
        GUI_Delay(100);
    }    
};    

/*************************** End of file ****************************/