求教各位,我能在屏上显示正数,为啥负数就乱码呢。帮看看哪里错了
void Operation_display();//运行显示
void runing();//运行
void main(void)
{
uchar devid;
DisplayStart();//启动画面
devid=Single_Read_ADXL345(0X00);
while(1)
{
Lcd12864_Displayfigure(0,1,-12345);
Lcd12864_Displayfigure(0,2,-1234);
Lcd12864_Displayfigure(0,3,-123);
Lcd12864_Displayfigure(0,4,-12);
Lcd12864_Displayfigure(4,1,12345);
Lcd12864_Displayfigure(4,2,1234);
Lcd12864_Displayfigure(4,3,123);
Lcd12864_Displayfigure(4,4,12);
/* if((run_menu==0)&&(menukey()==1))
{
LCD12864_Clear();
Delay400Ms();
run_menu=1;
menuorede_word=1;
menu_y=0;
}
if((run_menu>=1)&&(menukey()==6))
{
LCD12864_Clear(); Delay400Ms();
run_menu=0;
}
switch(run_menu)
{
case(0):Multiple_read_ADXL345();Operation_display();break;
/*******************************************************************************
* 函 数 名 : Lcd12864_Displayfigure
* 函数功能 : //显示数字
* 输 入 : x,y,*gigure
* 输 出 : 无
*******************************************************************************/
void Lcd12864_Displayfigure(unsigned char X, unsigned char Y, int gigure)
{
unsigned char X2;
X2=X;
switch(Y)
{
case 1:X2|=0X80;break; //根据行数来选择相应地址
case 2:X2|=0X90;break;
case 3:X2|=0X88;break;
case 4:X2|=0X98;break;
}
if(gigure<0)
{
//gigure=~gigure+1;
LCD12864_WriteCmd(X2);
LCD12864_WriteData('-');
LCD12864_WriteData('0' + (gigure/10000));//千位
LCD12864_WriteData('0' + (gigure%1000/100));//
LCD12864_WriteData(0x6b);//
//LCD12864_WriteData('0' + (gigure%1000%100/10));//十位
//LCD12864_WriteData('0' + (gigure%1000%100%10));//个位(0x87);
}
if(gigure>0)
{
LCD12864_WriteCmd(X2);
LCD12864_WriteData('0' + (gigure/1000));//千位
LCD12864_WriteData('0' + (gigure%1000/100));//
LCD12864_WriteData('0' + (gigure%1000%100/10));//十位
LCD12864_WriteData('0' + (gigure%1000%100%10));//个位(0x87);
}
}
|