|
这程序在并口下都是正常的,但在串口下画垂直线和斜线都是正常的但画水平线就不正常,串口下只用2根线与单片机链接!!!
void drawPoint(unsigned char x,unsigned char y,unsigned char color)
{
unsigned char row,collum,cbite;
unsigned char tempH,tempL;
Write_Cmd(0x34);
Write_Cmd(0x36);
collum=x>>4;
cbite=x&0x0f;
if(y<32)
row=y;
else
{row=y-32;
collum+=8;
}
Write_Cmd(0x80+row);
Write_Cmd(0x80+collum);
ReceiveByte();
tempH=ReceiveByte();
tempL=ReceiveByte();
Write_Cmd(0x80+row);
Write_Cmd(0x80+collum);
if (color)
{
if(cbite<8)
{
tempH|=(1<<(7-cbite));
//tempL=(1<<(7-cbite));
}
else
{
//tempH=(1<<(15-cbite));
tempL|=(1<<(15-cbite));
}
}
else
{
if(cbite<8)
{
tempH&=~(1<<(7-cbite));
//tempL=(1<<(7-cbite));
}
else
{
//tempH=(1<<(15-cbite));
tempL&=~(1<<(15-cbite));
}
}
Write_Data(tempH);
Write_Data(tempL);
Write_Cmd(0x30);
}
void drawRowLine(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char color)
{
unsigned char temp;
if(x0>x1) // 对x0、x1大小进行排列,以便画图
{
temp = x1;
x1 = x0;
x0 = temp;
}
while(x1>=x0)
{
drawPoint(x0, y0, color); // 逐点显示,描出垂直线
x0++;
}
}
/***********************************************************
函数名: drawCollumLine
函数说明:画竖直线
传入参数:(x0,y0),竖直线的起点;(x1,y0)竖直线的终点;
color=1,点亮;color=0,擦除
传出参数:无
返回值: 无
************************************************************/
void drawCollumLine(unsigned char x0,unsigned char y0,unsigned char y1,unsigned char color)
{
unsigned char temp;
if(y0>y1)
{
temp=y0;
y0=y1;
y1=temp;
}
while (y0<=y1)
{
drawPoint(x0,y0,color);
y0++;
}
}
|
|