?? main.c
字號:
#include "main.h"
#include "GUI.H"
#include "DIALOG.H"
#include "WM.h"
#include "button.h"
#include "progbar.h"
//系統時間
extern U32 OS_TimeMS ;
//bmp
extern const GUI_BITMAP bmdesktop;
extern const GUI_BITMAP bmugifile;
extern const GUI_BITMAP bmsscom;
//windows
WM_HWIN hWin2;
//定義全局變量 按鈕
BUTTON_Handle hButton[6];
//定義全局變量 文本框
//TimeTick用到外部開中斷函數
extern void EnableInt (void);
/********************************************************************************************************
** 函數功能 : 中斷服務函數 //適應gui對時間的要求,OS_TimeMS每1MS加1。
** 入口參數 :
** 出口參數 :
*********************************************************************************************************/
void __irq Rtc_Tick(void)
{
rI_ISPC=BIT_TICK;
OS_TimeMS+=15;
// uartprintf("\n\r\n\r TimeTick ");
}
/********************************************************************************************************
** 函數功能 :TimeTick 中斷初始化程序;
** 入口參數
** 出口參數 :無
*********************************************************************************************************/
void TickInit ( void )
{
rTICNT = 0x80+1; //enable tick timer interrupt, set tick timer interrupt time = (1+1)/128 second
//INT con
rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; //All=IRQ mode
pISR_TICK=(unsigned)Rtc_Tick;
rINTMSK=~(BIT_GLOBAL|BIT_TICK);
EnableInt();
}
/********************************************************************************************************
** 函數功能 :長軟件延時
** 入口參數 :dly 延時參數,值越大,延時越久
** 出口參數 :無
*********************************************************************************************************/
void DelayNS (U32 dly)
{
U32 i;
for ( ; dly>0; dly--)
for (i=0; i<10000; i++);
}
/********************************************************************************************************
** 函數功能 :從串口獲得建值函數
** 入口參數 :
** 出口參數 :無
*********************************************************************************************************/
U8 GetKey(void)
{
U8 value;
// printf("\n\r\n\r\n\r Please Input The Key value 1-5");
value = getch();
// printf("\n\r\n\r You Press ");
putch(value);
return (value);
}
/********************************************************************************************************
** 函數功能 :等待事件處理函數
** 入口參數 :
** 出口參數 :無
*********************************************************************************************************/
void SuperLoop(void)
{
U8 KeyValue=0;
KeyValue = GetKey();
switch(KeyValue)
{
case '1':
//指示按鍵狀態
BUTTON_SetState(hButton[1],BUTTON_STATE_PRESSED);
WM_Exec();
//其他事件處理
//恢復按鈕狀態
DelayNS(800);
BUTTON_SetState(hButton[1],BUTTON_STATE_INACTIVE);
WM_Exec();
break;
case '2':
//指示按鍵狀態
BUTTON_SetState(hButton[2],BUTTON_STATE_PRESSED);
WM_Exec();
//其他事件處理
//恢復按鈕狀態
DelayNS(800);
BUTTON_SetState(hButton[2],BUTTON_STATE_INACTIVE);
WM_Exec();
break;
case '3':
//指示按鍵狀態
BUTTON_SetState(hButton[3],BUTTON_STATE_PRESSED);
WM_Exec();
//其他事件處理
//恢復按鈕狀態
DelayNS(800);
BUTTON_SetState(hButton[3],BUTTON_STATE_INACTIVE);
WM_Exec();
break;
case '4':
//指示按鍵狀態
BUTTON_SetState(hButton[4],BUTTON_STATE_PRESSED);
WM_Exec();
//其他事件處理
//恢復按鈕狀態
DelayNS(800);
BUTTON_SetState(hButton[4],BUTTON_STATE_INACTIVE);
WM_Exec();
break;
case '5':
//指示按鍵狀態
BUTTON_SetState(hButton[5],BUTTON_STATE_PRESSED);
WM_Exec();
//其他事件處理
//恢復按鈕狀態
DelayNS(800);
BUTTON_SetState(hButton[5],BUTTON_STATE_INACTIVE);
WM_Exec();
break;
default:
break;
}
}
/********************************************************************************************************
** 函數功能 :創建按鈕函數
** 入口參數 :無
** 出口參數 :無
*********************************************************************************************************/
static void DemoButton(void)
{
char *ButtonText[6]={ "",
"1 Menu",
"2 Up",
"3 Down",
"4 Esc",
"5 Enter",
};
int Key = 0;
int i;
//建立按鈕
for(i=1; i<6;i++)
{
hButton[i] = BUTTON_Create(20 + (i-1)*60,210,45,25,GUI_ID_OK,WM_CF_SHOW);
//設置按鈕屬性
BUTTON_SetBkColor(hButton[i],0,GUI_BLUE);
BUTTON_SetBkColor(hButton[i],1,GUI_RED);
BUTTON_SetTextColor(hButton[i],0,GUI_WHITE);
BUTTON_SetTextColor(hButton[i],1,GUI_BLACK);
BUTTON_SetText(hButton[i],ButtonText[i]);
WM_Exec();
}
}
/********************************************************************************************************
** 函數功能 :創建文本框函數
** 入口參數 :無
** 出口參數 :無
*********************************************************************************************************/
static void DemoEdit(void)
{
EDIT_Handle hEdit1;
char aBuffer[28];
int Key;
//建立文本框
hEdit1 = EDIT_Create( 50, 110, 220, 25, ' ', sizeof(aBuffer), 0 );
//修改文本框屬性
EDIT_SetFont(hEdit1, &GUI_Font8x16);
EDIT_SetText(hEdit1, "Press <ENTER> when done...");
EDIT_SetTextColor(hEdit1, 0, GUI_RED);
WM_Exec();
//設置焦點到文本框
WM_SetFocus(hEdit1);
/* Handle keyboard until ESC or ENTER is pressed */
do
{
Key = GUI_WaitKey();
WM_Exec();
switch(Key)
{
case GUI_ID_ESCAPE:
case GUI_ID_CANCEL:
break;
default:
EDIT_AddKey(hEdit1,Key);
}
WM_Exec();
} while ( (Key != GUI_ID_ESCAPE ) && ( Key != GUI_ID_ENTER ) && ( Key !=0) );
EDIT_GetText(hEdit1,aBuffer,sizeof(aBuffer));
GUI_DispStringAt(aBuffer,10,180);
WM_Exec();
}
/********************************************************************************************************
** 函數功能 :main
** 入口參數 :無
** 出口參數 :無
*********************************************************************************************************/
int main( )
{
U32 cnt=1020;
U32 i;
// U32 data32 = 0x11de;
// float f1= 4.723,f2 =3.1415926;
ChangePllValue(88, 6, 1);
PortInit();
console_init(115200);
printf("n\r\n\r System start!");
TickInit();
GUI_Init();
GUI_Clear();
GUI_SetFont(&GUI_Font8x9);
GUI_SetFont(&GUI_Font_HZK16); //問題:使用該字庫可以顯示但是位置有偏移
GUI_SetColor(GUI_YELLOW);
GUI_GotoXY(0,0);
GUI_DispStringAt("博 易 網 絡 科 技",110,10);
GUI_SetFont(&GUI_Font8x9);
DemoButton();
DemoEdit();
while(1)
{
//檢測事件并處理
SuperLoop();
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -