gui(5461).c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  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 char g_aucLcdBufF[GLCD_HEIGHT/8][GLCD_WIDTH];
  12. unsigned int g_backColor;
  13. unsigned int g_foreColor;
  14. unsigned int guiGetBackColor(void){return g_backColor;}
  15. unsigned int guiGetForeColor(void){return g_foreColor;}
  16. void LcdSetAddr(unsigned char x, unsigned char Page)
  17. {
  18. LCD_CtrlWrite_ST7735(0xB0+Page);
  19. LCD_CtrlWrite_ST7735(0x10+((x>>4)&0x0f));
  20. LCD_CtrlWrite_ST7735(x&0x0f);
  21. }
  22. void LCDFlashPain(void){
  23. unsigned char i,j;
  24. for(i=0;i<GLCD_HEIGHT/8;i++){
  25. for(j=0;j<GLCD_WIDTH;j++){
  26. LcdSetAddr(j,i);//coum,page
  27. LCD_DataWrite_ST7735(g_aucLcdBufF[i][j]);
  28. }
  29. }
  30. }
  31. void newGuiClearBar(void){
  32. newGuiClearPage(0, ROW_ONE);
  33. DrawLineV(0,8,GLCD_WIDTH);
  34. }
  35. void newGuiClearPage(unsigned char x,ROW_ENUM row){
  36. int i,j;
  37. if(row>ROW_FOUR) return;
  38. j=2*row;
  39. for(i=x;i<GLCD_WIDTH;i++){
  40. g_aucLcdBufF[j][i]=0;
  41. g_aucLcdBufF[j+1][i]=0;
  42. }
  43. }
  44. void newGuiClearMainPage(void){
  45. newGuiClearPage(0, ROW_TWO);
  46. newGuiClearPage(0, ROW_THREE);
  47. newGuiClearPage(0, ROW_FOUR);
  48. }
  49. void LCDFlashPainPage(unsigned char x ,unsigned char y){
  50. unsigned char i,j;
  51. for(i=y/8;i<GLCD_HEIGHT/8;i++){
  52. for(j=x;j<GLCD_WIDTH;j++){
  53. LcdSetAddr(j,i);//coum,page
  54. LCD_DataWrite_ST7735(g_aucLcdBufF[i][j]);
  55. }
  56. }
  57. }
  58. void LcdStatusBarFlash(void){
  59. unsigned char i,j;
  60. for(i=0;i<2;i++){
  61. for(j=0;j<GLCD_WIDTH;j++){
  62. LcdSetAddr(j,i);//coum,page
  63. LCD_DataWrite_ST7735(g_aucLcdBufF[i][j]);
  64. }
  65. }
  66. }
  67. static unsigned short RGB888_2_RGB565(unsigned int rgb888){
  68. unsigned short r,g,b,rgb565;
  69. b=(rgb888 >> (16+3))&0x1F;
  70. g=(rgb888 >> (8+2))&0x3f;
  71. r=(rgb888 >> (0+3))&0x1f;
  72. rgb565=((r<<11) + (g<<5) + (b<<0));
  73. return rgb565;
  74. }
  75. static void guiDrawDot(unsigned short colorData){
  76. LCD_DataWrite_ST7735(colorData >> 8);
  77. LCD_DataWrite_ST7735(colorData & 0xff);
  78. }
  79. static void guiBlockSet(unsigned short sx, unsigned short ex, unsigned short sy, unsigned short ey){
  80. LCD_CtrlWrite_ST7735(0x2a);
  81. guiDrawDot(sx);
  82. guiDrawDot(sy);
  83. LCD_CtrlWrite_ST7735(0x2B);
  84. guiDrawDot(ex);
  85. guiDrawDot(ey);
  86. LCD_CtrlWrite_ST7735(0x2C);
  87. }
  88. #define KEEP_HZK_OPENED //ê?·?±£3????t3£?a
  89. static int guiGetHzk(unsigned char hiByte, unsigned char loByte, unsigned char *pHzk, FONT_MODEENUM fontMode){
  90. unsigned char Q,W;
  91. unsigned int offset;
  92. const char hzk_12x12[]="HZK12";
  93. const char hzk_16x16[]="HZK16";
  94. char *hzk_ptr=NULL;
  95. static int fd_12=NULL,fd_16=NULL;
  96. int *fd_ptr=NULL;
  97. int fsize;
  98. if(hiByte<0xa0 || loByte<0xa0) return -1;
  99. Q=hiByte-0xa0;
  100. W=loByte-0xa0;
  101. if(FONT_MODE_12X12==fontMode){
  102. fsize = 24;
  103. hzk_ptr=(char *)hzk_12x12;
  104. fd_ptr=&fd_12;
  105. }else if(FONT_MODE_16X16==fontMode){
  106. fsize = 32;
  107. hzk_ptr=(char *)hzk_16x16;
  108. fd_ptr=&fd_16;
  109. }else return -2;
  110. offset=(94 * (Q-1) + (W-1))* fsize;
  111. //′ò?a???t
  112. if(*fd_ptr==NULL){
  113. int fd=LSAPI_FS_Open(hzk_ptr, LSAPI_FS_O_RDONLY, 0);
  114. if(fd==NULL){
  115. MSG_ERR(1, "%s open failed", hzk_ptr);
  116. return -3;
  117. }
  118. *fd_ptr=fd;
  119. }
  120. //?áè??úèY
  121. LSAPI_FS_Seek(*fd_ptr, offset, LSAPI_FS_SEEK_SET);
  122. offset=LSAPI_FS_Read(*fd_ptr, pHzk,fsize);
  123. #ifndef KEEP_HZK_OPENED
  124. LSAPI_FS_Close(*fd_ptr);
  125. *fd_ptr=NULL;
  126. #endif
  127. return offset;
  128. }
  129. static int fd_12_ext=NULL,fd_16_ext=NULL;
  130. static int extFileSize_1212=-1;
  131. static int extFileSize_1616=-1;
  132. bool fontExtLock=false;
  133. void extFontFileCtl(unsigned char fontType,bool ctl){
  134. int *fd_ext;
  135. if(ctl==true) fontExtLock=false;
  136. else{
  137. fontExtLock=true;
  138. if(fontType==12) fd_ext=&fd_12_ext;
  139. else if(fontType==16) fd_ext=&fd_16_ext;
  140. else{
  141. fontExtLock=false;
  142. return;
  143. }
  144. if(*fd_ext != NULL){
  145. LSAPI_FS_Close(*fd_ext);
  146. *fd_ext=NULL;
  147. }
  148. }
  149. }
  150. static int guiGetExtHzk(unsigned char hiByte, unsigned char loByte, unsigned char *pHzk, FONT_MODEENUM fontMode){
  151. unsigned char Q,W;
  152. int offset,i;
  153. char *hzk_ptr=NULL;
  154. int *fd_ptr=NULL;
  155. int *fsize,rsize;
  156. LSAPI_FS_Stat_info_t pBuf;
  157. unsigned char tmp[2+32];
  158. if(fontExtLock==true) return -1;
  159. if(FONT_MODE_12X12==fontMode){
  160. rsize = 24+2;
  161. hzk_ptr=HZK_12_NEW_FILE;
  162. fd_ptr=&fd_12_ext;
  163. fsize=&extFileSize_1212;
  164. }else if(FONT_MODE_16X16==fontMode){
  165. rsize = 32+2;
  166. hzk_ptr=HZK_16_NEW_FILE;
  167. fd_ptr=&fd_16_ext;
  168. fsize=&extFileSize_1616;
  169. }else return -2;
  170. //′ò?a???t
  171. if(*fd_ptr==NULL){
  172. int fd=LSAPI_FS_Open(hzk_ptr, LSAPI_FS_O_RDONLY, 0);
  173. if(fd==NULL){
  174. MSG_ERR(1, "%s open failed", hzk_ptr);
  175. return -3;
  176. }
  177. *fd_ptr=fd;
  178. }
  179. //get file size
  180. if(*fsize<1){
  181. memset(&pBuf,0,sizeof(pBuf));
  182. LSAPI_FS_Fstat(*fd_ptr,&pBuf);
  183. *fsize=pBuf.st_size;
  184. if(*fsize<0){
  185. offset=-4;
  186. goto F_END;
  187. }
  188. }
  189. LSAPI_FS_Seek(*fd_ptr, 0, LSAPI_FS_SEEK_SET);
  190. //check size
  191. if(1!=LSAPI_FS_Read(*fd_ptr, tmp,1)){
  192. offset=-5;
  193. goto F_END;
  194. }
  195. if(FONT_MODE_12X12==fontMode && tmp[0]!=12){
  196. offset=-6;
  197. goto F_END;
  198. }else if(FONT_MODE_16X16==fontMode && tmp[0]!=16){
  199. offset=-7;
  200. goto F_END;
  201. }
  202. for(;;){
  203. offset=LSAPI_FS_Read(*fd_ptr, tmp,rsize);
  204. if(offset != rsize){
  205. offset=-8;
  206. goto F_END;
  207. }
  208. if(tmp[0]==hiByte && tmp[1]==loByte){
  209. offset=rsize-2;
  210. memcpy(pHzk, tmp+2, offset);
  211. goto F_END;
  212. }
  213. }
  214. offset=-9;
  215. F_END:
  216. #ifndef KEEP_HZK_OPENED
  217. LSAPI_FS_Close(*fd_ptr);
  218. *fd_ptr=NULL;
  219. #endif
  220. return offset;
  221. }
  222. static void guiShowChars(unsigned short x,unsigned short y,unsigned char hiByte, unsigned char loByte,
  223. FONT_MODEENUM fontMode,
  224. unsigned int frontColorID,//????
  225. unsigned int backColorID,//????
  226. REV_ENUM rev){//??
  227. unsigned short i,j,k,m,n,fcolor,bcolor;
  228. unsigned short width,height;
  229. unsigned char ByteWidth,data;
  230. const unsigned char *l_pucFont,*l_pucLetter;
  231. unsigned char *p;
  232. unsigned char sucHzk16[32];
  233. unsigned char sucHzk12[24];
  234. int ret;
  235. //===?¨¨?¨′?Y?á??¤?¨|¨¨????¨o?|ì??¨a??é????é|ì??¨?¨oy?Y????|쨨===
  236. x++;y++;
  237. k = 0;
  238. if(hiByte==0){//english
  239. if(fontMode==FONT_MODE_12X12){//8* 12
  240. width=8;//8
  241. height = 12; //12
  242. ByteWidth = 1;
  243. l_pucFont = g_apucFonts12;
  244. l_pucLetter = g_apucLetter12;
  245. }else{ //8*16
  246. width=8;
  247. height = 16;
  248. ByteWidth = 1;
  249. l_pucFont = g_apucFonts16;
  250. l_pucLetter = g_apucLetter16;
  251. }
  252. while(*l_pucLetter){
  253. if(loByte == *l_pucLetter)break;
  254. l_pucLetter ++;
  255. k ++;
  256. }
  257. //2¨|?¨°|ì??á??a|ì??a¨o?????
  258. l_pucFont += k * ByteWidth * height;
  259. }else{//chinese
  260. if(fontMode==FONT_MODE_12X12){//12*16
  261. width=16;
  262. height = 12;
  263. ByteWidth = 2;
  264. l_pucFont = sucHzk12;
  265. l_pucLetter = 0;
  266. k=0;
  267. ret=guiGetHzk(hiByte,loByte,sucHzk12,fontMode);
  268. if(sizeof(sucHzk12)!=ret) ret=guiGetExtHzk(hiByte, loByte, sucHzk12,fontMode);
  269. if(sizeof(sucHzk12)!=ret){//??¨?sFlash|ì?HZK???t?D?¨¢¨¨??á??a¨oy?Y
  270. //?¨°2?|ì??á??a?ê???¨o?"?¨2"
  271. l_pucFont=g_apucCLetter16;
  272. MSG_ERR(1, "guiGetHzk12Err:%02x,%02x,%d",hiByte,loByte,ret);
  273. }
  274. }else{//16*16
  275. width=16;
  276. height = 16;
  277. ByteWidth = 2;
  278. l_pucFont = sucHzk16;
  279. l_pucLetter = 0;
  280. k=0;
  281. ret=guiGetHzk(hiByte,loByte,sucHzk16,fontMode);
  282. if(sizeof(sucHzk16)!=ret) ret=guiGetExtHzk(hiByte, loByte, sucHzk16,fontMode);
  283. if(sizeof(sucHzk16)!=ret){//??¨?sFlash|ì?HZK16???t?D?¨¢¨¨??á??a¨oy?Y
  284. //?¨°2?|ì??á??a?ê???¨o?"?¨2"
  285. l_pucFont=g_apucCLetter16;
  286. MSG_ERR(1, "guiGetHzk16Err:%02x,%02x,%d",hiByte,loByte,ret);
  287. }
  288. }
  289. }
  290. //====================?¨′??|¨¤¨a|ì??¨?¨oy?Y==========
  291. if(y+height>GLCD_HEIGHT)return;
  292. if(x+width>GLCD_WIDTH)return;
  293. guiBlockSet(x,y,x+width-1,y+height-1);//8,12
  294. fcolor=RGB888_2_RGB565(frontColorID);
  295. bcolor=RGB888_2_RGB565(backColorID);
  296. //¨°?????à?¨???|ì??¨???é|ì?LCD?ê?2?¨?????????ê¨??¨?¨22a¨o??ê??á?騰a|ì??¨??2?¨°a|ì??¨??PaintBufToLcd?ê??¤??¨°¨°2??é?¨¢¨¢?
  297. //?¨′?Y?á???ê?¨2??????D?-|ì?
  298. for(j=0;j<height;j++){
  299. m=y+j;
  300. for(i=0;i<ByteWidth;i++){
  301. n=x+i*8;
  302. data=*l_pucFont++;
  303. for(k=0;k<8;k++){
  304. if(data & (0x80>>k)){//??,??frontColorID
  305. if(REVERSED_NO==rev) guiDrawDot(fcolor);
  306. else guiDrawDot(bcolor);
  307. }else{//??,??backColorID
  308. if(REVERSED_NO==rev) guiDrawDot(bcolor);
  309. else guiDrawDot(fcolor);
  310. }
  311. }
  312. }
  313. }
  314. }
  315. short guiGetStrXLen(char *str, FONT_MODEENUM fontMode){
  316. unsigned char ch;
  317. unsigned short len=0;
  318. unsigned char bsize;
  319. if(FONT_MODE_12X12==fontMode) bsize=6;
  320. else if(FONT_MODE_16X16==fontMode) bsize=8;
  321. else return 0;
  322. while ((ch=*str++)){
  323. if(ch=='M')len+=12;
  324. else if(ch>='A'&&ch<='Z')len+=8;
  325. else if(ch>='a'&&ch<='z')len+=8;
  326. else if(ch>='0'&&ch<='9')len+=8;
  327. else if(ch>=0x20&& ch<=0x60)len+=8; //¨??¨oa?á??¤?
  328. else len+=bsize;
  329. }
  330. return len;
  331. }
  332. //ò????ó?ú??ía?a·?
  333. void guiShowStr(unsigned short x, unsigned short y,const char *string, FONT_MODEENUM fontMode,
  334. REV_ENUM rev, //????
  335. unsigned int frontColorID,//???
  336. unsigned int backColorID){//???
  337. unsigned char width1,width2,heigh;
  338. unsigned char *p;
  339. unsigned short i;
  340. if(fontMode == FONT_MODE_12X12){
  341. width1 = 12;
  342. width2 = 1;
  343. heigh=12;
  344. }else if(fontMode == FONT_MODE_16X16){
  345. width1 = 16;
  346. width2 = 1;
  347. heigh=16;
  348. }else return;
  349. p = (unsigned char *)string;
  350. i = 0;
  351. while(*p){
  352. if (*p > 0x80){//chinese letter
  353. guiShowChars(x+i,y,*p, *(p+1),fontMode,frontColorID,backColorID,rev);
  354. i += width1 ;
  355. p += 2;
  356. }else{//english letter
  357. guiShowChars(x + i,y,0,*p,fontMode,frontColorID,backColorID,rev);
  358. if(fontMode==0) i += width2 * 8;
  359. else i += width2 * 8;
  360. p ++;
  361. }
  362. }
  363. }
  364. void guiShowButton(unsigned short x, unsigned short y,const char *str, FONT_MODEENUM fontMode,unsigned int buttonColorID, unsigned int strColorID){
  365. int heigh,len;
  366. if(FONT_MODE_12X12==fontMode) heigh=12+4;
  367. else if(FONT_MODE_16X16==fontMode) heigh=16+4;
  368. else return;
  369. len=guiGetStrXLen((char *)str, fontMode);
  370. guiFillRect(x,y,x+len+8,y+heigh,buttonColorID);
  371. guiShowStr(x+4, y+1, str, fontMode,REVERSED_NO,strColorID,buttonColorID);
  372. }
  373. void guiFillRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2,unsigned int colorData){
  374. x1++;x2++;y1++;y2++;
  375. unsigned short x=x2,y=y2,w,h,i,m,k,j,data;
  376. if(x1>x2 || y1>y2) return;
  377. if(x1>=GLCD_WIDTH || y1>=GLCD_HEIGHT) return;
  378. if(x>GLCD_WIDTH) x=GLCD_WIDTH;
  379. if(y>GLCD_HEIGHT) y=GLCD_HEIGHT;
  380. w=x-x1+1;
  381. h=y-y1+1;
  382. data=RGB888_2_RGB565(colorData);
  383. guiBlockSet(x1,y1,x,y);
  384. for(i=0;i<h;i++){
  385. m=y1+i;
  386. for(j=0;j<w;j++){
  387. k=x1+j;
  388. guiDrawDot(data);
  389. }
  390. }
  391. }
  392. void guiClearRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned int colorData){
  393. guiFillRect(x1,y1,x2,y2,colorData);
  394. }
  395. //??????
  396. void guiDrawHLine(unsigned short x1, unsigned short x2, unsigned short y, unsigned short ysize, unsigned int colorID){
  397. if(ysize==0) return;
  398. if(x2<x1) return;
  399. guiFillRect(x1,y,x2,y+ysize-1,colorID);
  400. }
  401. //′1?±??
  402. void guiDrawVLine(unsigned short y1, unsigned short y2, unsigned short x, unsigned short xsize, unsigned int colorID){
  403. if(xsize==0) return;
  404. if(y2<y1) return;
  405. guiFillRect(x,y1,x+xsize-1,y2,colorID);
  406. }
  407. void guiDrawRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2,unsigned char width, unsigned int colorID){
  408. if(x1>x2||y1>y2) return;
  409. guiDrawHLine(x1,x2,y1,width,colorID);
  410. guiDrawHLine(x1,x2,y2,width,colorID);
  411. guiDrawVLine(y1,y2,x1,width,colorID);
  412. guiDrawVLine(y1,y2+width-1,x2,width,colorID);
  413. }
  414. //óé·??ò?aμ?(x,y)?aê??-
  415. void guiDrawArrow(unsigned short x, unsigned short y,unsigned short len, ARROW_ENUM direction, unsigned int colorID){
  416. unsigned short i;
  417. switch(direction){
  418. case ARROW_LEFT:
  419. for(i=0;i<len;i++) guiDrawRect(x+i,y-i,x+i,y+i,1,colorID);
  420. break;
  421. case ARROW_RIGHT:
  422. for(i=0;i<len;i++) guiDrawRect(x-i,y-i,x-i,y+i,1,colorID);
  423. break;
  424. case ARROW_UP:
  425. for(i=0;i<len;i++) guiDrawRect(x-i,y+i,x+i,y+i,1,colorID);
  426. break;
  427. case ARROW_DOWN:
  428. for(i=0;i<len;i++) guiDrawRect(x-i,y-i,x+i,y-i,1,colorID);
  429. break;
  430. }
  431. }
  432. static void guiFillBmpBuf(unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char *bmpBuf){
  433. int i,j,k,t;
  434. unsigned short RGB565,r,g,b;
  435. unsigned char R,G,B;
  436. for(j=0;j<height;j++){
  437. t=y+j;
  438. k=j*width;
  439. for(i=0;i<width;i++){
  440. R=bmpBuf[3*i];
  441. G=bmpBuf[3*i+1];
  442. B=bmpBuf[3*i+2];
  443. r=R>>3;
  444. g=G>>2;
  445. b=B>>3;
  446. RGB565=((r<<11)+(g<<5)+(b<<0));
  447. guiDrawDot(RGB565);
  448. }
  449. }
  450. }
  451. int WidthBytes( int nBits, int nWidth ){
  452. int nWidthBytes;
  453. nWidthBytes = nWidth;
  454. if( nBits == 1 ) nWidthBytes = ( nWidth + 7 ) / 8;
  455. else if( nBits == 4 ) nWidthBytes = ( nWidth + 1 ) / 2;
  456. else if( nBits == 16 ) nWidthBytes = nWidth * 2;
  457. else if( nBits == 24 ) nWidthBytes = nWidth * 3;
  458. else if( nBits == 32 ) nWidthBytes = nWidth * 4;
  459. while( ( nWidthBytes & 3 ) != 0 ) nWidthBytes++;
  460. return( nWidthBytes );
  461. }
  462. void guiShowBmp(unsigned short x, unsigned short y, char *bmp){
  463. }
  464. #define IMAGE_MAX_SIZE 322
  465. void guiShowBinMap(unsigned short x, unsigned short y, char *bmp){
  466. int fd,filelen;
  467. unsigned char temp[IMAGE_MAX_SIZE],round;
  468. LSAPI_FS_Stat_info_t pBuf;
  469. unsigned short w,h,i,j,page,l,totalPage,leftbits,k,n,d,f,startY,moveBits,totalHDots,index1,index2;
  470. fd=LSAPI_FS_Open(bmp, LSAPI_FS_O_RDONLY,0);
  471. if(fd<0){
  472. MSG_ERR(1, "%s open failed", bmp);
  473. return;
  474. }
  475. //check file length
  476. memset(&pBuf,0,sizeof(pBuf));
  477. LSAPI_FS_Fstat(fd,&pBuf);
  478. filelen=pBuf.st_size;
  479. if(filelen>IMAGE_MAX_SIZE){
  480. MSG_INFO(1, "%s image too large %d>%d",bmp,filelen,IMAGE_MAX_SIZE);
  481. goto BMP_END;
  482. }
  483. LSAPI_FS_Read(fd, temp, filelen);
  484. w=temp[0];//width
  485. h=temp[1];//heigh
  486. page=y/8;//start page
  487. startY=y%8;//draw from startY dot
  488. for(i=0;i<w;i++)
  489. {
  490. totalHDots=h;//total moving row dots
  491. index1=0; //page++;
  492. index2=1;
  493. totalPage = h/8; //total pages
  494. round=0;
  495. while(totalPage)
  496. {
  497. //write the first time
  498. moveBits=8-startY;//pages need to be move in this page
  499. for(n=0;n<moveBits;n++)
  500. {
  501. if(temp[2+(index1*w)+i] & 1) g_aucLcdBufF[page+(index1)][x+i] |= (1<<(startY+n));
  502. else g_aucLcdBufF[page+(index1)][x+i] &= ~(1<<(startY+n));
  503. //move bits
  504. temp[2+(index1*w)+i] >>= 1;
  505. }
  506. totalHDots -= moveBits;
  507. if(totalHDots <=0) break;
  508. //write the second time
  509. if(moveBits==8){//é?ò?ò3ê?°′??ì?8dotD′μ?
  510. //′?ò3ò2°′??ò3D′
  511. if(totalHDots >= 8) moveBits=8;
  512. else moveBits=totalHDots;
  513. startY=0;
  514. for(n=0;n<moveBits;n++)
  515. {
  516. if(temp[2+(index2*w)+i] & 1) g_aucLcdBufF[page+index2][x+i] |= (1<<(startY+n));
  517. else g_aucLcdBufF[page+index2][x+i] &= ~(1<<(startY+n));
  518. //???ùóDBits?òμíò?ò???
  519. temp[2+(index2*w)+i] >>= 1;
  520. }
  521. }
  522. else{
  523. moveBits = startY; //5
  524. for(n=0;n<moveBits;n++)
  525. {
  526. if(temp[2+(index1*w)+i] & 1) g_aucLcdBufF[page+index2][x+i] |= (1<<(n));
  527. else g_aucLcdBufF[page+index2][x+i] &= ~(1<<(n));
  528. //???ùóDBits?òμíò?ò???
  529. temp[2+(index1*w)+i] >>= 1;
  530. }
  531. }
  532. totalHDots -= moveBits;
  533. if(totalHDots <=0) break;
  534. index1++;
  535. index2++;
  536. totalPage--;
  537. }
  538. }
  539. //LCDFlashPain();
  540. LCDFlashPainPage(x,y);
  541. BMP_END:
  542. if(fd>0) LSAPI_FS_Close(fd);
  543. }
  544. /*?ó?D??ê?*/
  545. void guiShowCaption(unsigned short xType, const char *str, unsigned short y, unsigned int frontColorID, unsigned int backColorID, FONT_MODEENUM fontMode){
  546. int len,sy;
  547. unsigned short x;
  548. len=guiGetStrXLen((char *)str,fontMode);
  549. if(xType==0) x=(GLCD_WIDTH-len)/2;
  550. else x=xType;
  551. guiShowStr(x, y, str, fontMode, REVERSED_NO, frontColorID, backColorID);
  552. }
  553. void guiClearArea(unsigned short x, unsigned short y, unsigned short width, unsigned short height,unsigned int colorID){
  554. guiFillRect(x,y,x+width,y+height,colorID);
  555. }
  556. void newGuiNoteBoot(char type){
  557. const char *p1="正在开机";
  558. const char *p2="请等待";
  559. const char *p3="欢迎使用";
  560. const char *p4="公网集群对讲机";
  561. char *ptr1,*ptr2;
  562. if(type==0){
  563. ptr1=p1;
  564. ptr2=p2;
  565. }else{
  566. ptr1=p3;
  567. ptr2=p4;
  568. }
  569. newGuiClearMainPage();
  570. DrawLineV(0, 8, GLCD_WIDTH);
  571. newGuiShowMessageBox(ptr1,ROW_TWO);
  572. newGuiShowMessageBox(ptr2,ROW_THREE);
  573. }
  574. void guiInit(void){
  575. memset(g_aucLcdBufF, 0x00, GLCD_HEIGHT/8*GLCD_WIDTH);
  576. // SetMessageConfi();
  577. //if(sutApp.account.tnet==5) guiShowBmp(0,0,"welcome5.bin");//开机图片
  578. //else guiShowBmp(0,0,"welcome.bin");//开机图片
  579. newGuiNoteBoot(0);
  580. LCDFlashPain();//刷屏缓存
  581. lcdBackLightApi(1);//清屏后打开,否则会看到关机前的画面
  582. }
  583. void guiClearAll(unsigned int colorID){//只清第二,三区
  584. guiFillRect(0, UI_STATUS_ITEM_Y, GLCD_WIDTH-1, UI_CONTENT_SHOW_Y-1, guiGetForeColor());//清除第二区
  585. guiFillRect(0,UI_CONTENT_SHOW_Y,GLCD_WIDTH-1,GLCD_HEIGHT-1,colorID);
  586. }
  587. void guiShowMessageBox(char *msg){
  588. char buf[70];
  589. short len,x,y;
  590. y=GLCD_HEIGHT/2;
  591. guiClearRect(0,y-20,GLCD_WIDTH-1,y+20,guiGetBackColor());
  592. guiDrawRect(2,y-18,GLCD_WIDTH-3,y+18,1,COLOR_BLACK);
  593. StrIntercept(buf,msg,18);
  594. #ifdef USE_12X12_FONT_ONLY
  595. len=guiGetStrXLen(buf,FONT_MODE_12X12);
  596. x=(GLCD_WIDTH-len)/2;
  597. guiShowStr(x,y-6,buf,FONT_MODE_12X12,REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  598. #else
  599. len=guiGetStrXLen(buf,FONT_MODE_16X16);
  600. x=(GLCD_WIDTH-len)/2;
  601. guiShowStr(x,y-8,buf,FONT_MODE_16X16,REVERSED_NO,COLOR_BLACK,guiGetBackColor());
  602. #endif
  603. }
  604. //画一条线,线粗为1点
  605. //x,y为纵横坐标
  606. //len为长度
  607. void DrawLineV(unsigned char x, unsigned char y,unsigned char len)
  608. {
  609. //x 0 - 127
  610. //y 0 - 63
  611. unsigned char i,j,page,l,length;
  612. if(len<=1) return;
  613. if(x > GLCD_WIDTH) return;
  614. if(y > GLCD_HEIGHT) return;
  615. page = y/8;
  616. l=y%8;
  617. length=len;
  618. if(length+x > GLCD_WIDTH) length = GLCD_WIDTH-x;
  619. for(i=0;i<length;i++){
  620. // g_aucLcdBufF[page][x+i] |= (1<<l);
  621. g_aucLcdBufF[page][x+i] |= (1<<2);
  622. g_aucLcdBufF[page][x+i] |= (1<<3);//
  623. }
  624. // LCDFlashPain();
  625. LCDFlashPainPage(x,y);
  626. }
  627. //画一条线,线粗为1点
  628. //x,y为纵横坐标
  629. //height为高度
  630. void DrawLineH(unsigned char x, unsigned char y, unsigned char height)
  631. {
  632. //x 0 - 127
  633. //y 0 - 63
  634. unsigned char i,j,page,l,k,hei,totalPage,leftbits;
  635. if(height<=1) return;
  636. if(x > GLCD_WIDTH) return;
  637. if(y > GLCD_HEIGHT) return;
  638. page = y/8; //第几页
  639. l=y%8; //第几个
  640. totalPage = (height-(8-l))/8; //共几页
  641. if(height > (8-l))
  642. leftbits = (height-(8-l))%8; //尾部位置
  643. else
  644. leftbits = 0;
  645. hei=height;
  646. if(hei+x > GLCD_WIDTH) hei = GLCD_WIDTH-x; //
  647. if(height < 8) k = 8-height;
  648. else k=l;
  649. //printf("page:%d,l:%d,totalPage:%d,leftbits:%d,hei:%d,k:%d\r\n", page,l,totalPage,leftbits,hei,k);
  650. for(i=0;i<(8-k);i++)
  651. g_aucLcdBufF[page][x] |= (1<<(l+i));
  652. for(i=0;i<totalPage;i++)
  653. {
  654. g_aucLcdBufF[page+i+1][x] |= 0xff;
  655. }
  656. if(leftbits)
  657. {
  658. for(i=0;i<leftbits;i++)
  659. g_aucLcdBufF[page+totalPage+1][x] |= (1<<i);
  660. }
  661. LCDFlashPainPage(x,y);
  662. }
  663. void newGuiShowMessageBox(char *msg, ROW_ENUM row){
  664. int len=guiGetStrXLen(msg, FONT_MODE_16X16);
  665. int y;
  666. if(row==ROW_TWO) y=16;
  667. else if(row==ROW_THREE) y=32;
  668. newGuiShowStr((GLCD_WIDTH-len)/2, y, msg,REVERSED_NO,FONT_MODE_16X16);
  669. }
  670. /*****************************************
  671. 从字库文件HZK16中提取某汉子的字库数据
  672. 输入:hiByte--汉字的高字节 loByte--汉字的低字节
  673. 字库文件存储在sFlash中,字库文件名为HZK16
  674. 输出:pHzk--提取到的字库数据,需要预留足够空间存储。如果是16*16 则应该是16*16/8=32Byte
  675. 返回:失败返回0 成功返回长度
  676. ******************************************/
  677. int GetHzk(unsigned char hiByte,unsigned char loByte,unsigned char *pHzk,FONT_MODEENUM font)
  678. {
  679. int fd;
  680. unsigned char Q,W;
  681. unsigned int offset;
  682. const char *HZK12="HZK12";
  683. const char *HZK16="HZK16";
  684. char *hzk;
  685. int readlen;
  686. if(hiByte<0xa0 || loByte<0xa0)return 0;
  687. Q=hiByte-0xa0;
  688. W=loByte-0xa0;
  689. if(font==FONT_MODE_16X16){
  690. hzk=HZK16;
  691. readlen=32;
  692. }else{
  693. hzk=HZK12;
  694. readlen=24;
  695. }
  696. offset=(94 * (Q-1) + (W-1))* readlen;
  697. fd=LSAPI_FS_Open(hzk, LSAPI_FS_O_RDONLY,0);
  698. if(fd<0){
  699. MSG_ERR(1, "%s open failed", hzk);
  700. return 0;
  701. }
  702. LSAPI_FS_Seek(fd, offset,LSAPI_FS_SEEK_SET);
  703. readlen=LSAPI_FS_Read(fd, pHzk, readlen);
  704. LSAPI_FS_Close(fd);
  705. return readlen;
  706. }
  707. void Rota90Degreed12(unsigned char *source)
  708. {
  709. unsigned char temp[24];
  710. unsigned char i,j,h,k;
  711. memset(temp,0,24);
  712. //左上角部分
  713. for(j=0;j<8;j++)
  714. {
  715. for(i=0;i<8;i++)
  716. if(source[2*i] & (1<<(7-j))) temp[j] |= (1<<i);
  717. }
  718. //右上角部分
  719. for(j=0;j<4;j++)
  720. {
  721. for(i=0;i<8;i++)
  722. if(source[2*i+1] & (1<<(7-j))) temp[1*8+j] |= (1<<i);
  723. }
  724. //左下角部分
  725. for(j=0;j<8;j++)
  726. {
  727. for(i=0;i<4;i++)
  728. if(source[1*16+2*i] & (1<<(7-j))) temp[1*12+j] |= (1<<i);
  729. }
  730. //右下角部分
  731. for(j=0;j<4;j++)
  732. {
  733. for(i=0;i<4;i++)
  734. if(source[1*16+2*i+1] & (1<<(7-j))) temp[1*20+j] |= (1<<i);
  735. }
  736. memcpy(source, temp,24);
  737. }
  738. void Rota90Degreed16(unsigned char *source)// 旋转90度
  739. {
  740. unsigned char temp[32];
  741. unsigned char i,j,h,k;
  742. memset(temp,0,32);
  743. //左上角部分
  744. for(j=0;j<8;j++)
  745. {
  746. for(i=0;i<8;i++)
  747. if(source[2*i] & (1<<(7-j))) temp[j] |= (1<<i);
  748. }
  749. //右上角部分
  750. for(j=0;j<8;j++)
  751. {
  752. for(i=0;i<8;i++)
  753. if(source[2*i+1] & (1<<(7-j))) temp[1*8+j] |= (1<<i);
  754. }
  755. //左下角部分
  756. for(j=0;j<8;j++)
  757. {
  758. for(i=0;i<8;i++)
  759. if(source[1*16+2*i] & (1<<(7-j))) temp[1*16+j] |= (1<<i);
  760. }
  761. //右下角部分
  762. for(j=0;j<8;j++)
  763. {
  764. for(i=0;i<8;i++)
  765. if(source[1*16+2*i+1] & (1<<(7-j))) temp[1*24+j] |= (1<<i);
  766. }
  767. memcpy(source, temp,32);
  768. }
  769. //rev 0 正常显示 否则反显
  770. void newGuiShowStr(unsigned char X, unsigned char y, const char *str,unsigned char rev,FONT_MODEENUM font)
  771. {
  772. //12*12中文
  773. //8*12 英文
  774. unsigned char *p;
  775. unsigned char i,j;
  776. unsigned char charNum,tempData;
  777. unsigned char sucHzk12[24+2];//12*12字体间会很窄,加第13列为0,这样好看
  778. unsigned char tempBack[12];
  779. unsigned char sucHzk16[32];
  780. unsigned char h,k1,k2,k3,pa;
  781. unsigned short temp;
  782. int ret;
  783. charNum=0;
  784. p=(unsigned char *)str;
  785. while(*p != 0)
  786. {
  787. if(*p > 0x80)//chinese
  788. {//填充2*8=16个点数据
  789. if(font==FONT_MODE_12X12){
  790. ret=GetHzk(*p,*(p+1),sucHzk12,font);
  791. if(ret != 24) ret=guiGetExtHzk(*p,*(p+1),sucHzk12,font);
  792. if(24!=ret){
  793. //找不到字库,显示"口"
  794. memcpy(sucHzk12, g_apucCFonts16, sizeof(sucHzk12));
  795. }
  796. Rota90Degreed12(sucHzk12);
  797. memcpy(tempBack, &sucHzk12[12],12);
  798. memcpy(&sucHzk12[13],tempBack, 12);
  799. sucHzk12[12]=0;
  800. sucHzk12[25]=0;
  801. ////////////////////////////////////
  802. h = y % 8;//新page中的第几行
  803. pa = y / 8;//座落于第几page
  804. k1 = 8-h;//开始page中有多少位是要被处理的,且处理是高位先
  805. k2 = 12-k1;//下一个page中要显示多少位
  806. if(k2>8) //k3,再下一个page中要显示多少位,对于12高度来说,最多跨三个page
  807. {
  808. k3=k2-8;
  809. k2 = 8;
  810. }
  811. else k3=0;
  812. for(i=0;i<13;i++)
  813. {
  814. temp = (((unsigned short)sucHzk12[i+13])<<8) & 0xff00;
  815. temp |= ((unsigned short)sucHzk12[i])&0xff;
  816. for(j=0;j<k1;j++)
  817. {
  818. if(temp & 0x01)
  819. g_aucLcdBufF[pa][charNum+X+i] |= (1<<(h+j));
  820. else
  821. g_aucLcdBufF[pa][charNum+X+i] &= ~(1<<(h+j));
  822. temp >>= 1;
  823. }
  824. for(j=0;j<k2;j++)
  825. {
  826. if(temp & 0x01)
  827. g_aucLcdBufF[pa+1][charNum+X+i] |= (1<<(j));
  828. else
  829. g_aucLcdBufF[pa+1][charNum+X+i] &= ~(1<<(j));
  830. temp >>= 1;
  831. }
  832. for(j=0;j<k3;j++)
  833. {
  834. if(temp & 0x01)
  835. g_aucLcdBufF[pa+2][charNum+X+i] |= (1<<(j));
  836. else
  837. g_aucLcdBufF[pa+2][charNum+X+i] &= ~(1<<(j));
  838. temp >>= 1;
  839. }
  840. }
  841. p+=2;
  842. charNum += 12+1;//加1是让两个字体间有间隔12*12本身是基本会用完宽度的
  843. }else{
  844. ret=GetHzk(*p,*(p+1),sucHzk16,font);
  845. if(ret != 32) ret=guiGetExtHzk(*p,*(p+1),sucHzk16,font);
  846. if(32!=ret){
  847. //找不到字库,显示"口"
  848. memcpy(sucHzk16, g_apucCFonts16, sizeof(sucHzk16));
  849. }
  850. Rota90Degreed16(sucHzk16);
  851. ////////////////////////////////////
  852. h = y % 8;//新page中的第几行
  853. pa = y / 8;//座落于第几page
  854. k1 = 8-h;//开始page中有多少位是要被处理的,且处理是高位先
  855. k2 = 16-k1;//下一个page中要显示多少位
  856. if(k2>8) //k3,再下一个page中要显示多少位
  857. {
  858. k3=k2-8;
  859. k2 = 8;
  860. }
  861. else k3=0;
  862. for(i=0;i<16;i++)
  863. {
  864. temp = (((unsigned short)sucHzk16[i+16])<<8) & 0xff00;
  865. temp |= ((unsigned short)sucHzk16[i])&0xff;
  866. for(j=0;j<k1;j++)
  867. {
  868. if(temp & 0x01)
  869. g_aucLcdBufF[pa][charNum+X+i] |= (1<<(h+j));
  870. else
  871. g_aucLcdBufF[pa][charNum+X+i] &= ~(1<<(h+j));
  872. temp >>= 1;
  873. }
  874. for(j=0;j<k2;j++)
  875. {
  876. if(temp & 0x01)
  877. g_aucLcdBufF[pa+1][charNum+X+i] |= (1<<(j));
  878. else
  879. g_aucLcdBufF[pa+1][charNum+X+i] &= ~(1<<(j));
  880. temp >>= 1;
  881. }
  882. for(j=0;j<k3;j++)
  883. {
  884. if(temp & 0x01)
  885. g_aucLcdBufF[pa+2][charNum+X+i] |= (1<<(j));
  886. else
  887. g_aucLcdBufF[pa+2][charNum+X+i] &= ~(1<<(j));
  888. temp >>= 1;
  889. }
  890. }
  891. p+=2;
  892. charNum += 16;//加1是让两个字体间有间隔12*12本身是基本会用完宽度的
  893. }
  894. }else//english
  895. {//填充1*8=8 个点数据
  896. if(font==0){
  897. if(*p < 0x30)
  898. tempData = *p-0x20;
  899. else if(*p <= '9')
  900. tempData = *p-0x30+16;
  901. else if(*p <= '@')
  902. tempData = *p-0x3a+26;
  903. else if(*p <= 'Z')
  904. tempData = *p-0x41+33;
  905. else if(*p <= 'z')
  906. tempData = *p-0x61+59;
  907. else if(*p <= '~')
  908. tempData = *p-0x7b+85;
  909. ///////////////////////////
  910. ////////////////////////////////////
  911. h = y % 8;//新page中的第几行
  912. pa = y / 8;//座落于第几page
  913. k1 = 8-h;//开始page中有多少位是要被处理的,且处理是高位先
  914. k2 = 8-k1;//下一个page中要显示多少位
  915. if(k2>8) //k3,再下一个page中要显示多少位,对于12高度来说,最多跨三个page
  916. {
  917. k3=k2-8;
  918. k2 = 8;
  919. }
  920. else k3=0;
  921. for(i=0;i<8;i++)
  922. {
  923. temp = (((unsigned short)g_english88[tempData][i+8])<<8) & 0xff00;
  924. temp |= ((unsigned short)g_english88[tempData][i])&0xff;
  925. for(j=0;j<k1;j++)
  926. {
  927. if(temp & 0x01)
  928. g_aucLcdBufF[pa][charNum+X+i] |= (1<<(h+j));
  929. else
  930. g_aucLcdBufF[pa][charNum+X+i] &= ~(1<<(h+j));
  931. temp >>= 1;
  932. }
  933. for(j=0;j<k2;j++)
  934. {
  935. if(temp & 0x01)
  936. g_aucLcdBufF[pa+1][charNum+X+i] |= (1<<(j));
  937. else
  938. g_aucLcdBufF[pa+1][charNum+X+i] &= ~(1<<(j));
  939. temp >>= 1;
  940. }
  941. for(j=0;j<k3;j++)
  942. {
  943. if(temp & 0x01)
  944. g_aucLcdBufF[pa+2][charNum+X+i] |= (1<<(j));
  945. else
  946. g_aucLcdBufF[pa+2][charNum+X+i] &= ~(1<<(j));
  947. temp >>= 1;
  948. }
  949. }
  950. p++;
  951. charNum += 8;
  952. }else {
  953. if(*p < 0x30)
  954. tempData = *p-0x20;
  955. else if(*p <= '9')
  956. tempData = *p-0x30+16;
  957. else if(*p <= '@')
  958. tempData = *p-0x3a+26;
  959. else if(*p <= 'Z')
  960. tempData = *p-0x41+33;
  961. else if(*p <= 'z')
  962. tempData = *p-0x61+59;
  963. else if(*p <= '~')
  964. tempData = *p-0x7b+85;
  965. ///////////////////////////
  966. ////////////////////////////////////
  967. h = y % 8;//新page中的第几行
  968. pa = y / 8;//座落于第几page
  969. k1 = 8-h;//开始page中有多少位是要被处理的,且处理是高位先
  970. k2 = 12-k1;//下一个page中要显示多少位
  971. if(k2>8) //k3,再下一个page中要显示多少位,对于12高度来说,最多跨三个page
  972. {
  973. k3=k2-8;
  974. k2 = 8;
  975. }
  976. else k3=0;
  977. for(i=0;i<8;i++)
  978. {
  979. temp = (((unsigned short)g_english812[tempData][i+8])<<8) & 0xff00;
  980. temp |= ((unsigned short)g_english812[tempData][i])&0xff;
  981. for(j=0;j<k1;j++)
  982. {
  983. if(temp & 0x01)
  984. g_aucLcdBufF[pa][charNum+X+i] |= (1<<(h+j));
  985. else
  986. g_aucLcdBufF[pa][charNum+X+i] &= ~(1<<(h+j));
  987. temp >>= 1;
  988. }
  989. for(j=0;j<k2;j++)
  990. {
  991. if(temp & 0x01)
  992. g_aucLcdBufF[pa+1][charNum+X+i] |= (1<<(j));
  993. else
  994. g_aucLcdBufF[pa+1][charNum+X+i] &= ~(1<<(j));
  995. temp >>= 1;
  996. }
  997. for(j=0;j<k3;j++)
  998. {
  999. if(temp & 0x01)
  1000. g_aucLcdBufF[pa+2][charNum+X+i] |= (1<<(j));
  1001. else
  1002. g_aucLcdBufF[pa+2][charNum+X+i] &= ~(1<<(j));
  1003. temp >>= 1;
  1004. }
  1005. }
  1006. p++;
  1007. charNum += 8;
  1008. }
  1009. }
  1010. }
  1011. // LCDFlashPain();
  1012. LCDFlashPainPage(X,y);
  1013. }
  1014. void NewDrawVLine(unsigned short x, unsigned short y, unsigned short Vlen)
  1015. {
  1016. unsigned short i,j,k;
  1017. unsigned short drawVdots;//需要画紧方向的总dot数
  1018. unsigned short leftdots; //当前page中有多少dot可用
  1019. unsigned short thisDrawDots;//实际填充dot到当前page中的个数
  1020. unsigned char startPage;//从哪page开始显示
  1021. if(0==Vlen || x >= GLCD_WIDTH || y >= GLCD_HEIGHT) return;
  1022. drawVdots = GLCD_HEIGHT-y;//实际可显示这么高
  1023. if(Vlen <= drawVdots) drawVdots=Vlen;
  1024. startPage=y/8;
  1025. j=y%8;//如果是非整page段,y则是从第几个Bit开始填充
  1026. if(j)
  1027. {
  1028. leftdots = 8-j;//非整page段还有这么多个dot可显示
  1029. if(drawVdots > leftdots) thisDrawDots = leftdots;
  1030. else thisDrawDots = drawVdots;
  1031. for(k=0;k<thisDrawDots;k++)//所有点写1
  1032. g_aucLcdBufF[startPage][x] |= 1<<(k+j);
  1033. drawVdots -= thisDrawDots;
  1034. startPage++;
  1035. }
  1036. if(drawVdots <=0) return;
  1037. //以下全是完全的page了
  1038. while(drawVdots)
  1039. {
  1040. if(drawVdots > 8) thisDrawDots = 8;
  1041. else thisDrawDots = drawVdots;
  1042. for(k=0;k<thisDrawDots;k++)
  1043. g_aucLcdBufF[startPage][x] |= 1<<k;
  1044. startPage++;
  1045. drawVdots -= thisDrawDots;
  1046. }
  1047. }
  1048. void GuiDrawSignalVLine(unsigned char t4) //3
  1049. {
  1050. MSG_INFO(1, "_t_%d_",t4);
  1051. if(t4 == 0) return;
  1052. // g_aucLcdBufF[1][15] &= 0xfe;
  1053. // g_aucLcdBufF[1][13] &= 0xfe;
  1054. // g_aucLcdBufF[1][11] &= 0xfe;
  1055. // g_aucLcdBufF[1][9] &= 0xfe;
  1056. // g_aucLcdBufF[1][7] &= 0xfe;
  1057. g_aucLcdBufF[0][15] &= 0x01;
  1058. g_aucLcdBufF[0][13] &= 0x01;
  1059. g_aucLcdBufF[0][11] &= 0x01;
  1060. g_aucLcdBufF[0][9] &= 0x01;
  1061. g_aucLcdBufF[0][7] &= 0x01;
  1062. g_aucLcdBufF[1][15] &= 0xfe;
  1063. g_aucLcdBufF[1][13] &= 0xfe;
  1064. g_aucLcdBufF[1][11] &= 0xfe;
  1065. g_aucLcdBufF[1][9] &= 0xfe;
  1066. g_aucLcdBufF[1][7] &= 0xfe;
  1067. if(t4 <2)
  1068. {
  1069. //g_aucLcdBufT[0][15] = 0xff;
  1070. g_aucLcdBufF[0][15] = 0xfe;
  1071. g_aucLcdBufF[1][15] |= 0x01;
  1072. }
  1073. if(t4 <3)
  1074. {
  1075. //g_aucLcdBufT[0][13] = 0xfc;
  1076. g_aucLcdBufF[0][13] = 0xf8;
  1077. g_aucLcdBufF[1][13] |= 0x01;
  1078. }
  1079. if(t4 <4)
  1080. {
  1081. //g_aucLcdBufT[0][11] = 0xf0;
  1082. g_aucLcdBufF[0][11] = 0xe0;
  1083. g_aucLcdBufF[1][11] |= 0x01;
  1084. }
  1085. if(t4 <5)
  1086. {
  1087. //g_aucLcdBufT[0][9] = 0xc0;
  1088. g_aucLcdBufF[0][9] = 0x80;
  1089. g_aucLcdBufF[1][9] |= 0x01;
  1090. }
  1091. if(t4 < 6)
  1092. {
  1093. //g_aucLcdBufT[0][7] = 0x80;
  1094. g_aucLcdBufF[1][7] |= 0x01;
  1095. }
  1096. LcdStatusBarFlash();
  1097. }
  1098. //////////////////////////////////////测试接口///////////////////////////////////
  1099. void guiTest(void){
  1100. static int flag=1;
  1101. MSG_INFO(1, "DDDD:%d", flag);
  1102. GuiDrawSignalVLine(flag);
  1103. if(++flag>=6) flag=1;
  1104. //guiShowBinMap(GLCD_WIDTH-15,48,"APN1.bin");
  1105. //guiShowBinMap(1,30,"APN2.bin");
  1106. return;
  1107. //return;
  1108. //char testbuf[5]={0xB2,0xE2,0xCA,0xD4,0x00};
  1109. //??ê?DD??
  1110. guiDrawHLine(1, GLCD_WIDTH-2, 1, 1, guiGetForeColor());
  1111. //??ê?áD??
  1112. guiDrawVLine(3, GLCD_HEIGHT-2, 1, 1, guiGetForeColor());
  1113. //??ê???D???D?
  1114. guiDrawRect(3,3,3+10,3+10,1,guiGetForeColor());
  1115. //??ê?êμD???D?
  1116. guiFillRect(15, 3, 15+10, 3+10,guiGetForeColor());
  1117. //??ê??yí·
  1118. guiDrawArrow(50, 3,10, ARROW_UP, guiGetForeColor());
  1119. guiDrawArrow(70, 3+10,10, ARROW_DOWN, guiGetForeColor());
  1120. guiDrawArrow(90, 3+8,10, ARROW_LEFT, guiGetForeColor());
  1121. guiDrawArrow(110, 3+8,10, ARROW_RIGHT, guiGetForeColor());
  1122. //??ê?12X12×?·?′?
  1123. guiShowStr(3, 30,"123测试45中,国AW", FONT_MODE_12X12, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
  1124. //??ê?16X16×?·?′?
  1125. guiShowStr(3, 50,"123测试45你。好AW", FONT_MODE_16X16, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
  1126. //??ê?í???
  1127. guiShowBmp(3, 80, "Palace2.bmp");
  1128. //??ê?°′?ü
  1129. guiShowButton(100, 80,"B12", FONT_MODE_12X12,guiGetForeColor(), guiGetBackColor());
  1130. }