📄 lcd.cpp
字号:
do
{
Point(x0,y0,color);
x0++;
}while(x1>x0);
}
void LCD::RLine(uchar x0, uchar y0, uchar y1, TCOLOR color)
/****************************************************************************
* 名称:RLine()
* 功能:画垂直线。
* 入口参数: x0 垂直线起点所在列的位置
* y0 垂直线起点所在行的位置
* y1 垂直线终点所在行的位置
* color 显示颜色(对于黑白色LCM,为0时灭,为1时显示)
* 出口参数:无
* 说明:操作失败原因是指定地址超出缓冲区范围。
****************************************************************************/
{
uchar bak;
uchar wr_dat;
if(y0>y1) //对y0,y1大小进行排列,以便画图
{
bak = y1;
y1 = y0;
y0 = bak;
}
do
{
/* 先读取当前点的字节数据 */
bak = Rbyt(x0,y0);
/* 进行"与"/"或"操作后,将正确的数据写回LCM
若y0和y1不是同一字节,则y0--当前字节结束,即(y0+8)&0x38,全写1,或者0.
若y0和y1是同一字节,则y0--y1,要全写1,或者0.
方法:dat = 0xff,然后y0清零dat低位,按y1清零高位.*/
if((y0>>3)!=(y1>>3))
{
wr_dat = 0xff<<(y0&0x07); //清0低位
if(color)
{
wr_dat = bak|wr_dat; //若color不为0,则显示
}
else
{
wr_dat = ~wr_dat;
wr_dat = bak&wr_dat;
}
Wbyt(x0,y0,wr_dat);
y0 = (y0+8)&0x38;
}
else
{
wr_dat = 0xff<<(y0&0x07);
wr_dat = wr_dat&(0xff>>(7-(y1&0x07)));
if(color)
{
wr_dat = bak|wr_dat; //若color不为0,则显示
}
else
{
wr_dat = ~wr_dat; //若color为0,则清除显示
wr_dat = bak&wr_dat;
}
Wbyt(x0,y0,wr_dat);
return;
}
}while(y1>y0);
}
uchar LCD::LoadLine(uchar x, uchar y, uchar *dat, uchar no)
/****************************************************************************
* 名称:LoadLine()
* 功能:输出单色图形的一行数据。
* 入口参数: x 指定显示位置,x坐标
* y 指定显示位置,y坐标
* dat 要输出显示的数据。
* no 要显示此行的点个数
* 出口参数:返回值为1时表示操作成功,为0时表示操作失败。
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
{ unsigned char bit_dat;
unsigned char i;
TCOLOR bakc;
/* 参数过滤 */
if(x>=LCM_XMAX) return(0);
if(y>=LCM_YMAX) return(0);
for(i=0; i<no; i++)
{ /* 判断是否要读取点阵数据 */
if( (i%8)==0 ) bit_dat = *dat++;
/* 设置相应的点为color或为back_color */
if( (bit_dat&DCB2HEX_TAB[i&0x07])==0 )
bakc=GetBColor();//CopyColor(&bakc, back_color);
else
bakc=GetFColor();//CopyColor(&bakc, disp_color);
Point(x, y, bakc);
if( (++x)>=LCM_XMAX ) return(0);
}
return(1);
}
uchar LCD::PutWd(uchar x, uchar y, uchar *dat, uchar hno, uchar lno)
/****************************************************************************
* 名称:PutHZ()
* 功能:显示汉字。
* 入口参数: x 指定显示位置,x坐标
* y 指定显示位置,y坐标
* dat 要输出显示的汉字点阵数据。
* hno 要显示此行的点个数
* lno 要显示此列的点个数
* 出口参数:无
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
{ unsigned char i;
for(i=0; i<lno; i++)
{ LoadLine(x, y, dat, hno); // 输出一行数据
y++; // 显示下一行
dat += (hno>>3); // 计算下一行的数据
if( (hno&0x07)!=0 ) dat++;
}
//CurenRow=x;
// CurenLin=y;
return(1);
}
uchar LCD::PutChar(uchar x, uchar y, uchar ch)
/****************************************************************************
* 名称:PutChar()
* 功能:显示ASCII码,显示值为20H-7FH(若为其它值,则显示' ')。
* 入口参数: x 指定显示位置,x坐标
* y 指定显示位置,y坐标
* ch 要显示的ASCII码值。
* 出口参数:返回值为1时表示操作成功,为0时表示操作失败。
* 说明:操作失败原因是指定地址超出有效范围。(显示格式为6*8)
****************************************************************************/
{
uchar font_dat;
uchar i, j;
TCOLOR bakc;
/* 参数过滤 */
if( x>(LCM_XMAX-8) ) return(0);
if( y>(LCM_YMAX-8) ) return(0);
if( (ch<0x20) || (ch>0x7f) ) ch = 0x20;
ch -= 0x20;
for(i=0; i<8; i++)
{ /* 读取点阵数据 */
font_dat = FONT8x8ASCII[ch][i];
for(j=0; j<8; j++)
{ /* 设置相应的点为color或为back_color */
if( (font_dat&DCB2HEX_TAB[j])==0 )
bakc=GetBColor();//GUI_CopyColor(&bakc, back_color);
else
bakc=GetFColor();//GUI_CopyColor(&bakc, disp_color);
Point(x, y, bakc);
x++;
}
y++; // 指向下一行
x -= 8; // 恢复x值
}
return(1);
}
void LCD::PutStr(uchar x, uchar y, char *str)
/****************************************************************************
* 名称:PutStr()
* 功能:输出显示字符串((8*8字体,没有自动换行功能)。
* 入口参数: x 指定显示位置,x坐标
* y 指定显示位置,y坐标
* str 要显示的ASCII码字符串
* 出口参数:无
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
{
while(1)
{
if( (*str)=='\0' ) break;
if( PutChar(x, y, *str++)==0 ) break;
x += 6; // 下一个字符显示位置,y不变(即不换行)
}
}
void LCD::PutF(uchar x, uchar y, float data)
/****************************************************************************
* 名称:PutF()
* 功能:输出显示字符串((8*8字体,没有自动换行功能)。
* 入口参数: x 指定显示位置,x坐标
* y 指定显示位置,y坐标
* data 浮要显示的点数据
* 出口参数:无
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
{
char tempst[30];
FtoStr(data,tempst);
PutStr(x,y,tempst);
}
void LCD::Axis_on()
/****************************************************************************
* 名称:Axis_on()
* 功能:显示座标轴
* 入口参数: 无
*
* 出口参数:无
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
{
uchar i;
for(i=1;i<63;i=i+8)
HLine(ZeroX,i-1,ZeroX+3,0x01);
HLine(0,ZeroY,127,0x01);
for(i=1;i<127;i=i+8)
RLine(i-1,ZeroY,ZeroY-2,0x01);
RLine(ZeroX,63,0,0x01);
}
void LCD::Xlabel(char *str)
/****************************************************************************
* 名称:Xlabel()
* 功能:显示座标轴
* 入口参数: str 要显示的横标轴
*
* 出口参数:无
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
{
PutStr(120,55,str);
}
void LCD::Ylabel(char *str)
/****************************************************************************
* 名称:Ylabel()
* 功能:显示座标轴
* 入口参数: str 要显示的纵标轴
*
* 出口参数:无
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
{
PutStr(1,0,str);
}
void LCD::Title(char *str)
/****************************************************************************
* 名称:Title()
* 功能:给曲线图加标题
* 入口参数: str 曲线图标题
*
* 出口参数:无
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
{
PutStr(64,0,str);
}
/*
void LCD::Plot(uint Num[])
{
uchar i;
uint max;
uint min;
max=Max(Num);
min=Min(Num);
float tempM;
tempM=63.0/(max-min);
uint tempR[128];
for(i=0;Num[i]!='\0';i++)
tempR[i]=(int)((Num[i]-min)*tempM);
for(i=0;Num[i]!='\0';i++)
if(Point(i,tempR[i],0x01)==0);
// if(Point(i,(int)(Num[i]),0x01)==0)continue;
}
*/
void LCD::Plot(uint Num[])
{
uint i;
uint max;
max=Max(Num);
float tempM;
tempM=63.0/max;
for(i=0;i<127;i++) // for(i=0;Num[i]!='\0';i++)
//if(Point(i,63-(int)(Num[i]*tempM),0x01)==0)continue;
if(Point(i,63-(int)(Num[i]*tempM),0x01)==0)continue;
// if(Point(i,(int)(Num[i]),0x01)==0)continue;
}
#endif //endif __LCD_CPP
//《《《《《《《《《《《《《《《《《《《《《《《《《
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -