中级会员
 
- 积分
- 454
- 金钱
- 454
- 注册时间
- 2016-4-22
- 在线时间
- 82 小时
|
发表于 2016-8-13 12:08:48
|
显示全部楼层
我试了一下你写的,只能显示一位数,两位数就不行了,我照你思路改了一下,现在可以显示任意位数了。
void LCD_ShowNum(u16 x,u16 y,s32 num,u8 len,u8 size)
{
u8 t,temp,fu = 0;
u8 enshow=0;
if(num<0)
{
num = - num;
fu = 1 ;
}
if(fu)
{
LCD_ShowChar(x-(size/2),y,'-',size,0);
}
for(t=0;t<len;t++)
{
temp=(num/LCD_Pow(10,len-t-1))%10;
if(enshow==0&&t<(len-1))
{
if(temp==0)
{
LCD_ShowChar(x+(size/2)*t,y,' ',size,0);
continue;
}else enshow=1;
}
LCD_ShowChar(x+(size/2)*(t+1),y,temp+'0',size,0);
}
} |
|