论坛元老
- 积分
- 3312
- 金钱
- 3312
- 注册时间
- 2015-4-19
- 在线时间
- 364 小时
|
发表于 2020-10-23 09:02:48
|
显示全部楼层
- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.44 *
- * Compiled Nov 10 2017, 08:53:57 *
- * (c) 2017 Segger Microcontroller GmbH & Co. KG *
- * *
- **********************************************************************
- * *
- * Internet: [url]www.segger.com[/url] Support: [email]support@segger.com[/email] *
- * *
- **********************************************************************
- */
- // USER START (Optionally insert additional includes)
- // USER END
- #include "DIALOG.h"
- #include "led.h"
- #include "lcd.h"
- #include "usart.h"
- #include "touch.h" //2020-9-22
- #include "dht11.h" //2020-10-8
- #include "rtc.h"
- #include "stdio.h"
- #include "string.h" //2020-10-13 sprintf((char *)dtbuf,"Longitude:%.5f %1c ",tp/=100000,gpsx.ewhemi); //òyèë°ÑêyÖμ×a»ˉÎa×Ö·û′®
- /*********************************************************************
- *
- * 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)
- #define ID_TEXT_0 (GUI_ID_USER + 0x03)
- #define ID_EDIT_0 (GUI_ID_USER + 0x04)
- #define ID_TEXT_1 (GUI_ID_USER + 0x05)
- #define ID_TEXT_2 (GUI_ID_USER + 0x06)
- #define ID_EDIT_1 (GUI_ID_USER + 0x07)
- #define ID_TEXT_3 (GUI_ID_USER + 0x08)
- #define ID_TEXT_4 (GUI_ID_USER + 0x09) //èÕÆú
- #define ID_TEXT_5 (GUI_ID_USER + 0x0a) //ê±¼ä
- // 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, "Framewin", ID_FRAMEWIN_0, 2, 0, 320, 240, 0, 0x0, 0 },
- { BUTTON_CreateIndirect, "Menu1", ID_BUTTON_0, 31, 188, 80, 20, 0, 0x0, 0 },
- { BUTTON_CreateIndirect, "Menu2", ID_BUTTON_1, 196, 188, 80, 20, 0, 0x0, 0 },
-
- { TEXT_CreateIndirect, "TEMP:", ID_TEXT_0, 109, 71, 38, 20, 0, 0x0, 0 },
- { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 146, 71, 44, 20, 0, 0x64, 0 },
- { TEXT_CreateIndirect, "'C", ID_TEXT_1, 194, 71, 31, 20, 0, 0x0, 0 },
-
- { TEXT_CreateIndirect, "HUMI:", ID_TEXT_2, 109, 103, 37, 20, 0, 0x0, 0 },
- { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 146, 102, 44, 20, 0, 0x64, 0 },
- { TEXT_CreateIndirect, "%RH", ID_TEXT_3, 194, 104, 32, 21, 0, 0x0, 0 },
- //{ TEXT_CreateIndirect, "data", ID_TEXT_4, 116, 169, 80, 20, 0, 0x64, 0 },
- //{ TEXT_CreateIndirect, "time", ID_TEXT_5, 122, 187, 80, 20, 0, 0x64, 0 },
- { TEXT_CreateIndirect, "data", ID_TEXT_4, 109, 143, 80, 20, 0, 0x64, 0 },
- { TEXT_CreateIndirect, "time", ID_TEXT_5, 113, 167, 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: //3õê¼»ˉÏûÏ¢
- //
- // Initialization of 'Edit'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
- //EDIT_SetText(hItem, "22");
- //EDIT_SetText(hItem, temperature);
- //
- // Initialization of 'Edit'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
- //EDIT_SetText(hItem, "65");
- //EDIT_SetText(hItem,humidity );
- //
- // Initialization of '%RH'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);//guibuilder ÖDóD¸33õÖμμĿؼt£¬»áÕaàïÔúÖDÖ′DD
- TEXT_SetFont(hItem, GUI_FONT_24B_ASCII);
- // USER START (Optionally insert additional code for further widget initialization)
- // USER END hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
- TEXT_SetText(hItem, "2020/10/17");
- TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
-
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
- TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
- TEXT_SetText(hItem, "15:10:10");
-
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch(Id) {
- case ID_BUTTON_0: // Notifications sent by 'Menu1'
- 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)
- LED2=!LED2; //2020-9-22 led2è¡·′
- GUI_EndDialog(pMsg->hWin, 0); //2020-9-18 ½áêø±¾¶Ô»°¿ò
- Createmenu1(); //2020-9-18 ′′½¨òaÏÔê¾μĶԻ°¿ò,¼′¾íêÇ1رÕá˱¾2ã¶Ô»°¿ò£¬ÏÔê¾DÂμĶԻ°¿ò£¬½ø¶øêμÏÖáËÇD»»½çÃæ1
-
- // USER END
- break;
- // USER START (Optionally insert additional code for further notification handling)
- // USER END
- }
- break;
- case ID_BUTTON_1: // Notifications sent by 'Menu2'
- 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)
- LED2=!LED2; //2020-9-22 led2è¡·′
-
- GUI_EndDialog(pMsg->hWin, 0); //2020-9-18 ½áêø±¾¶Ô»°¿ò
- Createmenu2(); //2020-9-18 ′′½¨òaÏÔê¾μĶԻ°¿ò,¼′¾íêÇ1رÕá˱¾2ã¶Ô»°¿ò£¬ÏÔê¾DÂμĶԻ°¿ò£¬½ø¶øêμÏÖáËÇD»»μ½½çÃæ2
-
-
- // 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:
- // 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;
- // USER START (Optionally insert additional code for further Ids)
- // USER END
- }
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- case WM_TIMER: //2020-10-13 ′°¿ú¶¨ê±Æ÷ÏûÏ¢
- // GET_Data_DHT11(); //2020-10-13 »ñè¡êμê±êyÖμ
- DISPLAY_DATA_DHT11(pMsg); //2020-10-13 ¸üDÂêyÖμ
- //DISPLAY_RTC(pMsg); //2020-10-13 ¸üDÂêyÖμ
-
- WM_RestartTimer(pMsg->Data.v, 100); //2020-10-13 ÖØÆô′°¿ú¶¨ê±Æ÷
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * CreateFramewin
- */
- WM_HWIN CreateFramewin(void);
- WM_HWIN CreateFramewin(void) {
- WM_HWIN hWin;
- hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
-
- WM_CreateTimer(WM_GetClientWindow(hWin), 0, 100, 0); //2020-10-13 ¶¨ê±Æ÷»ñè¡′°¿úμľä±ú,100ms
-
- return hWin;
- }
- // USER START (Optionally insert additional public code)
- /*********************************************************************
- *
- * _cbDialog
- */
- void DISPLAY_DATA_DHT11(WM_MESSAGE *pMsg)
- {
- char temperature_s[10];
- char humidity_s[10];
- WM_HWIN hItem;
- WM_HWIN hWin = pMsg->hWin;
-
- /***** 릏 *******/
- sprintf(temperature_s, "%d", temperature); //2020-10-13 ζèêy¾Y×a»ˉ3é×Ö·û′®
- hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
- EDIT_SetText(hItem, temperature_s);
- EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
- EDIT_SetFont(hItem, GUI_FONT_32_ASCII);
- /***** êa¶è *******/
- sprintf(humidity_s, "%d",humidity); //2020-10-13 êa¶èêy¾Y×a»ˉ3é×Ö·û′®
- hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
- EDIT_SetText(hItem, humidity_s);
- EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
- EDIT_SetFont(hItem, GUI_FONT_32_ASCII);
- }
- /**************************************************************************************************************************************************
- ÏÔê¾RTCèÕÆúóëê±¼ä
- ***************************************************************************************************************************************************/
- void DISPLAY_RTC(WM_MESSAGE *pMsg)
- {
- char date_s[6];//èÕÆú
- char time_s[6];//ê±¼ä
- WM_HWIN hItem;
- WM_HWIN hWin = pMsg->hWin;
-
- sprintf(date_s,"%02d:%02d:%02d",RTC_DateStruct.RTC_Year,RTC_DateStruct.RTC_Month,RTC_DateStruct.RTC_Date); //ÄêÔÂèÕ
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
- TEXT_SetText(hItem, date_s);
- TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
- TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
- //printf("Date: %02d-%02d-%02d\r\n",RTC_DateStruct.RTC_Year,RTC_DateStruct.RTC_Month,RTC_DateStruct.RTC_Date);
-
-
- sprintf(time_s,"%02d:%02d:%02d",RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds); //ê±·ÖÃë
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
- TEXT_SetText(hItem, time_s);
- TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
- TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
- //printf("Time: %02d-%02d-%02d\r\n",RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds);
-
- }
- void DISPLAY_RTC1(void)//ÏÔê¾RTCèÕÆúóëê±¼ä
- {
- char date_s[6];//èÕÆú
- char time_s[6];//ê±¼ä
- // sprintf((char*)tbuf,"Time:%02d:%02d:%02d",hour,min,sec);
- // GUI_DispStringAt(tbuf,30,200);
- // sprintf((char*)tbuf,"Date:20%02d-%02d-%02d",year,month,date);
- sprintf(time_s,"Time:%02d:%02d:%02d",RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds);
- GUI_DispStringAt(time_s,30,200);
- sprintf(date_s,"Date:20%02d-%02d-%02d",RTC_DateStruct.RTC_Year,RTC_DateStruct.RTC_Month,RTC_DateStruct.RTC_Date);
- GUI_DispStringAt(date_s,50,200);
- }
- ///******************************** emwinÖ÷oˉêy **************************************************************************************************/
- void MainTask(void)
- {
- GUI_SetBkColor(GUI_BLUE);
- GUI_Clear();
-
- GUI_CURSOR_Show();
- GUI_SetColor(GUI_WHITE);
- GUI_SetFont(GUI_FONT_32B_1);
-
- GUI_DispString("Hello World!\r\nNO RTOS");
- printf("\r\n ********** emwin start *********** \r\n");
- delay_ms(1000);
- //GUI_SetOrientation(0); //2020-9-6 éèÖÃÎaoáÆá ¸Ä2»1yà′
- CreateFramewin();
-
-
- while(1)
- {
- //LED2_TOGGLE;
- //printf("\r\n ********** EmWin run *********** \r\n");
- //printf("\r\n ********** TP_Read_XY2() err! return 0 *********** \r\n"); //2020-9-26
- //printf("x=%d,y=%d \r\n",*x,*y); //2020-9-26
- DHT11_Read_Data(&temperature,&humidity); //¶áè¡ÎÂêa¶èÖμ
- printf("temperature=%d C',humidity=%d %RH\r\n",temperature,humidity); //2020-9-26
- // printf("\r\n ********** TP_Read_XY2() ok! return 1 *********** \r\n"); //2020-9-13
- // printf("x=%d,y=%d \r\n",tp_dev.x[0],tp_dev.y[0]); //2020-9-26
- // LCD_ShowNum(30+40,150,temperature,2,16); //test 2020-10-12
- //LCD_ShowNum(30+40,170,humidity,2,16); //
- RTC_GetTimes(RTC_Format_BIN); //2020-10-17 »ñè¡rtcê±¼ä×Ö½úDí
- //RTC_GetTimes(RTC_Format_BCD); //test
- // printf("Date: %02d-%02d-%02d\r\n",RTC_DateStruct.RTC_Year,RTC_DateStruct.RTC_Month,RTC_DateStruct.RTC_Date);
- // printf("Time: %02d-%02d-%02d\r\n",RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds);
- printf("Date: %d/%d/%d\r\n",RTC_DateStruct.RTC_Year,RTC_DateStruct.RTC_Month,RTC_DateStruct.RTC_Date);
- printf("Time: %d:%d:%d\r\n",RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds);
- //TEXT_SetText(WM_GetDialogItem(hWin,ID_EDIT_0),temperature);
- LED1=!LED1;
- DISPLAY_RTC1();
- GUI_Delay(1000);
-
- }
- }
- // USER END
- /*************************** End of file ****************************/
复制代码 |
|