急求基于51单片机的LCD显示实时数据曲线!!
LCD用的是OCM12864-2,单片机用的是STC89C58RD。之前用的液晶屏显示某个数据的值,现要求用LCD屏显示数据变化曲线。以测温度为例,时间间隔可修改,若时间...
LCD用的是OCM12864-2,单片机用的是STC89C58RD。之前用的液晶屏显示某个数据的值,现要求用LCD屏显示数据变化曲线。以测温度为例,时间间隔可修改,若时间间隔取为10min,液晶屏从右往左推进,显示十组数据曲线变化。
对程序编写完全没有头绪,有可用的字库吗?请高手指点,邮箱2861516651@qq.com,不胜感激。 展开
对程序编写完全没有头绪,有可用的字库吗?请高手指点,邮箱2861516651@qq.com,不胜感激。 展开
2个回答
展开全部
先实现划线的函数,把相邻的采样点转化为屏幕坐标之后,连接起来就可以了,下面划线函数可以作为参考
void Line(char x1,char y1,char x2,char y2)
{
char xdelta; // width of rectangle around line
char ydelta; // height of rectangle around line
char xinc; //increment for moving x coordinate
char yinc; //increment for moving y coordinate
char rem; //current remainder
//Bool bit = 0;//used for dashed lines
char s,e; //Start,End
//See if the line is horizontal or vertical. If so, then call special routines.
if (y1 == y2)
{ //draw a horizontal line
if(x1 > x2 ) s = x2,e = x1;
else s = x1,e = x2;
for(; s <= e; s++) SetPixel(s,y1,1);
}
else if (x1 == x2)
{//draw a vertical line
if(y1 > y2 ) s = y2,e = y1;
else s = y1,e = y2;
for(; s <= e; s++) SetPixel(x1,s,1);
}
else
{// The line may be partially obscured. Do the draw line algorithm
// checking each point against the clipping regions.
xdelta = x2 - x1;
ydelta = y2 - y1;
if (xdelta < 0) xdelta = -xdelta;
if (ydelta < 0) ydelta = -ydelta;
xinc = (x2 > x1)? 1 : -1;
yinc = (y2 > y1)? 1 : -1;
// draw the first point
//SetPixel( x1, y1, 1);
if (xdelta >= ydelta)
{
rem = xdelta / 2;
for (;x1 != x2; x1 += xinc)
{
SetPixel(x1, y1,1);
rem += ydelta;
if (rem >= xdelta){
rem -= xdelta;
y1 += yinc;
}
}
}
else
{
rem = ydelta / 2;
for (;y1 != y2; y1 += yinc)
{
SetPixel(x1, y1,1);
rem += xdelta;
if (rem >= ydelta) {
rem -= ydelta;
x1 += xinc;
}
}
}
}
g_nCoordinateX = x2;//
g_nCoordinateY = y2;
}
void Line(char x1,char y1,char x2,char y2)
{
char xdelta; // width of rectangle around line
char ydelta; // height of rectangle around line
char xinc; //increment for moving x coordinate
char yinc; //increment for moving y coordinate
char rem; //current remainder
//Bool bit = 0;//used for dashed lines
char s,e; //Start,End
//See if the line is horizontal or vertical. If so, then call special routines.
if (y1 == y2)
{ //draw a horizontal line
if(x1 > x2 ) s = x2,e = x1;
else s = x1,e = x2;
for(; s <= e; s++) SetPixel(s,y1,1);
}
else if (x1 == x2)
{//draw a vertical line
if(y1 > y2 ) s = y2,e = y1;
else s = y1,e = y2;
for(; s <= e; s++) SetPixel(x1,s,1);
}
else
{// The line may be partially obscured. Do the draw line algorithm
// checking each point against the clipping regions.
xdelta = x2 - x1;
ydelta = y2 - y1;
if (xdelta < 0) xdelta = -xdelta;
if (ydelta < 0) ydelta = -ydelta;
xinc = (x2 > x1)? 1 : -1;
yinc = (y2 > y1)? 1 : -1;
// draw the first point
//SetPixel( x1, y1, 1);
if (xdelta >= ydelta)
{
rem = xdelta / 2;
for (;x1 != x2; x1 += xinc)
{
SetPixel(x1, y1,1);
rem += ydelta;
if (rem >= xdelta){
rem -= xdelta;
y1 += yinc;
}
}
}
else
{
rem = ydelta / 2;
for (;y1 != y2; y1 += yinc)
{
SetPixel(x1, y1,1);
rem += xdelta;
if (rem >= ydelta) {
rem -= ydelta;
x1 += xinc;
}
}
}
}
g_nCoordinateX = x2;//
g_nCoordinateY = y2;
}
展开全部
直接写描绘曲线的程序比较难.建议使用图片的方式处理..
更多追问追答
追问
多谢回答!!
是实时的曲线,可以用图片来做吗?
追答
我举个例子:现在从23度开始,接下来是25度,我们要做的曲线比较多,每个字节位8X8位,我们要做的图片就是64个.根据需要,我们使用的的就是23度到25度的曲线.如果范围大的话,就需要使用几张图片的叠加.显示时,在单片机里先处理需要的图片资料,再发给LCD就可以了.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询