⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui_task.c

📁 基于S3C44B0的嵌入式系统设计与开发实例详解的部分源代码
💻 C
字号:
/***********************************************************************************************************                                                uC/GUI*                        Universal graphic software for embedded applications**                       (c) Copyright 2002, Micrium Inc., Weston, FL*                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH**              礐/GUI is protected by international copyright laws. Knowledge of the*              source code may not be used to write a similar product. This file may*              only be used in accordance with a license and should not be redistributed*              in any way. We appreciate your understanding and fairness.*----------------------------------------------------------------------File        : GUIDEMO_TouchPurpose     : Touch demo---------------------------END-OF-HEADER------------------------------*/#include	"..\ucos-ii\includes.h"  #include   "..\gui\core\GUI.h"#include   "..\gui\core\LCD_ConfDefaults.h"      /* valid LCD configuration */#include   "..\guiapp\GUIDEMO.h"#include   "..\gui\widget\Button.h"#include   "..\gui\widget\Edit.h"#include   "..\gui\widget\Progbar.h"#include   "..\fat16\fat16.h"//#if (GUI_WINSUPPORT && GUI_SUPPORT_TOUCH)#define countof(Obj) (sizeof(Obj)/sizeof(Obj[0]))#define SEND_ID   0x80#define CAPS_ID   0x81#define SAVE_ID   0x82#define L1_ID     0x83#define L2_ID     0x84#define L3_ID     0x85#define CLEAR_ID  0x86#define NULL   0extern  OS_EVENT    *TCPTaskMbox;extern  OS_EVENT    *GUITaskMbox;extern  int FileNum;/***********************************************************************       _ExecKeyboard***********************************************************************This creates a sample keyboard.The routine returns after ENTER or ESC has been pressed.*///#if (LCD_XSIZE == 320) && (LCD_YSIZE == 240)static char _acText[] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '='                          , 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'                          , 2, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';'						  ,' ','Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/'						  ,' ', ' ',' ', ' ', ' ', ' ', ' ', ' '};void GUI_Task(void) {  int i,x;  int Key;  unsigned char capsflg=0, rcvflg=0;  char *txmsg="";  int *rxmsg;  char *msg,*text="";      BUTTON_Handle ahButton[52];  BUTTON_Handle hButtonESC;  BUTTON_Handle hButtonSend;  BUTTON_Handle hButtonSave;  EDIT_Handle   hEdit;  PROGBAR_Handle hProgBar;      GUI_RECT rText = {5,0, 320, 20};    GUI_SetBkColor(GUI_BLUE);    GUI_Clear();//  GUI_DrawBitmap(&bmMicriumLogoWRed, 5, 5);   //GUI_SetFont(&GUI_FontHZ12);  GUI_SetFont(&GUI_FontComic24B_ASCII);  GUI_SetColor(GUI_WHITE);  GUI_DispStringInRect("PDA test", &rText, GUI_TA_LEFT | GUI_TA_VCENTER);  rText.y0 +=20;  rText.y1 +=20;  //GUI_DispStringInRect("Touch screen demo", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER);  /* Create Keyboard Buttons */  for (i=0; i< 47; i++) {    int Pos = (i < 47) ? i : i+4;    int x0 = 5  + 28*(Pos%11);    int y0 = 100 + 28*(Pos/11);    char c = _acText[i];    int Id = c ? c : 1;    char ac[2] = {0};    char *s= ac;    ac[0] = c;    if(i==10)    {            ahButton[i] = BUTTON_Create( x0, y0, 25, 25, GUI_ID_BACKSPACE,BUTTON_CF_SHOW );            BUTTON_SetText   (ahButton[i], "Bsp");    }    else if(i==11)    {            ahButton[i] = BUTTON_Create( x0, y0, 25, 25, GUI_ID_SHIFT,BUTTON_CF_SHOW );            BUTTON_SetText   (ahButton[i], "Sft");    }    else if(i==22)    {            ahButton[i] = BUTTON_Create( x0, y0, 25, 25, CAPS_ID,BUTTON_CF_SHOW );            BUTTON_SetText   (ahButton[i], "Cap");    }     else if(i==33)    {            ahButton[i] = BUTTON_Create( x0, y0, 25, 25, GUI_ID_CONTROL,BUTTON_CF_SHOW );            BUTTON_SetText   (ahButton[i], "Ctr");    }    else if(i==44)    {            ahButton[i] = BUTTON_Create( x0, y0, 25, 25, L1_ID,BUTTON_CF_SHOW );            BUTTON_SetText   (ahButton[i], "L1");    }    else if(i==45)    {            ahButton[i] = BUTTON_Create( x0, y0, 25, 25, L2_ID,BUTTON_CF_SHOW );            BUTTON_SetText   (ahButton[i], "L2");    }    else if(i==46)    {            ahButton[i] = BUTTON_Create( x0, y0, 25, 25, L3_ID,BUTTON_CF_SHOW );            BUTTON_SetText   (ahButton[i], "L3");    }    else    {            ahButton[i] = BUTTON_Create( x0, y0, 25, 25, Id,BUTTON_CF_SHOW );            BUTTON_SetText   (ahButton[i], s);    }    #if GUI_SUPPORT_MEMDEV      BUTTON_EnableMemdev(ahButton[i]);    #endif  }       ahButton[i] = BUTTON_Create( 89, 212, 109, 25, ' ',BUTTON_CF_SHOW );    hButtonESC = BUTTON_Create( 220, 70, 80, 25, CLEAR_ID,BUTTON_CF_SHOW );  BUTTON_SetText   (hButtonESC, "Clear");    hButtonSave = BUTTON_Create( 130, 70, 80, 25, SAVE_ID,BUTTON_CF_SHOW );  BUTTON_SetText   (hButtonSave, "Save");    hButtonSend = BUTTON_Create( 40, 70, 80, 25, SEND_ID,BUTTON_CF_SHOW );  BUTTON_SetText   (hButtonSend, "Send");    hEdit = EDIT_Create( 5, 40, 310, 25, ' ', 80, 0 );  EDIT_SetFont(hEdit, &GUI_Font8x16);//  BUTTON_SetBkColor(ahButton[49], 0, GUI_RED);//  BUTTON_SetBkColor(ahButton[50], 0, GUI_BLUE);      /* Handle Keyboard until ESC or ENTER is pressed */  do {       	//GUI_Delay (100);       	 rxmsg=(int *)OSMboxAccept(GUITaskMbox);             if(rxmsg!=NULL)            {    	           GUI_SetFont(&GUI_Font8x16);               GUI_SetColor(GUI_WHITE);	            switch(*rxmsg)			    {			    	case 0: 			    	GUI_SetColor(GUI_WHITE);					GUI_ClearRect(105,20, 320, 40);			            GUI_DispStringInRect("Ethernet Error!", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER);         			            break;			        case 1:                        //PROGBAR_SetValue(hProgBar, 100);						GUI_ClearRect(105,20, 320, 40);			            GUI_DispStringInRect("Send Failed!", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER);         						//GUIDEMO_Delay(1000);                        PROGBAR_Delete(hProgBar);                            GUI_ClearRect(205,215,305,235);   			            break;			        case 2:						//PROGBAR_SetValue(hProgBar, 100);						GUI_ClearRect(105,20, 320, 40);			            GUI_DispStringInRect("Send Successfully!", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER);         						PROGBAR_Delete(hProgBar);                            GUI_ClearRect(205,215,305,235);  			            break;			        default:						GUI_ClearRect(105,20, 320, 40);			            BUTTON_SetText(hButtonSend, "Receive");			            rcvflg=1;			            GUI_DispStringInRect("Received a message!", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER);         			            break;			    }			}        Key = GUIDEMO_WaitKey();        switch (Key) {                case CAPS_ID://大小写转换                  if(capsflg==0)                    capsflg=1;                  else                    capsflg=0;                  break;             case SEND_ID:                  if(rcvflg==0)                  {                     EDIT_GetText(hEdit,txmsg,80);		             OSMboxPost(TCPTaskMbox, (void *)&txmsg);		             		             GUI_SetFont(&GUI_Font8x16);		             GUI_DispStringInRect("Begin to send a message!", &rText, GUI_TA_RIGHT | GUI_TA_VCENTER);					 //OSTimeDly(1000000);					 hProgBar = PROGBAR_Create( 205,                                   215,                                   100,                                    20,                                    WM_CF_SHOW );         PROGBAR_SetFont(hProgBar, &GUI_Font8x16);                                            PROGBAR_SetBarColor(hProgBar, 0, GUI_GREEN);         PROGBAR_SetBarColor(hProgBar, 1, GUI_WHITE);           for (i=0; (i <=99)&& !GUIDEMO_CheckCancel(); i++) {           PROGBAR_SetValue(hProgBar, i);           GUI_Delay(5);         }                          	           	  } 		          else		          {                     msg=*rxmsg;					 EDIT_SetText(hEdit,msg);		 	         BUTTON_SetText(hButtonSend, "Send");                     rcvflg=0;					 GUI_ClearRect(105,20, 320, 40);                   }		                      break;			    case SAVE_ID:					 EDIT_GetText(hEdit,text,80);					 if(FileNum==1){					 	x=fat_open("\\code\\L1.txt");						FileNum=2;					 	}					 else if (FileNum==2){					 	x=fat_open("\\code\\L2.txt");						FileNum=3;					 	}                     else if (FileNum==3){					 	x=fat_open("\\code\\L3.txt");						FileNum=1;                     	}					 fat_write(x, text, 80);					 fat_close(x);				         break;			    case L1_ID:					 x=fat_open("\\code\\L1.txt");					 fat_read(x, text, 80);					 fat_close(x);					 EDIT_SetText(hEdit,text);			         break;			    case L2_ID:					 x=fat_open("\\code\\L2.txt");					 fat_read(x, text, 80);					 fat_close(x);					 EDIT_SetText(hEdit,text);			         break;			    case L3_ID:					x=fat_open("\\code\\L3.txt");					 fat_read(x, text, 80);					 fat_close(x);					 EDIT_SetText(hEdit,text);			         break;			    case CLEAR_ID:			         EDIT_SetText(hEdit,"");			         break;			    default:			         if(capsflg==1)			         {			         	if((Key>=0x41)&&(Key<=0x5A))			         	   Key+=0x20;			         }			            EDIT_AddKey(hEdit, Key);			         break;			 }           	   } while(1); //((Key != 'N') && (Key!=GUI_ID_CANCEL) && (Key!=0));	  /* Cleanup 	  for (i=0; i< countof(ahButton); i++) {	    BUTTON_Delete(ahButton[i]);	  }	  BUTTON_Delete(hButtonESC);	  EDIT_Delete(hEdit);	  return Key;*/}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -