gui.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. #include "gui.h"
  2. #include "lcdDrv.h"
  3. #include "lsapi_fs.h"
  4. #include "log.h"
  5. #include "fonts.h"
  6. #include "board.h"
  7. #include "uiEntry.h"
  8. #include "app.h"
  9. #define COLOR_BACKGROUND COLOR_WHITE
  10. #define COLOR_FOREGROUND COLOR_BLUE
  11. unsigned int g_backColor;
  12. unsigned int g_foreColor;
  13. unsigned int guiGetBackColor(void){return g_backColor;}
  14. unsigned int guiGetForeColor(void){return g_foreColor;}
  15. static unsigned short RGB888_2_RGB565(unsigned int rgb888){
  16. unsigned short r,g,b,rgb565;
  17. b=(rgb888 >> (16+3))&0x1F;
  18. g=(rgb888 >> (8+2))&0x3f;
  19. r=(rgb888 >> (0+3))&0x1f;
  20. rgb565=((r<<11) + (g<<5) + (b<<0));
  21. return rgb565;
  22. }
  23. static void guiDrawDot(unsigned short colorData){
  24. LCD_DataWrite_ST7735(colorData >> 8);
  25. LCD_DataWrite_ST7735(colorData & 0xff);
  26. }
  27. static void guiBlockSet(unsigned short sx, unsigned short ex, unsigned short sy, unsigned short ey){
  28. LCD_CtrlWrite_ST7735(0x2a);
  29. guiDrawDot(sx);
  30. guiDrawDot(sy);
  31. LCD_CtrlWrite_ST7735(0x2B);
  32. guiDrawDot(ex);
  33. guiDrawDot(ey);
  34. LCD_CtrlWrite_ST7735(0x2C);
  35. }
  36. #define KEEP_HZK_OPENED //ê?·?±£3????t3£?a
  37. #define HZK_FENGQU 72*3*1024
  38. #define HZK_FENGQU_02 72*3*1024*2
  39. static int guiGetHzk(unsigned char hiByte, unsigned char loByte, unsigned char *pHzk, FONT_MODEENUM fontMode){
  40. unsigned char Q,W;
  41. unsigned int offset;
  42. const char hzk_16x16[]="HZK16";
  43. const char hzk_24x24_1[]="/ext/prepack/HZK24_1";
  44. const char hzk_24x24_2[]="/ext/prepack/HZK24_2";
  45. const char hzk_24x24_3[]="/ext/prepack/HZK24_3";
  46. char *hzk_ptr=NULL;
  47. static int fd_12=NULL,fd_16=NULL,fd_24_1=NULL,fd_24_2=NULL,fd_24_3=NULL;
  48. int *fd_ptr=NULL;
  49. int fsize;
  50. if(hiByte<0xa0 || loByte<0xa0) return -1;
  51. Q=hiByte-0xa0;
  52. W=loByte-0xa0;
  53. if(FONT_MODE_16X16==fontMode)fsize = 32;
  54. else if(FONT_MODE_24X24==fontMode)fsize=72;
  55. offset=(94 * (Q-1) + (W-1))* fsize;
  56. if(FONT_MODE_16X16==fontMode){
  57. hzk_ptr=(char *)hzk_16x16;
  58. fd_ptr=&fd_16;
  59. }else if(FONT_MODE_24X24==fontMode){
  60. if(offset<=HZK_FENGQU){
  61. hzk_ptr=(char *)hzk_24x24_1;
  62. fd_ptr=&fd_24_1;
  63. }else if(offset>HZK_FENGQU&&offset<HZK_FENGQU_02){
  64. offset-=HZK_FENGQU;
  65. hzk_ptr=(char *)hzk_24x24_2;
  66. fd_ptr=&fd_24_2;
  67. }else {
  68. offset-=HZK_FENGQU_02;
  69. hzk_ptr=(char *)hzk_24x24_3;
  70. fd_ptr=&fd_24_3;
  71. }
  72. }else return -2;
  73. if(*fd_ptr==NULL){
  74. int fd=LSAPI_FS_Open(hzk_ptr, LSAPI_FS_O_RDONLY, 0);
  75. if(fd==NULL){
  76. MSG_ERR(1, "%s open failed", hzk_ptr);
  77. return -3;
  78. }
  79. *fd_ptr=fd;
  80. }
  81. //?áè??úèY
  82. LSAPI_FS_Seek(*fd_ptr, offset, LSAPI_FS_SEEK_SET);
  83. offset=LSAPI_FS_Read(*fd_ptr, pHzk,fsize);
  84. #ifndef KEEP_HZK_OPENED
  85. LSAPI_FS_Close(*fd_ptr);
  86. *fd_ptr=NULL;
  87. #endif
  88. return offset;
  89. }
  90. static int fd_12_ext=NULL,fd_16_ext=NULL;
  91. static int extFileSize_1212=-1;
  92. static int extFileSize_1616=-1;
  93. bool fontExtLock=false;
  94. void extFontFileCtl(unsigned char fontType,bool ctl){
  95. int *fd_ext;
  96. if(ctl==true) fontExtLock=false;
  97. else{
  98. fontExtLock=true;
  99. if(fontType==12) fd_ext=&fd_12_ext;
  100. else if(fontType==16) fd_ext=&fd_16_ext;
  101. else{
  102. fontExtLock=false;
  103. return;
  104. }
  105. if(*fd_ext != NULL){
  106. LSAPI_FS_Close(*fd_ext);
  107. *fd_ext=NULL;
  108. }
  109. }
  110. }
  111. static int guiGetExtHzk(unsigned char hiByte, unsigned char loByte, unsigned char *pHzk, FONT_MODEENUM fontMode){
  112. unsigned char Q,W;
  113. int offset,i;
  114. char *hzk_ptr=NULL;
  115. int *fd_ptr=NULL;
  116. int *fsize,rsize;
  117. LSAPI_FS_Stat_info_t pBuf;
  118. unsigned char tmp[2+32];
  119. if(fontExtLock==true) return -1;
  120. if(FONT_MODE_16X16==fontMode){
  121. rsize = 24+2;
  122. hzk_ptr=HZK_12_NEW_FILE;
  123. fd_ptr=&fd_12_ext;
  124. fsize=&extFileSize_1212;
  125. }else if(FONT_MODE_16X16==fontMode){
  126. rsize = 32+2;
  127. hzk_ptr=HZK_16_NEW_FILE;
  128. fd_ptr=&fd_16_ext;
  129. fsize=&extFileSize_1616;
  130. }else return -2;
  131. //′ò?a???t
  132. if(*fd_ptr==NULL){
  133. int fd=LSAPI_FS_Open(hzk_ptr, LSAPI_FS_O_RDONLY, 0);
  134. if(fd==NULL){
  135. MSG_ERR(1, "%s open failed", hzk_ptr);
  136. return -3;
  137. }
  138. *fd_ptr=fd;
  139. }
  140. //get file size
  141. if(*fsize<1){
  142. memset(&pBuf,0,sizeof(pBuf));
  143. LSAPI_FS_Fstat(*fd_ptr,&pBuf);
  144. *fsize=pBuf.st_size;
  145. if(*fsize<0){
  146. offset=-4;
  147. goto F_END;
  148. }
  149. }
  150. LSAPI_FS_Seek(*fd_ptr, 0, LSAPI_FS_SEEK_SET);
  151. //check size
  152. if(1!=LSAPI_FS_Read(*fd_ptr, tmp,1)){
  153. offset=-5;
  154. goto F_END;
  155. }
  156. if(FONT_MODE_16X16==fontMode && tmp[0]!=12){
  157. offset=-6;
  158. goto F_END;
  159. }else if(FONT_MODE_16X16==fontMode && tmp[0]!=16){
  160. offset=-7;
  161. goto F_END;
  162. }
  163. for(;;){
  164. offset=LSAPI_FS_Read(*fd_ptr, tmp,rsize);
  165. if(offset != rsize){
  166. offset=-8;
  167. goto F_END;
  168. }
  169. if(tmp[0]==hiByte && tmp[1]==loByte){
  170. offset=rsize-2;
  171. memcpy(pHzk, tmp+2, offset);
  172. goto F_END;
  173. }
  174. }
  175. offset=-9;
  176. F_END:
  177. #ifndef KEEP_HZK_OPENED
  178. LSAPI_FS_Close(*fd_ptr);
  179. *fd_ptr=NULL;
  180. #endif
  181. return offset;
  182. }
  183. static void guiShowChars(unsigned short x,unsigned short y,unsigned char hiByte, unsigned char loByte,
  184. FONT_MODEENUM fontMode,
  185. unsigned int frontColorID,//????
  186. unsigned int backColorID,//????
  187. REV_ENUM rev){//??
  188. unsigned short i,j,k,m,n,fcolor,bcolor;
  189. unsigned short width,height;
  190. unsigned char ByteWidth,data;
  191. const unsigned char *l_pucFont,*l_pucLetter;
  192. unsigned char *p;
  193. unsigned char sucHzk16[32];
  194. //unsigned char sucHzk12[24];
  195. unsigned char sucHzk24[72];
  196. int ret;
  197. k = 0;
  198. if(hiByte==0){//english
  199. if(fontMode==FONT_MODE_16X16){//8* 12
  200. width=8;
  201. height = 16;
  202. ByteWidth = 1;
  203. l_pucFont = g_apucFonts16;
  204. l_pucLetter = g_apucLetter16;
  205. }else{ //8*16
  206. width=16;//8 hyl
  207. height = 24;
  208. ByteWidth = 2;
  209. l_pucFont = g_apucFonts24;
  210. l_pucLetter = g_apucLetter24;
  211. }
  212. while(*l_pucLetter){
  213. if(loByte == *l_pucLetter)break;
  214. l_pucLetter ++;
  215. k ++;
  216. }
  217. //2¨|?¨°|ì??á??a|ì??a¨o?????
  218. l_pucFont += k * ByteWidth * height;
  219. }else{//chinese
  220. if(fontMode==FONT_MODE_16X16){//12*16
  221. width=16;
  222. height = 16;
  223. ByteWidth = 2;
  224. l_pucFont = sucHzk16;
  225. l_pucLetter = 0;
  226. k=0;
  227. ret=guiGetHzk(hiByte,loByte,sucHzk16,fontMode);
  228. if(sizeof(sucHzk16)!=ret){//??¨?sFlash|ì?HZK16???t?D?¨¢¨¨??á??a¨oy?Y
  229. //?¨°2?|ì??á??a?ê???¨o?"?¨2"
  230. l_pucFont=g_apucCLetter16;
  231. MSG_ERR(1, "guiGetHzk16Err:%02x,%02x,%d",hiByte,loByte,ret);
  232. }
  233. }else{
  234. width=24;
  235. height = 24;
  236. ByteWidth = 3;
  237. l_pucFont = sucHzk24;
  238. l_pucLetter = 0;
  239. k=0;
  240. ret=guiGetHzk(hiByte,loByte,sucHzk24,fontMode);
  241. if(sizeof(sucHzk24)!=ret){//??¨?sFlash|ì?HZK16???t?D?¨¢¨¨??á??a¨oy?Y
  242. //?¨°2?|ì??á??a?ê???¨o?"?¨2"
  243. l_pucFont=g_apucCLetter16;
  244. MSG_ERR(1, "guiGetHzk24Err:%02x,%02x,%d",hiByte,loByte,ret);
  245. }
  246. }
  247. }
  248. //====================?¨′??|¨¤¨a|ì??¨?¨oy?Y==========
  249. if(y+height>GLCD_HEIGHT)return;
  250. if(x+width>GLCD_WIDTH)return;
  251. guiBlockSet(x,y,x+width-1,y+height-1);//
  252. fcolor=RGB888_2_RGB565(frontColorID);
  253. bcolor=RGB888_2_RGB565(backColorID);
  254. //¨°?????à?¨???|ì??¨???é|ì?LCD?ê?2?¨?????????ê¨??¨?¨22a¨o??ê??á?騰a|ì??¨??2?¨°a|ì??¨??PaintBufToLcd?ê??¤??¨°¨°2??é?¨¢¨¢?
  255. //?¨′?Y?á???ê?¨2??????D?-|ì?
  256. for(j=0;j<height;j++){
  257. m=y+j;
  258. for(i=0;i<ByteWidth;i++){
  259. n=x+i*8;
  260. data=*l_pucFont++;
  261. for(k=0;k<8;k++){
  262. if(data & (0x80>>k)){//??,??frontColorID
  263. if(REVERSED_NO==rev) guiDrawDot(fcolor);
  264. else guiDrawDot(bcolor);
  265. }else{//??,??backColorID
  266. if(REVERSED_NO==rev) guiDrawDot(bcolor);
  267. else guiDrawDot(fcolor);
  268. }
  269. }
  270. }
  271. }
  272. }
  273. short guiGetStrXLen(char *str, FONT_MODEENUM fontMode){
  274. unsigned char ch;
  275. unsigned short len=0;
  276. unsigned char bsize;
  277. bsize=12;
  278. while ((ch=*str++)){
  279. if(ch=='M')len+=16;
  280. else if(ch>='A'&&ch<='Z')len+=16;
  281. else if(ch>='a'&&ch<='z')len+=16;
  282. else if(ch>='0'&&ch<='9')len+=16;
  283. else if(ch>=0x20&& ch<=0x60)len+=16; //¨??¨oa?á??¤?
  284. else len+=bsize;
  285. }
  286. return len;
  287. }
  288. //ò????ó?ú??ía?a·?
  289. void guiShowStr(unsigned short x, unsigned short y,const char *string, FONT_MODEENUM fontMode,
  290. REV_ENUM rev, //????
  291. unsigned int frontColorID,//???
  292. unsigned int backColorID){//???
  293. unsigned char width1,width2,heigh;
  294. unsigned char *p;
  295. unsigned short i;
  296. fontMode=FONT_MODE_24X24;
  297. if(fontMode == FONT_MODE_16X16){
  298. width1 = 16;
  299. width2 = 1;
  300. heigh=16;
  301. }else if(fontMode == FONT_MODE_24X24){
  302. width1 = 24;
  303. width2 = 2;//1
  304. heigh=24;
  305. } else return;
  306. p = (unsigned char *)string;
  307. i = 0;
  308. while(*p){
  309. if (*p > 0x80){//chinese letter
  310. guiShowChars(x+i,y,*p, *(p+1),fontMode,frontColorID,backColorID,rev);
  311. i += width1 ;
  312. p += 2;
  313. }else{//english letter
  314. guiShowChars(x + i,y,0,*p,fontMode,frontColorID,backColorID,rev);
  315. if(fontMode==0) i += width2 * 8;
  316. else i += width2 * 8;
  317. p ++;
  318. }
  319. }
  320. }
  321. void guiShowButton(unsigned short x, unsigned short y,const char *str, FONT_MODEENUM fontMode,unsigned int buttonColorID, unsigned int strColorID){
  322. int heigh,len;
  323. if(FONT_MODE_16X16==fontMode) heigh=12+4;
  324. else if(FONT_MODE_24X24==fontMode) heigh=16+4;
  325. else return;
  326. len=guiGetStrXLen((char *)str, fontMode);
  327. guiFillRect(x,y,x+len+8,y+heigh,buttonColorID);
  328. guiShowStr(x+4, y+1, str, fontMode,REVERSED_NO,strColorID,buttonColorID);
  329. }
  330. void guiFillRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2,unsigned int colorData){
  331. unsigned short x=x2,y=y2,w,h,i,m,k,j,data;
  332. if(x1>x2 || y1>y2) return;
  333. if(x1>=GLCD_WIDTH || y1>=GLCD_HEIGHT) return;
  334. if(x>GLCD_WIDTH) x=GLCD_WIDTH;
  335. if(y>GLCD_HEIGHT) y=GLCD_HEIGHT;
  336. w=x-x1+1;
  337. h=y-y1+1;
  338. data=RGB888_2_RGB565(colorData);
  339. guiBlockSet(x1,y1,x,y);
  340. for(i=0;i<h;i++){
  341. m=y1+i;
  342. for(j=0;j<w;j++){
  343. k=x1+j;
  344. guiDrawDot(data);
  345. }
  346. }
  347. }
  348. void guiClearRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned int colorData){
  349. guiFillRect(x1,y1,x2,y2,colorData);
  350. }
  351. //??????
  352. void guiDrawHLine(unsigned short x1, unsigned short x2, unsigned short y, unsigned short ysize, unsigned int colorID){
  353. if(ysize==0) return;
  354. if(x2<x1) return;
  355. guiFillRect(x1,y,x2,y+ysize-1,colorID);
  356. }
  357. //′1?±??
  358. void guiDrawVLine(unsigned short y1, unsigned short y2, unsigned short x, unsigned short xsize, unsigned int colorID){
  359. if(xsize==0) return;
  360. if(y2<y1) return;
  361. guiFillRect(x,y1,x+xsize-1,y2,colorID);
  362. }
  363. void guiDrawRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2,unsigned char width, unsigned int colorID){
  364. if(x1>x2||y1>y2) return;
  365. guiDrawHLine(x1,x2,y1,width,colorID);
  366. guiDrawHLine(x1,x2,y2,width,colorID);
  367. guiDrawVLine(y1,y2,x1,width,colorID);
  368. guiDrawVLine(y1,y2+width-1,x2,width,colorID);
  369. }
  370. //óé·??ò?aμ?(x,y)?aê??-
  371. void guiDrawArrow(unsigned short x, unsigned short y,unsigned short len, ARROW_ENUM direction, unsigned int colorID){
  372. unsigned short i;
  373. switch(direction){
  374. case ARROW_LEFT:
  375. for(i=0;i<len;i++) guiDrawRect(x+i,y-i,x+i,y+i,1,colorID);
  376. break;
  377. case ARROW_RIGHT:
  378. for(i=0;i<len;i++) guiDrawRect(x-i,y-i,x-i,y+i,1,colorID);
  379. break;
  380. case ARROW_UP:
  381. for(i=0;i<len;i++) guiDrawRect(x-i,y+i,x+i,y+i,1,colorID);
  382. break;
  383. case ARROW_DOWN:
  384. for(i=0;i<len;i++) guiDrawRect(x-i,y-i,x+i,y-i,1,colorID);
  385. break;
  386. }
  387. }
  388. static void guiFillBmpBuf(unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char *bmpBuf){
  389. int i,j,k,t;
  390. unsigned short RGB565,r,g,b;
  391. unsigned char R,G,B;
  392. for(j=0;j<height;j++){
  393. t=y+j;
  394. k=j*width;
  395. for(i=0;i<width;i++){
  396. R=bmpBuf[3*i];
  397. G=bmpBuf[3*i+1];
  398. B=bmpBuf[3*i+2];
  399. r=R>>3;
  400. g=G>>2;
  401. b=B>>3;
  402. RGB565=((r<<11)+(g<<5)+(b<<0));
  403. guiDrawDot(RGB565);
  404. }
  405. }
  406. }
  407. void guiShowBmp(unsigned short x, unsigned short y, char *bmp){
  408. int fd,l,w,i;
  409. unsigned short type;
  410. unsigned int width,height,bfOffBits;
  411. unsigned char tbuf[GLCD_WIDTH*4];
  412. fd=LSAPI_FS_Open(bmp, LSAPI_FS_O_RDONLY,0);
  413. if(fd<0){
  414. MSG_ERR(1, "%s open failed", bmp);
  415. return;
  416. }
  417. //?áè????tààDí
  418. LSAPI_FS_Seek(fd, 0x1c, LSAPI_FS_SEEK_SET);
  419. LSAPI_FS_Read(fd, (unsigned char *)&type, 2);
  420. if(type != 0x0018){
  421. MSG_ERR(1, "%s is not 24bits bmp",bmp);
  422. LSAPI_FS_Close(fd);
  423. return;
  424. }
  425. //?áè?í????í?è
  426. LSAPI_FS_Seek(fd, 0x12, LSAPI_FS_SEEK_SET);
  427. LSAPI_FS_Read(fd, (unsigned char *)&width, 4);
  428. //?áè?í??????è
  429. LSAPI_FS_Seek(fd, 0x16, LSAPI_FS_SEEK_SET);
  430. LSAPI_FS_Read(fd, (unsigned char *)&height, 4);
  431. //?D??3?′?
  432. if(width>GLCD_WIDTH || height>GLCD_HEIGHT){
  433. MSG_ERR(1, "%s size overflow",bmp);
  434. LSAPI_FS_Close(fd);
  435. return;
  436. }
  437. //?á3?êy?Y?eê?μ??·
  438. LSAPI_FS_Seek(fd, 0x0a, LSAPI_FS_SEEK_SET);
  439. LSAPI_FS_Read(fd, (unsigned char *)&bfOffBits, 4);
  440. l=width%4;
  441. w=width*3+l;
  442. l=height-1;
  443. guiBlockSet(x,y,x+width-1,y+height-1);//-1
  444. for(i=0;i<height;i++){
  445. LSAPI_FS_Seek(fd, bfOffBits+l*w, LSAPI_FS_SEEK_SET);
  446. LSAPI_FS_Read(fd, tbuf, w);
  447. guiFillBmpBuf(x,y+i,width,1,tbuf);
  448. l--;
  449. }
  450. LSAPI_FS_Close(fd);
  451. }
  452. /*?ó?D??ê?*/
  453. void guiShowCaption(unsigned short xType, const char *str, unsigned short y, unsigned int frontColorID, unsigned int backColorID, FONT_MODEENUM fontMode){
  454. int len,sy;
  455. unsigned short x;
  456. len=guiGetStrXLen((char *)str,fontMode);
  457. if(xType==0) x=(GLCD_WIDTH-len)/2;
  458. else x=xType;
  459. guiShowStr(x, y, str, fontMode, REVERSED_NO, frontColorID, backColorID);
  460. }
  461. void guiClearArea(unsigned short x, unsigned short y, unsigned short width, unsigned short height,unsigned int colorID){
  462. guiFillRect(x,y,x+width,y+height,colorID);
  463. }
  464. void guiInit(void){
  465. g_backColor=COLOR_BACKGROUND;
  466. g_foreColor=COLOR_FOREGROUND;
  467. guiFillRect(0,0,GLCD_WIDTH-1,GLCD_HEIGHT-1,guiGetBackColor());
  468. // SetMessageConfi();
  469. if(sutApp.UserInfo.tnet==5) guiShowBmp(0,0,"/ext/prepack/welcome5.bmp");//开机图片
  470. else guiShowBmp(0,0,"/ext/prepack/welcome.bmp");//开机图片
  471. lcdBackLightApi(1);//清屏后打开,否则会看到关机前的画面
  472. }
  473. void guiClearAll(unsigned int colorID){//只清第二,三区
  474. guiFillRect(0, UI_STATUS_ITEM_Y, GLCD_WIDTH-1, UI_CONTENT_SHOW_Y-1, guiGetForeColor());//清除第二区
  475. guiFillRect(0,UI_CONTENT_SHOW_Y,GLCD_WIDTH-1,UI_LOCATION_SHOW_Y-1,colorID);
  476. }
  477. void guiShowMessageBox(char *msg){
  478. char buf[70];
  479. short len,x,y;
  480. y=GLCD_HEIGHT/2;
  481. guiClearRect(0,y-20,GLCD_WIDTH-1,y+20,guiGetBackColor());
  482. guiDrawRect(2,y-18,GLCD_WIDTH-3,y+18,1,COLOR_BLACK);
  483. StrIntercept(buf,msg,18);
  484. len=guiGetStrXLen(buf,FONT_MODE_16X16);
  485. x=(GLCD_WIDTH-len)/2;
  486. guiShowStr(x,y-8,buf,FONT_MODE_16X16,REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  487. }
  488. //////////////////////////////////////测试接口///////////////////////////////////
  489. void guiTest(void){
  490. //return;
  491. //char testbuf[5]={0xB2,0xE2,0xCA,0xD4,0x00};
  492. //??ê?DD??
  493. guiDrawHLine(1, GLCD_WIDTH-2, 1, 1, guiGetForeColor());
  494. //??ê?áD??
  495. guiDrawVLine(3, GLCD_HEIGHT-2, 1, 1, guiGetForeColor());
  496. //??ê???D???D?
  497. guiDrawRect(3,3,3+10,3+10,1,guiGetForeColor());
  498. //??ê?êμD???D?
  499. guiFillRect(15, 3, 15+10, 3+10,guiGetForeColor());
  500. //??ê??yí·
  501. guiDrawArrow(50, 3,10, ARROW_UP, guiGetForeColor());
  502. guiDrawArrow(70, 3+10,10, ARROW_DOWN, guiGetForeColor());
  503. guiDrawArrow(90, 3+8,10, ARROW_LEFT, guiGetForeColor());
  504. guiDrawArrow(110, 3+8,10, ARROW_RIGHT, guiGetForeColor());
  505. //??ê?12X12×?·?′?
  506. guiShowStr(3, 30,"123测试45中,国AW", FONT_MODE_16X16, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
  507. //??ê?16X16×?·?′?
  508. guiShowStr(3, 50,"123测试45你。好AW", FONT_MODE_16X16, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
  509. //??ê?í???
  510. guiShowBmp(3, 80, "Palace2.bmp");
  511. //??ê?°′?ü
  512. guiShowButton(100, 80,"B12", FONT_MODE_16X16,guiGetForeColor(), guiGetBackColor());
  513. }