?? ks0108.c
字號(hào):
ch_w=ASC_16[k].Msk[j];
ch_w=ch_w<<4;
ch_w|=ch_r;
SetPageCol(uPage,uCol+j);
if(uCol+j<64) write_LCD(LEFT,DATA,ch_w);
else write_LCD(RIGHT,DATA,ch_w);
}
SetPageCol(uPage+1,uCol);
for(j=0;j<width;j++)
{
SetPageCol(uPage+1,uCol+j);
ch_r=ASC_16[k].Msk[j];
ch_w=ASC_16[k].Msk[ASC_CHR_WIDTH+j];
ch_r=ch_r>>4;
ch_w=ch_w<<4;
ch_w|=ch_r;
SetPageCol(uPage+1,uCol+j);
if(uCol+j<64) write_LCD(LEFT,DATA,ch_w);
else write_LCD(RIGHT,DATA,ch_w);
}
}
}
SetPageCol(uPage,uCol+width);
}
void disp_hz(unsigned char *hz)
{
unsigned char k,j,uPage,uCol,ch_r,ch_w;
uPage = GetPage();
uCol = GetCol();
for(k=0;k<sizeof(GB_16)/sizeof(GB_16[0]);k++)
{
if(hz[0] == GB_16[k].Index[0] && hz[1] == GB_16[k].Index[1])
break;
}
if(CurOffset==1)
{
for(j=0;j<ASC_HZ_WIDTH;j++)
{
SetPageCol(uPage,uCol+j);
ch_w=GB_16[k].Msk[j];
if(uCol+j<64) write_LCD(LEFT,DATA,ch_w);
else write_LCD(RIGHT,DATA,ch_w);
}
SetPageCol(uPage+1,uCol);
for(j=0;j<ASC_HZ_WIDTH;j++)
{
SetPageCol(uPage+1,uCol+j);
if(uCol+j<64) ch_r=read_LCD(LEFT);
else ch_r=read_LCD(RIGHT);
ch_r&=0xf0;
ch_w=GB_16[k].Msk[ASC_HZ_WIDTH+j]&0x0f;
ch_w|=ch_r;
SetPageCol(uPage+1,uCol+j);
if(uCol+j<64) write_LCD(LEFT,DATA,ch_w);
else write_LCD(RIGHT,DATA,ch_w);
}
SetPageCol(uPage,uCol+ASC_HZ_WIDTH);
}
else //漢字上半部是寫半個(gè)字節(jié)
{
for(j=0;j<ASC_HZ_WIDTH;j++)
{
SetPageCol(uPage,uCol+j);
if(uCol+j<64) ch_r=read_LCD(LEFT);
else ch_r=read_LCD(RIGHT);
ch_r&=0x0f;
ch_w=GB_16[k].Msk[j];
ch_w=ch_w<<4;
ch_w|=ch_r;
SetPageCol(uPage,uCol+j);
if(uCol+j<64) write_LCD(LEFT,DATA,ch_w);
else write_LCD(RIGHT,DATA,ch_w);
}
SetPageCol(uPage+1,uCol);
for(j=0;j<ASC_HZ_WIDTH;j++)
{
SetPageCol(uPage+1,uCol+j);
ch_r=GB_16[k].Msk[j];
ch_w=GB_16[k].Msk[ASC_HZ_WIDTH+j];
ch_r=ch_r>>4;
ch_w=ch_w<<4;
ch_w|=ch_r;
SetPageCol(uPage+1,uCol+j);
if(uCol+j<64) write_LCD(LEFT,DATA,ch_w);
else write_LCD(RIGHT,DATA,ch_w);
}
SetPageCol(uPage,uCol+ASC_HZ_WIDTH);
}
}
void disp_str(unsigned char *p)
{
unsigned char i=0;
while(p[i]>0)
{
if(p[i] < 128)
{ /* ASCII */
disp_ch(p[i]);
}
else
{ /* 中文 */
disp_hz(&p[i]);
i++;
}
i++;
}
}
/*************************************/
/* 繪點(diǎn)函數(shù) */
/*************************************/
/* XX--(0-128) YY--(0-63) FLAG=1繪點(diǎn) FLAG=0 清點(diǎn) */
void pixel(unsigned char xx,unsigned char yy,unsigned char flag)
{
unsigned int y,ch;
ch=yy%8; //余數(shù)
y=1;
for(;ch!=0;)
{
y=y*2;
ch--;
}
if(xx<64)
{
set_page_L(yy/8);
set_col_addr_L(xx);
ch=read_LCD(LEFT);
set_col_addr_L(xx);
if(flag)
write_LCD(LEFT,DATA,ch|y);
else
{
y=~y;
ch&=y;
write_LCD(LEFT,DATA,ch|y);
}
}
else
{
set_page_R(yy/8);
set_col_addr_R(xx-64);
ch=read_LCD(RIGHT);
set_col_addr_R(xx-64);
if(flag)
write_LCD(RIGHT,DATA,ch|y);
else
{
y=~y;
ch&=y;
write_LCD(RIGHT,DATA,ch|y);
}
}
}
/*void point(void)
{
uchar x1, y1, y;
x1 = CurCol;
y1 = CurRow;
CurRow = y1 >> 3; //取Y方向分頁(yè)地址
Rddata(); // get cbyte on screen
y = y1 & 0x07; //字節(jié)內(nèi)位置計(jì)算
Wrdata(cbyte | (1 << y)); //畫上屏幕 /
CurCol = x1; ///恢復(fù)xy坐標(biāo) /
CurRow = y1;
} */
/************************************************/
/*畫圓。數(shù)學(xué)方程(X-Ox)^2+(Y-Oy)^2=Rx^2 */
/************************************************/
/*void circle(uchar Ox, uchar Oy, uchar Rx)
{
unsigned int xx, rr, xt, yt, rs;
yt = Rx;
rr = Rx * Rx + 1; //補(bǔ)償 1 修正方形
rs = (yt + (yt >> 1)) >> 1; //(*0.75)分開1/8圓弧來(lái)畫
for (xt = 0; xt <= rs; xt++)
{
xx = xt * xt;
while ((yt * yt) > (rr - xx))
yt--;
col = Ox + xt; //第一象限
row=Oy-yt;
point();
col = Ox - xt; //第二象限
point();
row = Oy + yt; //第三象限
point();
col = Ox + xt; //第四象限
point();
// ***************45度鏡象畫另一半***************
col = Ox + yt; //第一象限
row = Oy - xt;
point();
col = Ox - yt; //第二象限
point();
row = Oy + xt; //第三象限
point();
col = Ox + yt; //第四象限
point();
}
}
*/
/************************************************/
/*畫線。任意方向的斜線,直線數(shù)學(xué)方程 aX+bY=1 */
/************************************************/
/*void Linexy(uchar x0,uchar y0,uchar xt,uchar yt)
{
uchar t;
int xerr = 0, yerr = 0, delta_x, delta_y, distance;
int incx, incy;
delta_x = xt - x0; // 計(jì)算坐標(biāo)增量
delta_y = yt - y0;
col = x0;
row = y0;
if (delta_x > 0)
{
incx = 1; // 水平+方向
}
else if (delta_x == 0 )
{
incx = 0; // 垂直線
}
else
{
incx =- 1; //水平負(fù)方向
delta_x =- delta_x;
}
if (delta_y > 0)
{
incy = 1; // 垂直+方向
}
else
if (delta_y == 0)
{
incy = 0; // 水平線
}
else
{
incy =- 1; //垂直-方向
delta_y =- delta_y;
}
if (delta_x > delta_y)
distance = delta_x; //選取基本增量坐標(biāo)軸
else
distance = delta_y;
for (t = 0; t <= distance + 1; t++)
{ // 畫線輸出
point(); // 畫點(diǎn)
xerr += delta_x;
yerr += delta_y;
if (xerr > distance)
{
xerr -= distance;
col += incx;
}
if (yerr > distance)
{
yerr -= distance;
row += incy;
}
}
}
*/
void Linexy(uchar x0,uchar y0,uchar xt,uchar yt,uchar s)
{
register uchar t;
int xerr=0,yerr=0,delta_x,delta_y,distance;
int incx,incy,uRow,uCol;
delta_x = xt-x0; //計(jì)算坐標(biāo)增量
delta_y = yt-y0;
uRow = x0;
uCol = y0;
if(delta_x>0) incx=1; //設(shè)置單步方向
else if( delta_x==0 ) incx=0; //垂直線
else {incx=-1;delta_x=-delta_x;}
if(delta_y>0) incy=1;
else if( delta_y==0 ) incy=0; //水平線
else {incy=-1;delta_y=-delta_y;}
if( delta_x > delta_y ) distance=delta_x; //選取基本增量坐標(biāo)軸
else distance=delta_y;
for( t=0;t <= distance+1; t++ )
{ //畫線輸出
pixel(uRow,uCol,s); //畫點(diǎn)
xerr += delta_x ;
yerr += delta_y ;
if( xerr > distance )
{
xerr-=distance;
uRow+=incx;
}
if( yerr > distance )
{
yerr-=distance;
uCol+=incy;
}
}
}
/************************************************/
/*畫圓。數(shù)學(xué)方程(X-Ox)^2+(Y-Oy)^2=Rx^2 */
/************************************************/
void circle(uchar Ox,uchar Oy,uchar Rx,uchar s)
{
unsigned int xx,rr,xt,yt,rs,row,col;
yt=Rx;
rr=Rx*Rx+1; //補(bǔ)償 1 修正方形
rs=(yt+(yt>>1))>>1; //(*0.75)分開1/8圓弧來(lái)畫
for (xt=0;xt<=rs;xt++)
{
xx=xt*xt;
while ((yt*yt)>(rr-xx))yt--;
row=Ox+xt; //第一象限
col=Oy-yt;
pixel(row,col,s);
row=Ox-xt; //第二象限
pixel(row,col,s);
col=Oy+yt; //第三象限
pixel(row,col,s);
row=Ox+xt; //第四象限
pixel(row,col,s);
/***************45度鏡象畫另一半***************/
row=Ox+yt; //第一象限
col=Oy-xt;
pixel(row,col,s);
row=Ox-yt; //第二象限
pixel(row,col,s);
col=Oy+xt; //第三象限
pixel(row,col,s);
row=Ox+yt; //第四象限
pixel(row,col,s);
}
}
void delay(int tt)
{
int i;
int j;
while((j++)>1000000)
{
for(i=0;i<tt;i++)
{
NOP();
}
}
}
void main()
{
unsigned int i;
//init_port();//自己加,主要是控制線所在端口為輸出
DDRB = 0xff;
init_lcd();
SetRowCol(1,0);
disp_str("液晶顯示的第1行");
SetRowCol(2,0);
disp_str("液晶顯示的第2行");
SetRowCol(3,0);
disp_str("液晶顯示的第3行");
SetRowCol(4,0);
disp_str("液晶顯示的第4行");
SetRowCol(5,0);
disp_str("液晶顯示的第5行");
//clr_lcd();
//for(i=0;i<64;i++) pixel(127,i,1);
//for(i=0;i<64;i++) pixel(0,i,1);
//for(i=0;i<128;i++) pixel(i,0,1);
//for(i=0;i<128;i++) pixel(i,63,1);
//for(i=0;i<40;i++)
//{
//circle(20,45,i,1); // 畫圓
//}
while(1);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -