?? lcd_dis.c
字號:
//========================================================================
// 文件名: LCD_Dis.c
// 作 者: kaka.IN Hisense
// sn.kaka@yahoo.com
// 日 期: 2007/01/07
// 描 述: 通用版LCD用戶接口層程序集
//
// 參 考: 請參考具體顯示器的硬件描述說明書或者是DataSheet,并以此來編寫加速
// 版接口程序;適用于16位MCU
// 版 本:
// 2006/10/18 First version Mz Design
// 2007/01/13 V1.1 去掉坐標體系變換的功能,對速度進行一定的優化
// 并使該文件的代碼更加通用于各種LCD
//========================================================================
#include "LCD_Driver_User.h" //LCD底層驅動聲明頭文件
#include "LCD_Config.h" //LCD的配置文件,比如坐標軸是否倒置等的定義
#define Dis_Zero 0
//extern unsigned int Asii8[]; //6X8的ASII字符庫
extern const unsigned int Asii0610[]; //6X10的ASII字符庫
extern const unsigned int Asii0816[]; //8X16的ASII字符庫
extern const unsigned int GB1716[]; //32*32自定義的漢字庫
extern const unsigned int AsiiA[];
int X_Witch; //字符寫入時的寬度
int Y_Witch; //字符寫入時的高度
int Font_Wrod; //字體的每個字模占用多少個存儲單元數
unsigned int *Char_TAB; //字庫指針
int Plot_Mode; //繪圖模式
unsigned int BMP_Color;
unsigned int Char_Color;
//void Pos_Switch(unsigned int * x,unsigned int * y);
//void Writ_Dot(int x,int y,unsigned int Color);
//========================================================================
// 函數: void FontSet(int Font_NUM,unsigned int Color)
// 描述: 文本字體設置
// 參數: Font_NUM 字體選擇,以驅動所帶的字庫為準
// Color 文本顏色,僅作用于自帶字庫
// 返回: 無
// 備注:
// 版本:
// 2006/10/15 First version
//========================================================================
void FontSet(int Font_NUM,unsigned int Color)
{
switch(Font_NUM)
{
case 0: Font_Wrod = 8; //ASII字符A
X_Witch = 16;//X_Witch = 8;
Y_Witch = 16;
Char_Color = Color;
Char_TAB = (unsigned int *)(Asii0816 - 32*8);
break;
case 1: Font_Wrod = 5; //ASII字符B
X_Witch = 6;
Y_Witch = 10;
Char_Color = Color;
Char_TAB = (unsigned int *)(Asii0610 - (32*5));
break;
case 2: Font_Wrod = 24; //漢字A
X_Witch = 17;
Y_Witch = 16;
Char_Color = Color;
Char_TAB = (unsigned int *)GB1716;
break;
case 3: Font_Wrod = 0;
X_Witch = 8;
Y_Witch = 16;
Char_Color = Color;
Char_TAB = (unsigned int *)AsiiA;
break;
default: break;
}
// if(X_Witch&0x07) X_Witch = (X_Witch&0xfff8)+0x0008; //調整寬度到8的倍數
}
//========================================================================
// 函數: void PutChar(int x,int y,unsigned int a)
// 描述: 寫入一個標準字符
// 參數: x X軸坐標 y Y軸坐標
// a 要顯示的字符在字庫中的偏移量
// 返回: 無
// 備注: ASCII字符可直接輸入ASCII碼即可
// 版本:
// 2006/10/15 First version
// 2007/01/11 V1.1
//========================================================================
void PutChar(int x,int y,unsigned int a)
{
int i,j;//,K; //數據暫存
unsigned int *p_data; //unsigned char *p_data;
unsigned int Temp; //unsigned char Temp;
unsigned int Index = 0;
p_data = Char_TAB + a*Font_Wrod; /*要寫字符的首地址*/
j = 0;
while((j ++) < Y_Witch)
{
if(y > Dis_Y_MAX) break;
i = 0;
while(i < X_Witch)
{
if((i&0x07)==0)
{
Temp = *(p_data + (Index>>1));
if((Index&0x01)==0)Temp = Temp>>8;
Index++;
}
// K = 0;
if((Temp & 0x80) > 0) Write_Dot_LCD/*Writ_Dot*/(x+i,y,Char_Color);
Temp = Temp << 1;
if((x+i) >= Dis_X_MAX)
{
Index += (X_Witch-i)>>3;
break;
}
i++;
}
y ++;
}
}
/*下面的為字模測試的時候所用到的函數*/
void PutChar_T(int x,int y,unsigned int a)
{
int i,j;//,K; //數據暫存
unsigned int *p_data; //unsigned char *p_data;
unsigned int Temp; //unsigned char Temp;
unsigned int Index = 0;
p_data = Char_TAB + a*Font_Wrod; /*要寫字符的首地址*/
j = 0;
while((j ++) < Y_Witch)
{
if(y > Dis_Y_MAX) break;
i = 0;
while(i < X_Witch)
{
if((i&0x07)==0)
{
Temp = *(p_data + Index);
//if((Index&0x01)==0)Temp = Temp>>8;
Index++;
}
// K = 0;
if((Temp & 0x80) > 0) Write_Dot_LCD/*Writ_Dot*/(x+i,y,Char_Color);
Temp = Temp << 1;
//if((x+i) >= Dis_X_MAX)
//{
// Index += (X_Witch-i)>>3;
// break;
//}
i++;
}
y ++;
}
}
//========================================================================
// 函數: void PutString(int x,int y,char *p)
// 描述: 在x、y為起始坐標處寫入一串標準字符
// 參數: x X軸坐標 y Y軸坐標
// p 要顯示的字符串
// 返回: 無
// 備注: 僅能用于自帶的ASCII字符串顯示
// 版本:
// 2006/10/15 First version
//========================================================================
void PutString(int x,int y,char *p)
{
while(*p!=0)
{
PutChar(x,y,*p);
x += X_Witch;
if((x + X_Witch) > Dis_X_MAX)
{
x = Dis_Zero;
if((Dis_Y_MAX - y) < Y_Witch) break;
else y += Y_Witch;
}
p++;
}
}
/*
//========================================================================
// 函數: void Bitmap(unsigned int *p,int x,int y)
// 描述: 寫入一個BMP圖片,起點為(x,y)
// 參數:
// 返回: 無
// 備注:
// 版本:
// 2006/10/15 First version
//========================================================================
void Bitmap(int x,int y,unsigned int *p)
{
int Temp_With,Temp_High,i,j; //數據暫存
unsigned int Temp;
unsigned int Index=0;
Temp_High = *p&0x00ff;
Temp_With = *(p ++)>>8; //圖片寬度
j = 0;
while((j ++) < Temp_High)
{
if(y > Dis_Y_MAX) break;
i = 0;
while(i < Temp_With)
{
Index++;
if((Index&0x0f)==0)
{
Temp = *(p++);
}
if((x+i) > Dis_X_MAX) break;
if(Temp&0x8000) Write_Dot_LCD(x+i,y,Char_Color);
Temp = Temp << 1;
i++;
}
y ++;
}
}
*/
//========================================================================
// 函數: void SetPaintMode(int Mode,unsigned int Color)
// 描述: 繪圖模式設置
// 參數: Mode 繪圖模式 Color 像素點的顏色,相當于前景色
// 返回: 無
// 備注: Mode無效
// 版本:
// 2006/10/15 First version
//========================================================================
void SetPaintMode(int Mode,unsigned int Color)
{
Plot_Mode = Mode;
BMP_Color = Color;
}
//========================================================================
// 函數: void PutPixel(int x,int y)
// 描述: 在x、y點上繪制一個前景色的點
// 參數: x X軸坐標 y Y軸坐標
// 返回: 無
// 備注: 使用前景色
// 版本:
// 2006/10/15 First version
//========================================================================
void PutPixel(int x,int y)
{
Write_Dot_LCD/*Writ_Dot*/(x,y,BMP_Color);
}
//========================================================================
// 函數: void Line(int s_x,int s_y,int e_x,int e_y)
// 描述: 在s_x、s_y為起始坐標,e_x、e_y為結束坐標繪制一條直線
// 參數: x X軸坐標 y Y軸坐標
// 返回: 無
// 備注: 使用前景色
// 版本:
// 2006/10/15 First version
//========================================================================
void Line(int s_x,int s_y,int e_x,int e_y)
{
int Offset_x,Offset_y,Offset_k = 0;
int Err_d = 1;
if(s_y>e_y)
{
Offset_x = s_x;
s_x = e_x;
e_x = Offset_x;
Offset_x = s_y;
s_y = e_y;
e_y = Offset_x;
}
Offset_x = e_x-s_x;
Offset_y = e_y-s_y;
Write_Dot_LCD/*Writ_Dot*/(s_x,s_y,BMP_Color);
if(Offset_x<=0)
{
Offset_x = s_x-e_x;
Err_d = -1;
}
if(Offset_x>Offset_y)
{
while(s_x!=e_x)
{
if(Offset_k>0)
{
s_y+=1;
Offset_k += (Offset_y-Offset_x);
}
else Offset_k += Offset_y;
s_x+=Err_d;
if(s_x>LCD_X_MAX||s_y>LCD_Y_MAX) break;
Write_Dot_LCD/*Writ_Dot*/(s_x,s_y,BMP_Color);
}
}
else
{
while(s_y!=e_y)
{
if(Offset_k>0)
{
s_x+=Err_d;
Offset_k += (Offset_x-Offset_y);
}
else Offset_k += Offset_x;
s_y+=1;
if(s_x>=LCD_X_MAX||s_y>=LCD_Y_MAX) break;
Write_Dot_LCD/*Writ_Dot*/(s_x,s_y,BMP_Color);
}
}
}
/*
//========================================================================
// 函數: void W_DB_Line(int *p)
// 描述: 畫一個任意多邊形
// 參數: p
// 返回: 該函數無效
// 備注: 使用前景色
// 版本:
// 2006/10/15 First version
//========================================================================
void W_DB_Line(int *p)
{
int Dot_sun,i;
Dot_sun = *p++;
i = 0;
while((i ++) < Dot_sun)
{
W_line((*p >> 8)&0xff,*(p + 1)&0xff,(*(p + 1)>>8)&0xff,*(p + 1)&0xff);
p += 1;
}
}*/
//========================================================================
// 函數: void W_Red_Dot(int x,int y,int a,int b,int mode)
// 描述: 繪制圓的各個像限中的點和線
// 參數:
// 返回: 無
// 備注: 該函數對用戶不可見,使用前景色
// 版本:
// 2006/10/15 First version
//========================================================================
void W_Red_Dot(int x,int y,int a,int b,int mode)
{
if(mode > 0)
{
Line(x+a,y+b,x-a,y+b);
Line(x+a,y-b,x-a,y-b);
}
else
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -