123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698 |
- #include "gui.h"
- #include "lcdDrv.h"
- #include "lsapi_fs.h"
- #include "log.h"
- #include "fonts.h"
- #include "board.h"
- #include "uiEntry.h"
- #include "app.h"
- #include "math.h"
- #if 0
- #define COLOR_BACKGROUND COLOR_BLACK
- #define COLOR_FOREGROUND COLOR_WHITE
- #else
- #define COLOR_BACKGROUND COLOR_WHITE
- #define COLOR_FOREGROUND COLOR_BLACK
- #endif
- unsigned int g_backColor;
- unsigned int g_foreColor;
- unsigned int guiGetBackColor(void){return g_backColor;}
- unsigned int guiGetForeColor(void){return g_foreColor;}
- static unsigned short RGB888_2_RGB565(unsigned int rgb888){
- unsigned short r,g,b,rgb565;
-
- b=(rgb888 >> (16+3))&0x1F;
- g=(rgb888 >> (8+2))&0x3f;
- r=(rgb888 >> (0+3))&0x1f;
-
- rgb565=((r<<11) + (g<<5) + (b<<0));
- return rgb565;
- }
- static void guiDrawDot(unsigned short colorData){
- LCD_DataWrite_ST7735(colorData >> 8);
- LCD_DataWrite_ST7735(colorData & 0xff);
- }
- static void guiBlockSet(unsigned short sx, unsigned short ex, unsigned short sy, unsigned short ey){
- LCD_CtrlWrite_ST7735(0x2a);
- guiDrawDot(sx);
- guiDrawDot(sy);
-
- LCD_CtrlWrite_ST7735(0x2B);
- guiDrawDot(ex);
- guiDrawDot(ey);
- LCD_CtrlWrite_ST7735(0x2C);
- }
- #define KEEP_HZK_OPENED //ê?·?±£3????t3£?a
- #define HZK_FENGQU 72*3*1024
- #define HZK_FENGQU_02 72*3*1024*2
- #define HZK32_FENQU_BLOCK 262144
- static int guiGetHzk(unsigned char hiByte, unsigned char loByte, unsigned char *pHzk, FONT_MODEENUM fontMode){
- unsigned char Q,W;
- unsigned int offset;
- const char hzk_16x16[]="HZK16";
- const char hzk_24x24_1[]="/ext/prepack/HZK24_1";
- const char hzk_24x24_2[]="/ext/prepack/HZK24_2";
- const char hzk_24x24_3[]="/ext/prepack/HZK24_3";
- char *hzk_ptr=NULL;
- static int fd_12=NULL,fd_16=NULL,fd_24_1=NULL,fd_24_2=NULL,fd_24_3=NULL;
- static int fd_32_1=NULL,fd_32_2=NULL,fd_32_3=NULL,fd_32_4=NULL;
- int *fd_ptr=NULL;
- int fsize;
- char temp=0;
- static char buf[30]={0};
-
- if(hiByte<0xa0 || loByte<0xa0) return -1;
- Q=hiByte-0xa0;
- W=loByte-0xa0;
- if(FONT_MODE_16X16==fontMode)fsize = 32;
- else if(FONT_MODE_24X24==fontMode)fsize=72;
- else if(FONT_MODE_32X32==fontMode)fsize=128;
-
- offset=(94 * (Q-1) + (W-1))* fsize;
- if(FONT_MODE_16X16==fontMode){
- hzk_ptr=(char *)hzk_16x16;
- fd_ptr=&fd_16;
- }else if(FONT_MODE_24X24==fontMode){
- if(offset<=HZK_FENGQU){
- hzk_ptr=(char *)hzk_24x24_1;
- fd_ptr=&fd_24_1;
- }else if(offset>HZK_FENGQU&&offset<HZK_FENGQU_02){
- offset-=HZK_FENGQU;
- hzk_ptr=(char *)hzk_24x24_2;
- fd_ptr=&fd_24_2;
- }else {
- offset-=HZK_FENGQU_02;
- hzk_ptr=(char *)hzk_24x24_3;
- fd_ptr=&fd_24_3;
- }
- }else if(FONT_MODE_32X32==fontMode){
- temp=offset/HZK32_FENQU_BLOCK;
- snprintf(buf, sizeof(buf),"/ext/prepack/HZK32_%d",temp+1);
- hzk_ptr=buf;
- //MSG_INFO(1,"%s",buf);
- offset-=HZK32_FENQU_BLOCK*temp;
- switch(temp){
- case 0 :
- fd_ptr=&fd_32_1;
- break;
- case 1 :
- fd_ptr=&fd_32_2;
- break;
- case 2 :
- fd_ptr=&fd_32_3;
- break;
- case 3 :
- fd_ptr=&fd_32_4;
- break;
- default:
- fd_ptr=&fd_32_4;
- break;
- }
-
- }else return -2;
-
- if(*fd_ptr==NULL){
- int fd=LSAPI_FS_Open(hzk_ptr, LSAPI_FS_O_RDONLY, 0);
- if(fd==NULL){
- MSG_ERR(1, "%s open failed", hzk_ptr);
- return -3;
- }
- *fd_ptr=fd;
- }
- LSAPI_FS_Seek(*fd_ptr, offset, LSAPI_FS_SEEK_SET);
- offset=LSAPI_FS_Read(*fd_ptr, pHzk,fsize);
-
- #ifndef KEEP_HZK_OPENED
- LSAPI_FS_Close(*fd_ptr);
- *fd_ptr=NULL;
- #endif
- return offset;
- }
- static int fd_12_ext=NULL,fd_16_ext=NULL;
- static int extFileSize_1212=-1;
- static int extFileSize_1616=-1;
- bool fontExtLock=false;
- void extFontFileCtl(unsigned char fontType,bool ctl){
- int *fd_ext;
- if(ctl==true) fontExtLock=false;
- else{
- fontExtLock=true;
- if(fontType==12) fd_ext=&fd_12_ext;
- else if(fontType==16) fd_ext=&fd_16_ext;
- else{
- fontExtLock=false;
- return;
- }
- if(*fd_ext != NULL){
- LSAPI_FS_Close(*fd_ext);
- *fd_ext=NULL;
- }
- }
- }
- static int guiGetExtHzk(unsigned char hiByte, unsigned char loByte, unsigned char *pHzk, FONT_MODEENUM fontMode){
- unsigned char Q,W;
- int offset,i;
- char *hzk_ptr=NULL;
- int *fd_ptr=NULL;
- int *fsize,rsize;
- LSAPI_FS_Stat_info_t pBuf;
- unsigned char tmp[2+32];
- if(fontExtLock==true) return -1;
- if(FONT_MODE_16X16==fontMode){
- rsize = 24+2;
- hzk_ptr=HZK_12_NEW_FILE;
- fd_ptr=&fd_12_ext;
- fsize=&extFileSize_1212;
- }else if(FONT_MODE_16X16==fontMode){
- rsize = 32+2;
- hzk_ptr=HZK_16_NEW_FILE;
- fd_ptr=&fd_16_ext;
- fsize=&extFileSize_1616;
- }else return -2;
- //′ò?a???t
- if(*fd_ptr==NULL){
- int fd=LSAPI_FS_Open(hzk_ptr, LSAPI_FS_O_RDONLY, 0);
- if(fd==NULL){
- MSG_ERR(1, "%s open failed", hzk_ptr);
- return -3;
- }
- *fd_ptr=fd;
- }
- //get file size
- if(*fsize<1){
- memset(&pBuf,0,sizeof(pBuf));
- LSAPI_FS_Fstat(*fd_ptr,&pBuf);
- *fsize=pBuf.st_size;
- if(*fsize<0){
- offset=-4;
- goto F_END;
- }
- }
- LSAPI_FS_Seek(*fd_ptr, 0, LSAPI_FS_SEEK_SET);
- //check size
- if(1!=LSAPI_FS_Read(*fd_ptr, tmp,1)){
- offset=-5;
- goto F_END;
- }
- if(FONT_MODE_16X16==fontMode && tmp[0]!=12){
- offset=-6;
- goto F_END;
- }else if(FONT_MODE_16X16==fontMode && tmp[0]!=16){
- offset=-7;
- goto F_END;
- }
- for(;;){
- offset=LSAPI_FS_Read(*fd_ptr, tmp,rsize);
- if(offset != rsize){
- offset=-8;
- goto F_END;
- }
- if(tmp[0]==hiByte && tmp[1]==loByte){
- offset=rsize-2;
- memcpy(pHzk, tmp+2, offset);
- goto F_END;
- }
- }
- offset=-9;
- F_END:
- #ifndef KEEP_HZK_OPENED
- LSAPI_FS_Close(*fd_ptr);
- *fd_ptr=NULL;
- #endif
- return offset;
- }
- static void guiShowChars(unsigned short x,unsigned short y,unsigned char hiByte, unsigned char loByte,
- FONT_MODEENUM fontMode,
- unsigned int frontColorID,//????
- unsigned int backColorID,//????
- REV_ENUM rev){//??
- unsigned short i,j,k,m,n,fcolor,bcolor;
- unsigned short width,height;
- unsigned char ByteWidth,data;
- const unsigned char *l_pucFont,*l_pucLetter;
- unsigned char *p;
- unsigned char sucHzk16[32];
- unsigned char sucHzk24[72];
- unsigned char sucHzk32[128];
- int ret;
- k = 0;
- if(hiByte==0){//english
- if(fontMode==FONT_MODE_16X16){//8* 12
- width=8;
- height = 16;
- ByteWidth = 1;
- l_pucFont = g_apucFonts16;
- l_pucLetter = g_apucLetter16;
-
- }else if(fontMode==FONT_MODE_24X24){ //8*16
- width=16;//8 hyl
- height = 24;
- ByteWidth = 2;
- l_pucFont = g_apucFonts24;
- l_pucLetter = g_apucLetter24;
- }else if(fontMode==FONT_MODE_32X32){
- width=16;//8 hyl
- height = 32;
- ByteWidth = 2;
- l_pucFont = g_apucFonts32;
- l_pucLetter = g_apucLetter32;
- }
- while(*l_pucLetter){
- if(loByte == *l_pucLetter)break;
- l_pucLetter ++;
- k ++;
- }
- //2¨|?¨°|ì??á??a|ì??a¨o?????
- l_pucFont += k * ByteWidth * height;
- }else{//chinese
-
- if(fontMode==FONT_MODE_16X16){//12*16
- width=16;
- height = 16;
- ByteWidth = 2;
- l_pucFont = sucHzk16;
- l_pucLetter = 0;
- k=0;
- ret=guiGetHzk(hiByte,loByte,sucHzk16,fontMode);
- if(sizeof(sucHzk16)!=ret){//??¨?sFlash|ì?HZK16???t?D?¨¢¨¨??á??a¨oy?Y
- //?¨°2?|ì??á??a?ê???¨o?"?¨2"
- l_pucFont=g_apucCLetter16;
- MSG_ERR(1, "guiGetHzk16Err:%02x,%02x,%d",hiByte,loByte,ret);
- }
- }else if(fontMode==FONT_MODE_32X32){
- width=32;
- height = 32;
- ByteWidth = 4;
- l_pucFont = sucHzk32;
- l_pucLetter = 0;
- k=0;
- ret=guiGetHzk(hiByte,loByte,sucHzk32,fontMode);
- if(sizeof(sucHzk32)!=ret){//??¨?sFlash|ì?HZK16???t?D?¨¢¨¨??á??a¨oy?Y
- //?¨°2?|ì??á??a?ê???¨o?"?¨2"
- l_pucFont=g_apucCLetter16;
- MSG_ERR(1, "guiGetHzk32Err:%02x,%02x,%d",hiByte,loByte,ret);
- }
- }else if(fontMode==FONT_MODE_24X24){
-
- width=24;
- height = 24;
- ByteWidth = 3;
- l_pucFont = sucHzk24;
- l_pucLetter = 0;
- k=0;
- ret=guiGetHzk(hiByte,loByte,sucHzk24,fontMode);
- if(sizeof(sucHzk24)!=ret){//??¨?sFlash|ì?HZK16???t?D?¨¢¨¨??á??a¨oy?Y
- //?¨°2?|ì??á??a?ê???¨o?"?¨2"
- l_pucFont=g_apucCLetter16;
- MSG_ERR(1, "guiGetHzk24Err:%02x,%02x,%d",hiByte,loByte,ret);
- }
-
- }
-
- }
- //====================?¨′??|¨¤¨a|ì??¨?¨oy?Y==========
- if(y+height>GLCD_HEIGHT)return;
- if(x+width>GLCD_WIDTH)return;
- guiBlockSet(x,y,x+width-1,y+height-1);//
- fcolor=RGB888_2_RGB565(frontColorID);
- bcolor=RGB888_2_RGB565(backColorID);
- //¨°?????à?¨???|ì??¨???é|ì?LCD?ê?2?¨?????????ê¨??¨?¨22a¨o??ê??á?騰a|ì??¨??2?¨°a|ì??¨??PaintBufToLcd?ê??¤??¨°¨°2??é?¨¢¨¢?
- //?¨′?Y?á???ê?¨2??????D?-|ì?
- for(j=0;j<height;j++){
- m=y+j;
- for(i=0;i<ByteWidth;i++){
- n=x+i*8;
- data=*l_pucFont++;
- for(k=0;k<8;k++){
- if(data & (0x80>>k)){//??,??frontColorID
- if(REVERSED_NO==rev) guiDrawDot(fcolor);
- else guiDrawDot(bcolor);
- }else{//??,??backColorID
- if(REVERSED_NO==rev) guiDrawDot(bcolor);
- else guiDrawDot(fcolor);
- }
- }
- }
- }
- }
- short guiGetStrXLen(char *str, FONT_MODEENUM fontMode){
- unsigned char ch;
- unsigned short len=0;
- unsigned char bsize;
-
- bsize=16;
- while ((ch=*str++)){
- if(ch=='M')len+=16;
- else if(ch>='A'&&ch<='Z')len+=16;
- else if(ch>='a'&&ch<='z')len+=16;
- else if(ch>='0'&&ch<='9')len+=16;
- else if(ch>=0x20&& ch<=0x60)len+=16; //¨??¨oa?á??¤?
- else len+=bsize;
- }
- return len;
- }
- //ò????ó?ú??ía?a·?
- void guiShowStr(unsigned short x, unsigned short y,const char *string, FONT_MODEENUM fontMode,
- REV_ENUM rev, //????
- unsigned int frontColorID,//???
- unsigned int backColorID){//???
- unsigned char width1,width2,heigh;
- unsigned char *p;
- unsigned short i;
-
- if(fontMode==FONT_MODE_72X72){
- fontMode=FONT_MODE_24X24;
-
- }else{
- fontMode=FONT_MODE_32X32;
- }
-
-
- if(fontMode == FONT_MODE_16X16){
- width1 = 16;
- width2 = 1;
- heigh=16;
- }else if(fontMode == FONT_MODE_24X24){
- width1 = 24;
- width2 = 2;//1
- heigh=24;
- } else if(fontMode == FONT_MODE_32X32){
- width1 = 32;
- width2 = 2;
- heigh=32;
- }else return;
- p = (unsigned char *)string;
- i = 0;
-
- while(*p){
- if (*p > 0x80){//chinese letter
- guiShowChars(x+i,y,*p, *(p+1),fontMode,frontColorID,backColorID,rev);
- i += width1 ;
- p += 2;
- }else{//english letter
- guiShowChars(x + i,y,0,*p,fontMode,frontColorID,backColorID,rev);
- if(fontMode==FONT_MODE_16X16) i += width2 * 8;
- //else if(fontMode==FONT_MODE_32X32) i+=20;
- else i += width2 * 8;
- p ++;
- }
- }
- }
- void guiShowButton(unsigned short x, unsigned short y,const char *str, FONT_MODEENUM fontMode,unsigned int buttonColorID, unsigned int strColorID){
- int heigh,len;
-
- if(FONT_MODE_16X16==fontMode) heigh=12+4;
- else if(FONT_MODE_24X24==fontMode) heigh=16+4;
- else return;
- len=guiGetStrXLen((char *)str, fontMode);
- guiFillRect(x,y,x+len+8,y+heigh,buttonColorID);
- guiShowStr(x+4, y+1, str, fontMode,REVERSED_NO,strColorID,buttonColorID);
- }
- void guiFillRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2,unsigned int colorData){
- unsigned short x=x2,y=y2,w,h,i,m,k,j,data;
- if(x1>x2 || y1>y2) return;
- if(x1>=GLCD_WIDTH || y1>=GLCD_HEIGHT) return;
- if(x>GLCD_WIDTH) x=GLCD_WIDTH;
- if(y>GLCD_HEIGHT) y=GLCD_HEIGHT;
- w=x-x1+1;
- h=y-y1+1;
- data=RGB888_2_RGB565(colorData);
- guiBlockSet(x1,y1,x,y);
- for(i=0;i<h;i++){
- m=y1+i;
- for(j=0;j<w;j++){
- k=x1+j;
- guiDrawDot(data);
- }
- }
- }
- void guiClearRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned int colorData){
- guiFillRect(x1,y1,x2,y2,colorData);
- }
- //??????
- void guiDrawHLine(unsigned short x1, unsigned short x2, unsigned short y, unsigned short ysize, unsigned int colorID){
- if(ysize==0) return;
- if(x2<x1) return;
- guiFillRect(x1,y,x2,y+ysize-1,colorID);
- }
- //′1?±??
- void guiDrawVLine(unsigned short y1, unsigned short y2, unsigned short x, unsigned short xsize, unsigned int colorID){
- if(xsize==0) return;
- if(y2<y1) return;
- guiFillRect(x,y1,x+xsize-1,y2,colorID);
- }
- void guiDrawRect(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2,unsigned char width, unsigned int colorID){
- if(x1>x2||y1>y2) return;
- guiDrawHLine(x1,x2,y1,width,colorID);
- guiDrawHLine(x1,x2,y2,width,colorID);
- guiDrawVLine(y1,y2,x1,width,colorID);
- guiDrawVLine(y1,y2+width-1,x2,width,colorID);
- }
- //óé·??ò?aμ?(x,y)?aê??-
- void guiDrawArrow(unsigned short x, unsigned short y,unsigned short len, ARROW_ENUM direction, unsigned int colorID){
- unsigned short i;
- switch(direction){
- case ARROW_LEFT:
- for(i=0;i<len;i++) guiDrawRect(x+i,y-i,x+i,y+i,1,colorID);
- break;
- case ARROW_RIGHT:
- for(i=0;i<len;i++) guiDrawRect(x-i,y-i,x-i,y+i,1,colorID);
- break;
- case ARROW_UP:
- for(i=0;i<len;i++) guiDrawRect(x-i,y+i,x+i,y+i,1,colorID);
- break;
- case ARROW_DOWN:
- for(i=0;i<len;i++) guiDrawRect(x-i,y-i,x+i,y-i,1,colorID);
- break;
- }
- }
- static void guiFillBmpBuf(unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char *bmpBuf){
- int i,j,k,t;
- unsigned short RGB565,r,g,b;
- unsigned char R,G,B;
- for(j=0;j<height;j++){
- t=y+j;
- k=j*width;
- for(i=0;i<width;i++){
- R=bmpBuf[3*i];
- G=bmpBuf[3*i+1];
- B=bmpBuf[3*i+2];
- r=R>>3;
- g=G>>2;
- b=B>>3;
- RGB565=((r<<11)+(g<<5)+(b<<0));
- guiDrawDot(RGB565);
- }
- }
- }
- void guiShowBmp(unsigned short x, unsigned short y, char *bmp){
- int fd,l,w,i;
- unsigned short type;
- unsigned int width,height,bfOffBits;
- unsigned char tbuf[GLCD_WIDTH*4];
-
- fd=LSAPI_FS_Open(bmp, LSAPI_FS_O_RDONLY,0);
- if(fd<0){
- MSG_ERR(1, "%s open failed", bmp);
- return;
- }
- //?áè????tààDí
- LSAPI_FS_Seek(fd, 0x1c, LSAPI_FS_SEEK_SET);
- LSAPI_FS_Read(fd, (unsigned char *)&type, 2);
- if(type != 0x0018){
- MSG_ERR(1, "%s is not 24bits bmp",bmp);
- LSAPI_FS_Close(fd);
- return;
- }
- //?áè?í????í?è
- LSAPI_FS_Seek(fd, 0x12, LSAPI_FS_SEEK_SET);
- LSAPI_FS_Read(fd, (unsigned char *)&width, 4);
- //?áè?í??????è
- LSAPI_FS_Seek(fd, 0x16, LSAPI_FS_SEEK_SET);
- LSAPI_FS_Read(fd, (unsigned char *)&height, 4);
- //?D??3?′?
- if(width>GLCD_WIDTH || height>GLCD_HEIGHT){
- MSG_ERR(1, "%s size overflow",bmp);
- LSAPI_FS_Close(fd);
- return;
- }
-
- //?á3?êy?Y?eê?μ??·
- LSAPI_FS_Seek(fd, 0x0a, LSAPI_FS_SEEK_SET);
- LSAPI_FS_Read(fd, (unsigned char *)&bfOffBits, 4);
-
- l=width%4;
- w=width*3+l;
- l=height-1;
- guiBlockSet(x,y,x+width-1,y+height-1);//-1
- for(i=0;i<height;i++){
- LSAPI_FS_Seek(fd, bfOffBits+l*w, LSAPI_FS_SEEK_SET);
- LSAPI_FS_Read(fd, tbuf, w);
- guiFillBmpBuf(x,y+i,width,1,tbuf);
- l--;
- }
-
- LSAPI_FS_Close(fd);
- }
- /*?ó?D??ê?*/
- void guiShowCaption(unsigned short xType, const char *str, unsigned short y, unsigned int frontColorID, unsigned int backColorID, FONT_MODEENUM fontMode){
- int len,sy;
- unsigned short x;
- len=guiGetStrXLen((char *)str,fontMode);
- if(xType==0) x=(GLCD_WIDTH-len)/2;
- else x=xType;
- guiShowStr(x, y, str, fontMode, REVERSED_NO, frontColorID, backColorID);
- }
- void guiShowLefCaption(unsigned short xType, const char *str, unsigned short y, unsigned int frontColorID, unsigned int backColorID, FONT_MODEENUM fontMode){
- int len,sy;
- unsigned short x;
- if(strlen(str)>15){
- guiLefItem(0,UI_GROUP_SHOW_Y,frontColorID,backColorID,fontMode,str,1);
- }else{
- len=guiGetStrXLen((char *)str,fontMode);
- if(xType==0) x=(GLCD_WIDTH-len)/2;
- else x=xType;
- guiShowStr(x, y, str, fontMode, REVERSED_NO, frontColorID, backColorID);
- }
- }
- void guiClearArea(unsigned short x, unsigned short y, unsigned short width, unsigned short height,unsigned int colorID){
- guiFillRect(x,y,x+width,y+height,colorID);
- }
- void guiInit(void){
- g_backColor=COLOR_FOREGROUND;
- g_foreColor=COLOR_BACKGROUND;
-
- guiFillRect(0,0,GLCD_WIDTH-1,GLCD_HEIGHT-1,guiGetBackColor());
- if(sutApp.UserInfo.tnet==5) guiShowBmp(0,0,"/ext/prepack/welcome5.bmp");//开机图片
- else guiShowBmp(0,0,"/ext/prepack/welcome.bmp");//开机图片
- //LSAPI_OSI_ThreadSleep(2000);
- lcdBackLightApi(1);//清屏后打开,否则会看到关机前的画面
- }
- void guiClearAll(unsigned int colorID){//只清第二,三区
- guiFillRect(0, UI_STATUS_ITEM_Y, GLCD_WIDTH-1, UI_CONTENT_SHOW_Y-1, guiGetBackColor());//清除第二区
- guiFillRect(0,UI_CONTENT_SHOW_Y,GLCD_WIDTH-1,UI_LOCATION_SHOW_Y-1,colorID);
-
- }
- void guiShowMessageBox(char *msg){
- char buf[70];
- short len,x,y;
-
- y=GLCD_HEIGHT/2;
- guiClearRect(0,y-20,GLCD_WIDTH-1,y+BAR_HIGHT,guiGetBackColor()); //COLOR_RED
- guiDrawRect(2,y-18,GLCD_WIDTH-3,y+BAR_HIGHT,1,COLOR_SEL_BAR);
- StrIntercept(buf,msg,18);
- len=guiGetStrXLen(buf,FONT_MODE_16X16);
- x=(GLCD_WIDTH-len)/2;
- guiShowStr(x,y-8,buf,FONT_MODE_16X16,REVERSED_NO,COLOR_RED,guiGetBackColor());
-
- }
- void guiShowLocationPoint(signed short x1,signed short y1,signed short zerox2,signed short zeroy2,short angle, unsigned int colorID){
-
- signed short x=0,y=0;
- double r=0;
- static double tempangle=0;
- tempangle=rad(30);
-
- MSG_INFO(1,"tempangle===%lf",tempangle);
-
- #if 0
- /*
- //r=zeroy2-y1;//75
- r=75;
- x=r*cos(tempangle)+zerox2;
- y=r*sin(tempangle)+zeroy2;
- */
-
- x=(x1-zerox2)*cos(tempangle)-(y1-zeroy2)*sin(tempangle)+zerox2;
- y=(y1-zeroy2)*cos(tempangle)+(x1-zerox2)*sin(tempangle)+zeroy2;
- //120+ 75
- //157 +
- MSG_INFO(1,"X==%d,Y===%d,zerox2==%d,zeroy2==%d,r===%lf",x,y,zerox2,zeroy2,sin(tempangle));
- guiFillRect(x,y,x+5,y+5,colorID);
- #endif
- }
- //////////////////////////////////////测试接口///////////////////////////////////
- void guiTest(void){
- //return;
- //char testbuf[5]={0xB2,0xE2,0xCA,0xD4,0x00};
- //??ê?DD??
- guiDrawHLine(1, GLCD_WIDTH-2, 1, 1, guiGetForeColor());
- //??ê?áD??
- guiDrawVLine(3, GLCD_HEIGHT-2, 1, 1, guiGetForeColor());
- //??ê???D???D?
- guiDrawRect(3,3,3+10,3+10,1,guiGetForeColor());
- //??ê?êμD???D?
- guiFillRect(15, 3, 15+10, 3+10,guiGetForeColor());
- //??ê??yí·
- guiDrawArrow(50, 3,10, ARROW_UP, guiGetForeColor());
- guiDrawArrow(70, 3+10,10, ARROW_DOWN, guiGetForeColor());
- guiDrawArrow(90, 3+8,10, ARROW_LEFT, guiGetForeColor());
- guiDrawArrow(110, 3+8,10, ARROW_RIGHT, guiGetForeColor());
- //??ê?12X12×?·?′?
- guiShowStr(3, 30,"123测试45中,国AW", FONT_MODE_16X16, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
- //??ê?16X16×?·?′?
- guiShowStr(3, 50,"123测试45你。好AW", FONT_MODE_16X16, REVERSED_NO,guiGetForeColor(),guiGetBackColor());
- //??ê?í???
- guiShowBmp(3, 80, "Palace2.bmp");
- //??ê?°′?ü
- guiShowButton(100, 80,"B12", FONT_MODE_16X16,guiGetForeColor(), guiGetBackColor());
- }
|