gui(3571).c 31 KB

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