#include "stm32f10x.h" #include "Lcd_Driver.h" #include "GUI.h" #include "delay.h" #include "font.h" //��ILI93xx����������ΪGBR��ʽ��������д���ʱ��ΪRGB��ʽ�� //ͨ���ú���ת�� //c:GBR��ʽ����ɫֵ //����ֵ��RGB��ʽ����ɫֵ u16 LCD_BGR2RGB(u16 c) { u16 r,g,b,rgb; b=(c>>0)&0x1f; g=(c>>5)&0x3f; r=(c>>11)&0x1f; rgb=(b<<11)+(g<<5)+(r<<0); return(rgb); } void Gui_Circle(u16 X,u16 Y,u16 R,u16 fc) {//Bresenham�㷨 unsigned short a,b; int c; a=0; b=R; c=3-2*R; while (a=0) { x_inc = 1; } else { x_inc = -1; dx = -dx; } if (dy>=0) { y_inc = 1; } else { y_inc = -1; dy = -dy; } dx2 = dx << 1; dy2 = dy << 1; if (dx > dy)//x�������y���룬��ôÿ��x����ֻ��һ���㣬ÿ��y���������ɸ��� {//���ߵĵ�������x���룬��x��������� // initialize error term error = dy2 - dx; // draw the line for (index=0; index <= dx; index++)//Ҫ���ĵ������ᳬ��x���� { //���� Gui_DrawPoint(x0,y0,Color); // test if error has overflowed if (error >= 0) //�Ƿ���Ҫ����y����ֵ { error-=dx2; // move to next line y0+=y_inc;//����y����ֵ } // end if error overflowed // adjust the error term error+=dy2; // move to the next pixel x0+=x_inc;//x����ֵÿ�λ���󶼵���1 } // end for } // end if |slope| <= 1 else//y�����x�ᣬ��ÿ��y����ֻ��һ���㣬x�����ɸ��� {//��y��Ϊ�������� // initialize error term error = dx2 - dy; // draw the line for (index=0; index <= dy; index++) { // set the pixel Gui_DrawPoint(x0,y0,Color); // test if error overflowed if (error >= 0) { error-=dy2; // move to next line x0+=x_inc; } // end if error overflowed // adjust the error term error+=dx2; // move to the next pixel y0+=y_inc; } // end for } // end else |slope| > 1 } void Gui_box(u16 x, u16 y, u16 w, u16 h,u16 bc) { Gui_DrawLine(x,y,x+w,y,0xEF7D); Gui_DrawLine(x+w-1,y+1,x+w-1,y+1+h,0x2965); Gui_DrawLine(x,y+h,x+w,y+h,0x2965); Gui_DrawLine(x,y,x,y+h,0xEF7D); Gui_DrawLine(x+1,y+1,x+1+w-2,y+1+h-2,bc); } void Gui_box2(u16 x,u16 y,u16 w,u16 h, u8 mode) { if (mode==0) { Gui_DrawLine(x,y,x+w,y,0xEF7D); Gui_DrawLine(x+w-1,y+1,x+w-1,y+1+h,0x2965); Gui_DrawLine(x,y+h,x+w,y+h,0x2965); Gui_DrawLine(x,y,x,y+h,0xEF7D); } if (mode==1) { Gui_DrawLine(x,y,x+w,y,0x2965); Gui_DrawLine(x+w-1,y+1,x+w-1,y+1+h,0xEF7D); Gui_DrawLine(x,y+h,x+w,y+h,0xEF7D); Gui_DrawLine(x,y,x,y+h,0x2965); } if (mode==2) { Gui_DrawLine(x,y,x+w,y,0xffff); Gui_DrawLine(x+w-1,y+1,x+w-1,y+1+h,0xffff); Gui_DrawLine(x,y+h,x+w,y+h,0xffff); Gui_DrawLine(x,y,x,y+h,0xffff); } } /************************************************************************************** ��������: ����Ļ��ʾһ͹��İ�ť�� �� ��: u16 x1,y1,x2,y2 ��ť�����ϽǺ����½����� �� ��: �� **************************************************************************************/ void DisplayButtonDown(u16 x1,u16 y1,u16 x2,u16 y2) { Gui_DrawLine(x1, y1, x2,y1, GRAY2); //H Gui_DrawLine(x1+1,y1+1,x2,y1+1, GRAY1); //H Gui_DrawLine(x1, y1, x1,y2, GRAY2); //V Gui_DrawLine(x1+1,y1+1,x1+1,y2, GRAY1); //V Gui_DrawLine(x1, y2, x2,y2, WHITE); //H Gui_DrawLine(x2, y1, x2,y2, WHITE); //V } /************************************************************************************** ��������: ����Ļ��ʾһ���µİ�ť�� �� ��: u16 x1,y1,x2,y2 ��ť�����ϽǺ����½����� �� ��: �� **************************************************************************************/ void DisplayButtonUp(u16 x1,u16 y1,u16 x2,u16 y2) { Gui_DrawLine(x1, y1, x2,y1, WHITE); //H Gui_DrawLine(x1, y1, x1,y2, WHITE); //V Gui_DrawLine(x1+1,y2-1,x2,y2-1, GRAY1); //H Gui_DrawLine(x1, y2, x2,y2, GRAY2); //H Gui_DrawLine(x2-1,y1+1,x2-1,y2, GRAY1); //V Gui_DrawLine(x2 ,y1 ,x2,y2, GRAY2); //V } void Gui_DrawFont_GBK16(u16 x, u16 y, u16 fc, u16 bc, u8 *s) { unsigned char i,j; unsigned short k,x0; x0=x; while(*s) { if((*s) < 128) { k=*s; if (k==13) { x=x0; y+=16; } else { if (k>32) k-=32; else k=0; for(i=0;i<16;i++) for(j=0;j<8;j++) { if(asc16[k*16+i]&(0x80>>j)) Gui_DrawPoint(x+j,y+i,fc); else { if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc); } } x+=8; } s++; } else { for (k=0;k>j)) Gui_DrawPoint(x+j,y+i,fc); else { if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc); } } for(j=0;j<8;j++) { if(hz16[k].Msk[i*2+1]&(0x80>>j)) Gui_DrawPoint(x+j+8,y+i,fc); else { if (fc!=bc) Gui_DrawPoint(x+j+8,y+i,bc); } } } } } s+=2;x+=16; } } } void Gui_DrawFont_GBK24(u16 x, u16 y, u16 fc, u16 bc, u8 *s) { unsigned char i,j; unsigned short k; while(*s) { if( *s < 0x80 ) { k=*s; if (k>32) k-=32; else k=0; for(i=0;i<16;i++) for(j=0;j<8;j++) { if(asc16[k*16+i]&(0x80>>j)) Gui_DrawPoint(x+j,y+i,fc); else { if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc); } } s++;x+=8; } else { for (k=0;k>j)) Gui_DrawPoint(x+j,y+i,fc); else { if (fc!=bc) Gui_DrawPoint(x+j,y+i,bc); } } for(j=0;j<8;j++) { if(hz24[k].Msk[i*3+1]&(0x80>>j)) Gui_DrawPoint(x+j+8,y+i,fc); else { if (fc!=bc) Gui_DrawPoint(x+j+8,y+i,bc); } } for(j=0;j<8;j++) { if(hz24[k].Msk[i*3+2]&(0x80>>j)) Gui_DrawPoint(x+j+16,y+i,fc); else { if (fc!=bc) Gui_DrawPoint(x+j+16,y+i,bc); } } } } } s+=2;x+=24; } } } void Gui_DrawFont_Num32(u16 x, u16 y, u16 fc, u16 bc, u16 num) { unsigned char i,j,k,c; //lcd_text_any(x+94+i*42,y+34,32,32,0x7E8,0x0,sz32,knum[i]); // w=w/8; for(i=0;i<32;i++) { for(j=0;j<4;j++) { c=*(sz32+num*32*4+i*4+j); for (k=0;k<8;k++) { if(c&(0x80>>k)) Gui_DrawPoint(x+j*8+k,y+i,fc); else { if (fc!=bc) Gui_DrawPoint(x+j*8+k,y+i,bc); } } } } }