//在指定位置显示一个字符 //num:要显示的字符:" "--->"~" //mode:叠加方式(1)还是非叠加方式(0) //在指定位置显示一个字符 //num:要显示的字符:" "--->"~" //mode:叠加方式(1)还是非叠加方式(0) void LCD_ShowChar(unsigned int x,unsigned int y,unsigned char num,unsigned char mode) { unsigned char temp; unsigned char pos,t; unsigned int x0=x; unsigned int colortemp=POINT_COLOR; if(x>LCD_W-16||y>LCD_H-16)return; //设置窗口 num=num-' ';//得到偏移后的值 Address_set(x,y,x+8-1,y+16-1); //设置光标位置 if(!mode) //非叠加方式 { for(pos=0;pos<16;pos++) { temp=asc2_1608[(unsigned int )num*16+pos]; //调用1608字体 for(t=0;t<8;t++) { if(temp&0x01)POINT_COLOR=colortemp; else POINT_COLOR=BACK_COLOR; LCD_WRITE_DATA(POINT_COLOR); temp>>=1; x++; } x=x0; y++; } }else//叠加方式 { for(pos=0;pos<16;pos++)
//写入 单个字符 //在指定位置显示一个字符(8*12大小) //dcolor为内容颜色,gbcolor为背静颜色 void showzifu(unsigned int x,unsigned int y,unsigned char value,unsigned int dcolor,unsigned int bgcolor) { unsigned char i,j; unsigned int temp=0; LCD_CS_0; Address_set(x,y,x+7,y+11); //设置区域 temp+=(value-32)*12; //确定要显示的值 //这里用的是ascii表 前32个ascii没有存入zifu库里 所以要减32 //并且 每个字符用12个字节显示 所以再乘以12 就是对应的显示位的首地址 for(j=0;j<12;j++) { for(i=0;i<8;i++) //先横扫 { if((zifu[temp]&(1<<(7-i)))!=0) //将1 左移 然后对应位进行相与 { Lcd_Write_Data(dcolor); //Draw_Point(x+i,y+j,dcolor); } else { Lcd_Write_Data(bgcolor); //Draw_Point(x+i,y+j,bgcolor); } } temp++; } LCD_CS_1; }
void Draw_Point(unsigned int x,unsigned int y,unsigned int color) { LCD_CS_0; Address_set(x,y,x,y); Lcd_Write_Data(color); LCD_CS_1; }
int Red_pix(unsigned int x,unsigned int y) { int data=0; Address_set(x,y,x,y); data=DATA; // data=DATA; return data; }
void LCD_TEST_SingleColor (uint8_t h,uint8_t l) { int i, j; Address_set (0,239,0,319); for (i=0;i<320; i++) for (j = 0;j<240;j++) wr_com16(h,l); }
void tftDrawPixel(uint16_t x, uint16_t y) { CS_LOW; Address_set(x, y, x, y); Lcd_Write_Data(strokeColor >> 8); Lcd_Write_Data(strokeColor); CS_HIGH; }
//在指定区域内填充指定颜色 //区域大小: // (xend-xsta)*(yend-ysta) void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color) { u16 i,j; Address_set(xsta,ysta,xend,yend); //设置光标位置 for(i=ysta; i<=yend; i++) { for(j=xsta; j<=xend; j++)LCD_WR_DATA(color); //设置光标位置 } }
//在指定区域内填充指定颜色 //区域大小: // (xend-xsta)*(yend-ysta) void LCD_Fill(unsigned int xsta,unsigned int ysta,unsigned int xend,unsigned int yend,unsigned int color) { unsigned int i,j; Address_set(xsta,ysta,xend,yend); //设置光标位置 for(i=ysta;i<=yend;i++) { for(j=xsta;j<=xend;j++) LCD_WRITE_DATA(color);//设置光标位置 } }
void tftVLine(uint16_t x, uint16_t y, uint16_t l) { CS_LOW; Address_set(x, y, x, y+l-1); for(int i = 0; i < l; i++) { Lcd_Write_Data(strokeColor >> 8); Lcd_Write_Data(strokeColor); } CS_HIGH; }
//清屏函数 //Color:要清屏的填充色 void LCD_Clear(unsigned int Color) { unsigned int i,j; Address_set(0,0,LCD_W-1,LCD_H-1); for(i=0;i<LCD_W;i++) { for (j=0;j<LCD_H;j++) { LCD_WRITE_DATA(Color); } } }
void Draw_CC(unsigned int x,unsigned int y,unsigned char num, unsigned int dcolor, unsigned int bgcolor)//写汉字 { unsigned int i,j; LCD_CS_0; Address_set(x,y,x+16-1,y+16-1); for( j=0; j<32 ; j++) for( i=0; i<8; i++) { if ((CC[num][j] & (1<<(7-i)))!=0) Lcd_Write_Data(dcolor); else Lcd_Write_Data(bgcolor); } LCD_CS_1; }
void Pant(unsigned int color) { int i,j; Address_set(0,0,MAX_W-1,MAX_H-1); for(i=0;i<MAX_W;i++) { for (j=0;j<MAX_H;j++) { DATA=color; } } }
void Fill_Window(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2,unsigned int color) { int i,j,it,jt; it=x2-x1; jt=y2-y1; LCD_CS_0; Address_set(x1,y1,x2,y2); for(i=0;i<=it;i++) { for (j=0;j<=jt;j++) { Lcd_Write_Data(color); } } LCD_CS_1; }
//清屏函数 //Color:要清屏的填充色 void LCD_Clear(u16 Color) { u8 VH,VL; u16 i,j; VH=Color>>8; VL=Color; Address_set(0,0,LCD_W-1,LCD_H-1); for(i=0; i<LCD_W; i++) { for (j=0; j<LCD_H; j++) { LCD_WR_DATA8(VH); LCD_WR_DATA8(VL); } } }
void tftBltMask(const uint8_t* source, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t col) { CS_LOW; const uint16_t* source16 = (const uint16_t*) source; Address_set(x, y, x+w-1, y+h-1); for(int i = 0; i < h; i++) { for(int m = 0; m < w; m++) { // x direction if (*source16++) { // white pixel in mask gets background color Lcd_Write_Data(BLACK>>8); Lcd_Write_Data(BLACK); } else { // non-white pixels in mask get given color Lcd_Write_Data(col>>8); Lcd_Write_Data(col); } }
void tftRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { if (fill) { CS_LOW; Address_set(x, y, x+w-1, y+h-1); for(int i = 0; i < h; i++) { for(int m = 0; m < w; m++) { Lcd_Write_Data(fillColor >> 8); Lcd_Write_Data(fillColor); } } CS_LOW; } if (stroke) { tftHLine(x , y , w); tftHLine(x , y+h-1, w); tftVLine(x , y , h); tftVLine(x+w-1, y , h); } }
void Pant_pix(unsigned int x,unsigned int y,unsigned int color) { Address_set(x,y,x,y); DATA=color; }
//画点 //POINT_COLOR:此点的颜色 void LCD_DrawPoint(unsigned int x,unsigned int y) { Address_set(x,y,x,y);//设置光标位置 LCD_WRITE_DATA(POINT_COLOR); }
//画点 //POINT_COLOR:此点的颜色 void LCD_DrawPoint(u16 x,u16 y) { Address_set(x,y,x,y);//设置光标位置 LCD_WR_DATA(POINT_COLOR); }