初级会员
- 积分
- 165
- 金钱
- 165
- 注册时间
- 2016-5-17
- 在线时间
- 41 小时
|
发表于 2019-11-9 23:35:42
|
显示全部楼层
#include "DIALOG.h"
#include "EmWinHZFont.h"
#include "stm32f10x_it.h"
#include "led.h"
#include "beep.h"
#include "delay.h"
#include "sys.h"
#include "ILI93xx.h"
#include "usart.h"
#include "24cxx.h"
#include "flash.h"
#include "touch.h"
#include "sram.h"
#include "timer.h"
#include "sdio_sdcard.h"
#include "malloc.h"
#include "GUI.h"
#include "ff.h"
#include "exfuns.h"
#include "w25qxx.h"
#include "includes.h"
#include "fontupd.h"
#include "WM.h"
#include "DIALOG.h"
#include "gpio.h"
#include "max6675.h"
#include "rtc.h"
#include "bjdj.h"
#include "usmart.h"
#include "key.h"
#include <stdio.h>
#include "touch.h"
#include "bsp_TB6600_TIM.h"
/*********************************************************************
*
* 主页一介面
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_BUTTON_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_1 (GUI_ID_USER + 0x02)
#define ID_BUTTON_2 (GUI_ID_USER + 0x03)
#define ID_BUTTON_3 (GUI_ID_USER + 0x04)
#define ID_BUTTON_4 (GUI_ID_USER + 0x05)
#define ID_BUTTON_5 (GUI_ID_USER + 0x06)
#define ID_TEXT_0 (GUI_ID_USER + 0x07)
#define ID_TEXT_1 (GUI_ID_USER + 0x08)
#define ID_DROPDOWN_0 (GUI_ID_USER + 0x09)
#define ID_TEXT_2 (GUI_ID_USER + 0x0A)
#define ID_TEXT_3 (GUI_ID_USER + 0x0B)
#define ID_TEXT_4 (GUI_ID_USER + 0x0C)
#define ID_TEXT_5 (GUI_ID_USER + 0x0D)
#define ID_SPINBOX_0 (GUI_ID_USER + 0x0E)
#define ID_TEXT_6 (GUI_ID_USER + 0x0F)
#define ID_TEXT_7 (GUI_ID_USER + 0x10)
#define ID_TEXT_8 (GUI_ID_USER + 0x11)
#define ID_TEXT_9 (GUI_ID_USER + 0x12)
#define ID_TEXT_10 (GUI_ID_USER + 0x13)
#define ID_BUTTON_6 (GUI_ID_USER + 0x14)
#define ID_BUTTON_7 (GUI_ID_USER + 0x15)
#define ID_BUTTON_8 (GUI_ID_USER + 0x16)
#define ID_TEXT_11 (GUI_ID_USER + 0x17)
#define ID_TEXT_12 (GUI_ID_USER + 0x18)
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Window0", ID_WINDOW_0, 0, 0, 240, 285, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "00", ID_BUTTON_0, 12, 181, 65, 25, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "01", ID_BUTTON_1, 88, 181, 65, 25, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "02", ID_BUTTON_2, 165, 181, 65, 25, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "03", ID_BUTTON_3, 13, 213, 65, 25, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "04", ID_BUTTON_4, 89, 213, 65, 25, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "05", ID_BUTTON_5, 163, 213, 65, 25, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text0", ID_TEXT_0, 116, 16, 55, 29, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text1", ID_TEXT_1, 2, 62, 40, 20, 0, 0x0, 0 },
{ DROPDOWN_CreateIndirect, "Dropdown", ID_DROPDOWN_0, 5, 20, 94, 28, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text2", ID_TEXT_2, 2, 92, 40, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text3", ID_TEXT_3, 2, 120, 40, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text4", ID_TEXT_4, 2, 146, 64, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text5", ID_TEXT_5, 117, 60, 40, 20, 0, 0x0, 0 },
{ SPINBOX_CreateIndirect, "Spinbox", ID_SPINBOX_0, 173, 13, 61, 35, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text6", ID_TEXT_6, 116, 90, 40, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text7", ID_TEXT_7, 46, 60, 68, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text8", ID_TEXT_8, 50, 93, 50, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text9", ID_TEXT_9, 52, 120, 140, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text10", ID_TEXT_10, 90, 146, 50, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "06", ID_BUTTON_6, 11, 244, 65, 25, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "07", ID_BUTTON_7, 89, 244, 65, 25, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "08", ID_BUTTON_8, 164, 244, 65, 25, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text11", ID_TEXT_11, 158, 62, 70, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text12", ID_TEXT_12, 175, 92, 55, 20, 0, 0x0, 0 },
};
extern WM_HWIN CreateFramewin3(WM_HWIN hParent);
extern float temprature;//温度
int i;
int t=0;
int p;
extern int rs;//人数
extern int gn;//煮粥或煮饭
extern u16 COUN1;
static void _cbDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
// WM_HWIN hDlg;
WM_HWIN hWin = pMsg->hWin;
int NCode;
int Id;
//int Index;
int IAa;
char buf0[6];
char buf1[6];
char buf2[1];
char buf3[6];
char buf4[10];
//hDlg = pMsg->hWin;
COUN1=TIM3->CNT;//计数奇存器
switch (pMsg->MsgId)
{
case WM_TIMER://定时器消息,到时间时有效
sprintf((char*)buf0,"%02d:%02d:%02d",calendar.hour,calendar.min,calendar.sec);//时分秒
TEXT_SetText(WM_GetDialogItem(hWin,ID_TEXT_11), buf0);
sprintf((char*)buf1,"%02d/%02d/%02d",calendar.w_year,calendar.w_month,calendar.w_date);//年月日
TEXT_SetText(WM_GetDialogItem(hWin,ID_TEXT_7), buf1);
sprintf((char*)buf2,"%03d",i=temprature);//温度
TEXT_SetText(WM_GetDialogItem(hWin,ID_TEXT_12), buf2);
sprintf((char*)buf4,"%02d/%02d/%02d/%02d:%02d",calendar.w_year,calendar.w_month,calendar.w_date,alarm.hour,alarm.min);//闹钟的年月日时分秒
TEXT_SetText(WM_GetDialogItem(hWin,ID_TEXT_9), buf4);
sprintf((char*)buf3,"%03d",p=COUN1);//流量计
TEXT_SetText(WM_GetDialogItem(hWin,ID_TEXT_10), buf3);
switch(calendar.week)
{
case 0:
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "星期日");
break;
case 1:
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "星期一");
break;
case 2:
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "星期二");
break;
case 3:
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "星期三");
break;
case 4:
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "星期四");
break;
case 5:
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "星期五");
break;
case 6:
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "星期六");
break;
}
WM_RestartTimer(pMsg->Data.v, 200);
if(WM_IsCompletelyCovered(pMsg->hWin))
break; //当切换到其他页面什么都不做
break;
case WM_INIT_DIALOG://初始化消息,创建窗口/控件时有效,比如在这里设置一些控件的初始参数
hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
DROPDOWN_SetFont(hItem, &GUI_FontHZ24);
DROPDOWN_AddString(hItem, "煮饭");//给 DROPDOWN 列表添加元素
DROPDOWN_AddString(hItem, "煮粥");
DROPDOWN_AddString(hItem, "其它");
DROPDOWN_SetListHeight(hItem, 100);
hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
//gn = DROPDOWN_GetSel(hItem);//返回当前选定元素的数量。
DROPDOWN_SetSel(hItem,gn);//设置当前选定内容。
//DROPDOWN_SetSelExp(hItem,gn);//设置处于展开状态的附加 LISTBOX 的选定项
printf("gn1:%d gn1\r\n",gn);//打印
//printf("hItem2:%d hItem2\r\n",hItem);//打印
// RTC_Get();//更新时间
//
// sprintf((char*)buf0,"%02d:%02d:%02d",calendar.hour,calendar.min,calendar.sec);//时分秒
// TEXT_SetText(WM_GetDialogItem(hWin,ID_TEXT_11), buf0);
//
// sprintf((char*)buf1,"%02d/%02d/%02d",calendar.w_year,calendar.w_month,calendar.w_date);//年月日
// TEXT_SetText(WM_GetDialogItem(hWin,ID_TEXT_7), buf1);
// printf("w_year:%d \rs\n",calendar.w_year);//打印
hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0);
SPINBOX_SetFont(hItem, &GUI_FontHZ24);
SPINBOX_SetValue(hItem, rs);
SPINBOX_SetRange(hItem, 1, 8);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
TEXT_SetFont(hItem, &GUI_FontHZ24);
TEXT_SetText(hItem, "人数");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "日期:");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "星期:" );
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "定时:" );
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "流量计:");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
TEXT_SetText(hItem, "时间:");
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "温度:");
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7);
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetText(hItem, "T7");
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
TEXT_SetTextColor(hItem, 0x00FF0000);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetText(hItem, "T8");
TEXT_SetTextColor(hItem, 0x00FF0000);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_9);
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetText(hItem, "T9");
TEXT_SetTextColor(hItem, 0x00FF0000);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_10);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetTextColor(hItem, 0x00FF0000); //颜色
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_11);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetTextColor(hItem, 0x00FF0000);
//TEXT_SetText(hItem, "温度");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_12);
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetText(hItem, "3");
TEXT_SetTextColor(hItem, 0x00FF0000);
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
BUTTON_SetFont(hItem, &GUI_FontHZ16);
BUTTON_SetText(hItem, "开始");
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
BUTTON_SetFont(hItem, &GUI_FontHZ16);
BUTTON_SetText(hItem, "停止");
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
BUTTON_SetFont(hItem, &GUI_FontHZ16);
BUTTON_SetText(hItem, "取消");
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3);
BUTTON_SetFont(hItem, &GUI_FontHZ16);
BUTTON_SetText(hItem, "设置");
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_4);
BUTTON_SetFont(hItem, &GUI_FontHZ16);
BUTTON_SetText(hItem, "开/合");
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_5);
BUTTON_SetFont(hItem, GUI_FONT_16_ASCII);
BUTTON_SetText(hItem, "+");
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_6);
BUTTON_SetFont(hItem, GUI_FONT_16_ASCII);
BUTTON_SetText(hItem, "F");
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_7);
BUTTON_SetFont(hItem, GUI_FONT_16_ASCII);
BUTTON_SetText(hItem, "G");
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_8);
BUTTON_SetFont(hItem, GUI_FONT_16_ASCII);
BUTTON_SetText(hItem, "-");
break;
case WM_NOTIFY_PARENT://操作触发消息处理(操作屏幕程序会跑到这里),比如点击按键、点击编辑框(任何的操作)等等......
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id)
{
case ID_DROPDOWN_0: //
switch(NCode)
{
case WM_NOTIFICATION_CLICKED://已单击控件
break;
case WM_NOTIFICATION_RELEASED://已释放控件
break;
case WM_NOTIFICATION_SEL_CHANGED://下拉列表的选择已更改
hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);//返回对话框项目 (小工具)的窗口句柄
gn = DROPDOWN_GetSel(hItem);//返回当前选定元素的数量。
// printf("gn2:%d \r\n",gn);//打印
AT24CXX_WriteOneByte(SYSTEM_PARA_SAVE_BASE+4,gn);//指定地址写入一个字节
break;
}
break;
case ID_SPINBOX_0: //
switch(NCode)
{
case WM_NOTIFICATION_CLICKED://已单击控件
break;
case WM_NOTIFICATION_RELEASED://已释放控件
break;
case WM_NOTIFICATION_MOVED_OUT://已单击控件,并且指针已移出控件,但没有释放
break;
case WM_NOTIFICATION_VALUE_CHANGED://编辑控件的值 (内容)已更改
hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0);//返回对话框项目 (小工具)的窗口句柄
rs = SPINBOX_GetValue(hItem);//返回当前选定元素的数量。
AT24CXX_WriteOneByte(SYSTEM_PARA_SAVE_BASE+8,rs);//指定地址写入一个字节
switch(IAa)
{
case 1:
break;
case 2:
break;
case 3:
break;
}
break;
}
break;
case ID_BUTTON_0: //开始
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
//hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
//EDIT_SetFont(hItem, &GUI_FontHZ16);
//EDIT_SetText(hItem, "Hello world!");
break;
case WM_NOTIFICATION_RELEASED://按下放开后入到这里面
BEEP=!BEEP;
//kaiqie();//开始运行函数
kaiqie2();//开始运行函数//调试用
// printf("gn2:%d \r\n",gn);//打印
break;
}
break;
case ID_BUTTON_1: //停止
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
BEEP=0;
break;
}
break;
case ID_BUTTON_2: // 取消
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
BEEP=0;
All_STOP ();
break;
}
break;
case ID_BUTTON_3: //设置
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
CreateFramewin3(WM_HBKWIN);
break;
}
break;
case ID_BUTTON_4: // 开/合
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_5: // +
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_6: // F
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
if((tp_dev.touchtype&0X80)==0)TP_Adjust(); //电阻屏才需要校准
//system_task_return=0; //清除退出标志
break;
}
break;
case ID_BUTTON_7: //G
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_8: // -
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
WM_HWIN CreateWindow0(WM_HWIN hParent);
WM_HWIN CreateWindow0(WM_HWIN hParent)
{
WM_HWIN hWin;
//WM_HWIN hWia;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);//页面创建函数,返回该页面句柄
WM_CreateTimer(hWin, 0, 200, 0); //创建一个软件定时器
//WM_CreateTimer(WM_GetClientWindow(hWin),0,100,0);//添加此段
return hWin;
}
|
|