www.pudn.com > LTC2440.rar > LCD12864.H, change:2013-03-29,size:19127b


 #ifndef _LCD12864_H_ 
#define _LCD12864_H_ 
//lcd12864.h头文件 
//从51移植过来的 
#include"font_num.h" 
#define uchar unsigned char 
#define uint unsigned int 
 
 ////************LCD***********//// 
  /* 
#define SET_CS PORTA|=(1<<PA5) 
#define CLR_CS PORTA&=~(1<<PA5) 
#define SET_SID PORTA|=(1<<PA6) 
#define CLR_SID PORTA&=~(1<<PA6) 
#define SET_SCLK PORTA|=(1<<PA7) 
#define CLR_SCLK PORTA&=~(1<<PA7) 
 
		   */ 
/* 
#define SET_CS	 		GPIOB->BSRR=0X00000400 
#define CLR_CS 	   		GPIOB->BSRR=0X04000000 
#define SET_SID	 		GPIOB->BSRR=0X00001000 
#define CLR_SID	 		GPIOB->BSRR=0X10000000 
#define SET_SCLK		GPIOB->BSRR=0X00004000 
#define CLR_SCLK 		GPIOB->BSRR=0X40000000 
 
void SendNum(unsigned char address,unsigned long numxx); 
void WriteStr(uchar add,uchar *ptr); 
void lcd_init(void); 
 
 
void delay_1ms(uint x) 
{ 
    long j; 
    long i; 
    for(j=0;j<x;j++) 
    { 
        for(i=0;i<100;i++); 
    } 
} 
 
void send_command(uchar command_data) 
{ 
    uchar i; 
    uchar i_data,temp_data1,temp_data2; 
    i_data=0xf8; 
    delay_1ms(10); 
    SET_CS; 
    CLR_SCLK; 
    for(i=0;i<8;i++) 
    { 
       if(i_data&0x80) 
			SET_SID; 
		else 
			CLR_SID; 
        CLR_SCLK; 
        SET_SCLK; 
        i_data=i_data<<1; 
    } 
    i_data=command_data; 
    i_data&=0xf0; 
    for(i=0;i<8;i++) 
    { 
        
		if(i_data&0x80) 
			SET_SID; 
		else 
			CLR_SID; 
        CLR_SCLK; 
        SET_SCLK; 
        i_data=i_data<<1; 
    } 
    i_data=command_data; 
    temp_data1=i_data&0xf0; 
    temp_data2=i_data&0x0f; 
    temp_data1>>=4; 
    temp_data2<<=4; 
    i_data=temp_data1|temp_data2; 
    i_data&=0xf0; 
    for(i=0;i<8;i++) 
    { 
       if(i_data&0x80) 
			SET_SID; 
		else 
			CLR_SID; 
       CLR_SCLK; 
       SET_SCLK; 
        i_data=i_data<<1; 
    } 
    CLR_CS; 
} 
 
void send_data(uchar command_data) 
{ 
    uchar i; 
    uchar i_data,temp_data1,temp_data2; 
    i_data=0xfa; 
    delay_1ms(10); 
    SET_CS; 
    for(i=0;i<8;i++) 
    { 
       if(i_data&0x80) 
			SET_SID; 
		else 
			CLR_SID; 
       CLR_SCLK; 
       SET_SCLK; 
        i_data=i_data<<1; 
    } 
    i_data=command_data; 
    i_data&=0xf0; 
    for(i=0;i<8;i++) 
    { 
        if(i_data&0x80) 
			SET_SID; 
		else 
			CLR_SID; 
       CLR_SCLK; 
       SET_SCLK; 
        i_data=i_data<<1; 
    } 
    i_data=command_data; 
    temp_data1=i_data&0xf0; 
    temp_data2=i_data&0x0f; 
    temp_data1>>=4; 
    temp_data2<<=4; 
    i_data=temp_data1|temp_data2; 
    i_data&=0xf0; 
    for(i=0;i<8;i++) 
    { 
        if(i_data&0x80) 
			SET_SID; 
		else 
			CLR_SID; 
       CLR_SCLK; 
       SET_SCLK; 
        i_data=i_data<<1; 
    } 
    CLR_CS; 
} 
 
void lcd_init() 
{ 
  
    delay_1ms(100); 
    send_command(0x30); //功能设置:一次送8位数据,基本指令集  
   
    send_command(0x04); //点设定:显示字符/光标从左到右移位,DDRAM地址加1  
 
    send_command(0x0c); //显示设定:开显示,关光标,当前显示位不反白闪动0X0F相反  
 
    send_command(0x01); //清DDRAM  
 
    send_command(0x02); //DDRAM地址归位  
 
    send_command(0x80); //把显示地址设为0X80,即为第一行的首位  
} 
 
 
 
 
//  
// 
// 写字符串 
// 
//  
void SendStr(uchar *add) 
 
{    
    uchar ii; 
   for(ii=0;add[ii]!='\0';ii++) 
   { 
 
    send_data(add[ii]); 
    
   } 
 
 
} 
 
 
 
  //  
  // 
  //给某地址写字符串 
  //  
  void WriteStr(uchar add,uchar *ptr) 
 
     { 
        send_command(add); 
       SendStr(ptr); 
     // LCD_send_Data(*ptr); 
      
     } 
      
void WrLetter(uchar addr,uchar tmpdata) 
{ 
     send_command(addr); 
     send_data(tmpdata);  
} 
 
void SendNum(unsigned char address,unsigned long numxx) 
{ 
  send_command(address); 
 
  send_data('0'+numxx%100000000/10000000); 
  send_data('0'+numxx%10000000/1000000); 
  send_data('0'+numxx%1000000/100000); 
  send_data('0'+numxx%100000/10000); 
  send_data('0'+numxx%10000/1000); 
  send_data('0'+numxx%1000/100); 
  send_data('0'+numxx%100/10); 
  send_data('0'+numxx%10); 
 
} 
 
*/ 
 
////////////////////////////// 
#define LCD_CS_H	 		GPIOB->BSRR=0X00000400 
#define LCD_CS_L 	   		GPIOB->BSRR=0X04000000 
#define LCD_SDI_H	 		GPIOB->BSRR=0X00001000 
#define LCD_SDI_L	 		GPIOB->BSRR=0X10000000 
#define LCD_SCK_H		GPIOB->BSRR=0X00004000 
#define LCD_SCK_L 		GPIOB->BSRR=0X40000000  
void delay_1ms(uint x) 
{ 
    long j; 
    long i; 
    for(j=0;j<x;j++) 
    { 
        for(i=0;i<100;i++); 
    } 
} 
/* 
void SEND_LCD8(unsigned char i_data) 
{ 
    unsigned char i; 
for(i=0;i<8;i++) 
    {   LCD_SCK_L; 
       if(i_data&0x80) 
            LCD_SDI_H; 
        else 
            LCD_SDI_L; 
         
        LCD_SCK_H; 
        i_data=i_data<<1; 
    } 
} 
void send_command(unsigned char command_data) 
{ 
 
    unsigned char i_data,temp_data1,temp_data2; 
    i_data=0xf8; 
  // delay_1ms(10); 
    LCD_CS_H; 
    LCD_SCK_L; 
    SEND_LCD8(i_data); 
    i_data=command_data; 
    i_data&=0xf0; 
    SEND_LCD8(i_data); 
    i_data=command_data; 
    temp_data1=i_data&0xf0; 
    temp_data2=i_data&0x0f; 
    temp_data1>>=4; 
    temp_data2<<=4; 
    i_data=temp_data1|temp_data2; 
    i_data&=0xf0; 
    SEND_LCD8(i_data); 
     LCD_CS_L; 
} 
 
void send_data(unsigned char command_data) 
{ 
 
    unsigned char i_data,temp_data1,temp_data2; 
    i_data=0xfa; 
    LCD_CS_H; 
    SEND_LCD8(i_data); 
    i_data=command_data; 
    i_data&=0xf0; 
    SEND_LCD8(i_data); 
    i_data=command_data; 
    temp_data1=i_data&0xf0; 
    temp_data2=i_data&0x0f; 
    temp_data1>>=4; 
    temp_data2<<=4; 
    i_data=temp_data1|temp_data2; 
    i_data&=0xf0; 
    SEND_LCD8(i_data); 
    LCD_CS_L; 
} 
   */ 
    
void send_command(uchar command_data) 
{ 
    uchar i; 
    uchar i_data,temp_data1,temp_data2; 
    i_data=0xf8; 
    delay_1ms(10); 
    LCD_CS_H; 
    LCD_SCK_L; 
    for(i=0;i<8;i++) 
    { 
       if(i_data&0x80) 
			LCD_SDI_H; 
		else 
			LCD_SDI_L; 
        LCD_SCK_L; 
        LCD_SCK_H; 
        i_data=i_data<<1; 
    } 
    i_data=command_data; 
    i_data&=0xf0; 
    for(i=0;i<8;i++) 
    { 
        
		if(i_data&0x80) 
			LCD_SDI_H; 
		else 
			LCD_SDI_L; 
        LCD_SCK_L; 
        LCD_SCK_H; 
        i_data=i_data<<1; 
    } 
    i_data=command_data; 
    temp_data1=i_data&0xf0; 
    temp_data2=i_data&0x0f; 
    temp_data1>>=4; 
    temp_data2<<=4; 
    i_data=temp_data1|temp_data2; 
    i_data&=0xf0; 
    for(i=0;i<8;i++) 
    { 
       if(i_data&0x80) 
			LCD_SDI_H; 
		else 
			LCD_SDI_L; 
       LCD_SCK_L; 
       LCD_SCK_H; 
        i_data=i_data<<1; 
    } 
    LCD_CS_L; 
} 
 
void send_data(uchar command_data) 
{ 
    uchar i; 
    uchar i_data,temp_data1,temp_data2; 
    i_data=0xfa; 
    delay_1ms(10); 
    LCD_CS_H; 
    for(i=0;i<8;i++) 
    { 
       if(i_data&0x80) 
			LCD_SDI_H; 
		else 
			LCD_SDI_L; 
       LCD_SCK_L; 
       LCD_SCK_H; 
        i_data=i_data<<1; 
    } 
    i_data=command_data; 
    i_data&=0xf0; 
    for(i=0;i<8;i++) 
    { 
        if(i_data&0x80) 
			LCD_SDI_H; 
		else 
			LCD_SDI_L; 
       LCD_SCK_L; 
       LCD_SCK_H; 
        i_data=i_data<<1; 
    } 
    i_data=command_data; 
    temp_data1=i_data&0xf0; 
    temp_data2=i_data&0x0f; 
    temp_data1>>=4; 
    temp_data2<<=4; 
    i_data=temp_data1|temp_data2; 
    i_data&=0xf0; 
    for(i=0;i<8;i++) 
    { 
        if(i_data&0x80) 
			LCD_SDI_H; 
		else 
			LCD_SDI_L; 
       LCD_SCK_L; 
       LCD_SCK_H; 
        i_data=i_data<<1; 
    } 
    LCD_CS_L; 
} 
void lcd_init() 
{ 
  
  
    send_command(0x30); delay_1ms(80); //功能设置:一次送8位数据,基本指令集  
    send_command(0x04); delay_1ms(80); //点设定:显示字符/光标从左到右移位,DDRAM地址加1  
    send_command(0x0c);  delay_1ms(80);//显示设定:开显示,关光标,当前显示位不反白闪动0X0F相反  
    send_command(0x01); delay_1ms(1600);//清DDRAM  
    send_command(0x02); delay_1ms(80); //DDRAM地址归位  
    send_command(0x80);  delay_1ms(80);//把显示地址设为0X80,即为第一行的首位  
     
} 
char getHEX(unsigned char number) 
{ 
	if(number>9) 
		return ((number-10)+'A'); 
	else 
		return 	number+'0'; 
} 
void HEX32(unsigned char address,unsigned long numxx) 
{ 
 
	send_command(address); 
	send_data(getHEX((numxx>>28)&0x0f)); 
	send_data(getHEX((numxx>>24)&0x0f)); 
	send_data(getHEX((numxx>>20)&0x0f)); 
	send_data(getHEX((numxx>>16)&0x0f)); 
   	send_data(getHEX((numxx>>12)&0x0f)); 
	send_data(getHEX((numxx>>8)&0x0f)); 
	send_data(getHEX((numxx>>4)&0x0f)); 
	send_data(getHEX((numxx>>0)&0x0f)); 
} 
void HEX8(unsigned char address,unsigned  char numxx) 
{ 
  	send_command(address); 
	send_data(getHEX((numxx>>4)&0x0f)); 
	send_data(getHEX((numxx>>0)&0x0f)); 
	} 
void lcd_draw_update() 
{ 
 
 //基本指令 
     send_command(0x30); delay_1ms(80); /*功能设置:一次送8位数据,基本指令集*/ 
   // send_command(0x04); delay_1ms(80); /*点设定:显示字符/光标从左到右移位,DDRAM地址加1*/ 
    send_command(0x0c);  delay_1ms(80);/*显示设定:开显示,关光标,当前显示位不反白闪动0X0F相反*/ 
   // send_command(0x01); delay_1ms(1600);/*清DDRAM*/ 
   // send_command(0x02); delay_1ms(80); /*DDRAM地址归位*/ 
  //  send_command(0x80);  delay_1ms(80);/*把显示地址设为0X80,即为第一行的首位*/ 
    
   //send_command(0x36);   delay_1ms(80); //8bit,绘图开,扩充指令开 
  // send_command(0x02);   delay_1ms(72); /*DDRAM地址归位*/ 
  
   // send_command(0x06); // reverse  
   // delay_1ms(72); 
    //send_command(0x40); // scroll 0 
    //delay_1ms(72);  
       
     
} 
void drawon() 
{ 
send_command(0x36); //绘图开,扩充指令开 
 
} 
void cord(unsigned char X_,unsigned char Y_) 
{ 
send_command(0x80|Y_); //绘图RAM地址0 
send_command(0x80|X_); //绘图RAM地址 0~15 
} 
void data_num(unsigned char X_,unsigned char num) 
{ 
    unsigned char j; 
    unsigned short int i; 
    i=32*num; 
 for(j=0;j<23;j++) 
  { 
      cord(X_,j); 
      send_data(font[j+i][0]); 
      send_data(font[j+i][1]); 
  }  
} 
//画图大数字 
void draw_weight(long ADC0,unsigned char dot,unsigned char unitdn[3])////显示6位10进制,dot几位小数位 
{   unsigned char DIG[10]; 
    long tmp; 
    unsigned char f=0; 
    unsigned short int j,k; 
    int i; 
    tmp=ADC0; 
    
     
    if(ADC0<0) 
    ADC0=0-ADC0; 
    for(i=0;i<10;i++) 
    { 
        DIG[i]=ADC0%10; 
        ADC0/=10; 
    } 
   
    for(i=9;i>=0;i--) 
    { 
        if(f==0) 
        { 
            if((DIG[i]!=0 )||(i==dot))//第一个不为0 
            { 
               f=1; 
               j=i; 
               if(tmp<0) 
               { 
               DIG[i+1]=12;//minus -号 
               j=i+1; 
               } 
               break; 
            } 
            DIG[i]=10;// space 
        }  
    } 
     f=0;  
     if(dot!=0) 
     { 
      //DIG[dot]|=0x80;//dot 
     } 
     //0LSB 8MSB 
      
     drawon();//开画图 
      
    cord(0,9); 
    for(i=0;i<16;i++)//  
    { 
        send_data(0); 
     } 
   
 for(j=0;j<23;j++)//Y 
  { 
      cord(0,j+10); 
      for(i=6;i>0;i--)//数字部分 
      { 
       k =j+(DIG[i-1]<<5); 
       if(i==6&&(!dot)) 
       send_data(0); 
       if(dot==i) 
          send_data(font_dot[j]); 
       send_data(font[k][0]); 
       send_data(font[k][1]); 
      } 
      /* 
      if(j<10) 
      { 
      send_data(font_asii8X16[(unitup[0]-' ')][j+4]); 
      send_data(font_asii8X16[(unitup[1]-' ')][j+4]); 
      } 
      else //if(j<23) 
      {*/ 
     
      send_data(0); 
      if(j>7) 
      { 
       send_data(font_asii8X16[(unitdn[0]-' ')][j-7]); 
       send_data(font_asii8X16[(unitdn[1]-' ')][j-7]); 
      } 
      else 
      { 
       send_data(0); send_data(0); 
      } 
      /* 
      // send_data(0); 
      if(j>3) 
      { 
        send_data(font_unit[j-4][0]); 
        send_data(font_unit[j-4][1]); 
        send_data(font_unit[j-4+20][0]); 
        send_data(font_unit[j-4+20][1]); 
      }*/ 
       
      //} 
       
  }  
      
 
} 
//IO小图标16个 
void draw_io(unsigned char in,unsigned short int out)/// 
{ 
    unsigned short int i,j; 
    unsigned char tmp=0; 
  //  unsigned char inICON[4],outICON[4]; 
 drawon();//开画图 
  
 for(j=0;j<10;j++)//Y 
  { 
      cord(0,j); 
      if(j==0) 
          for(i=0;i<8;i++) 
            send_data(0x00); 
      else if(j<1+5) 
      { 
          for(i=0;i<8;i++)//  
          { 
            ////////////input///////// 
             tmp=0; 
            if(in&(1<<((i<<1)+1)))//on 
             tmp|=font_iicon[1][j-1]; 
            else//off 
             tmp|=font_iicon[0][j-1]; 
            if(in&(1<<(i<<1)))//on 
             tmp|=font_iicon[3][j-1]; 
            else 
             tmp|=font_iicon[2][j-1]; 
           send_data(tmp); 
           
          } 
          for(i=0;i<8;i++)//  
          { 
 
           ////////output/////// 
            tmp=0; 
            if(out&(1<<((i<<1)+1)))//on 
             tmp|=font_oicon[1][j-1]; 
            else//off 
             tmp|=font_oicon[0][j-1]; 
            if(out&(1<<(i<<1)))//on 
             tmp|=font_oicon[3][j-1]; 
            else 
             tmp|=font_oicon[2][j-1]; 
            send_data(tmp); 
          } 
      } 
       
  } 
} 
//IO大图标8个 
void draw_ioB(unsigned short int in,unsigned short int out)/// 
{ 
    unsigned short int i,j; 
    unsigned char tmp; 
  //  unsigned char inICON[4],outICON[4]; 
 drawon();//开画图 
  
 for(j=0;j<10;j++)//Y 
  { 
      cord(0,j); 
      if(j==0) 
          for(i=0;i<16;i++)//  
          { 
            send_data(0xff); 
           
          } 
      else if(j<8) 
      { 
          for(i=0;i<8;i++)//  
          { 
 
           ////////output/////// 
            if(out&(1<<i))//on 
                    tmp=font_oiconB[1][j-1]; 
            else 
                tmp=font_oiconB[0][j-1]; 
            if(i==0) 
              tmp|=0x80; 
            else if(i==7) 
              tmp|=0x01; 
              send_data(tmp); 
          } 
          for(i=0;i<8;i++)//  
          { 
            ////////////input///////// 
             
             
            if(in&(1<<i)) 
                tmp=font_iiconB[1][j-1]; 
            else 
                tmp=font_iiconB[0][j-1]; 
            if(i==0) 
              tmp|=0x80; 
            else if(i==7) 
              tmp|=0x01; 
              send_data(tmp); 
           
          } 
           
      } 
      else if(j==8) 
       for(i=0;i<16;i++)//  
          { 
            send_data(0xff); 
           
          } 
       
  } 
} 
void draw_CNST(unsigned char i1[10]) 
{ 
    unsigned short int i,j; 
    unsigned short int tmp,tmp1; 
    drawon();//开画图 
    for(j=0;j<3;j++)//Y 
    { 
        cord(8,j); 
        for(i=0;i<16;i++)//  
        { 
        send_data(0); 
        } 
    } 
     for(j=0;j<12;j++)//Y 
      { 
          cord(8,j+3); 
           for(i=0;i<4;i++)//  
           {    
               tmp=(i<<1); 
               tmp1=(i<<1)+1; 
               send_data(font_cn1212[i1[tmp]*12+j][0]); 
               send_data(font_cn1212[i1[tmp]*12+j][1]|font_cn1212[i1[tmp1]*12+j][0]>>4); 
               send_data(font_cn1212[i1[tmp1]*12+j][0]<<4|font_cn1212[i1[tmp1]*12+j][1]>>4); 
               send_data(font_cn1212[i1[tmp1]*12+j][1]<<4); 
           } 
      } 
} 
//第2行 
void draw_LINE2(unsigned char i1[17]) 
{ 
    unsigned short int i,j; 
  
    drawon();//开画图 
    cord(8,15); 
    for(i=0;i<16;i++)//  
    { 
        send_data(0); 
    } 
 
    for(j=0;j<16;j++)//Y 
    { 
        cord(8,j+16); 
        for(i=0;i<16;i++)//  
        {    
            send_data(font_asii8X16[i1[i]-' '][j]); 
        } 
    } 
} 
void drawoff() 
{ 
send_command(0x30); //绘图关,扩充指令关 
 
} 
/* 
void draw_char8x16(unsigned char X_,unsigned char Y_,unsigned char CH;) 
{ 
    unsigned char j; 
    unsigned short int i; 
    i=16*CH; 
 for(j=0;j<23;j++) 
  { 
      cord(X_,j); 
      send_data(font[j+i][0]); 
      send_data(font[j+i][1]); 
  }  
}*/ 
//*************************************************************** 
// 
// 写字符串 
// 
//************************************************************** 
void SendStr(unsigned char *add) 
{    
    unsigned char ii; 
   for(ii=0;add[ii]!='\0';ii++) 
   { 
      send_data(add[ii]); 
   } 
} 
  //********************************************************* 
  // 
  //给某地址写字符串 
  //********************************************************** 
void WriteStr(unsigned char add,unsigned char *ptr) 
{ 
        send_command(add); 
       SendStr(ptr); 
     // LCD_send_Data(*ptr); 
} 
      
void WrLetter(unsigned char addr,unsigned char tmpdata) 
{ 
     send_command(addr); 
     send_data(tmpdata);  
      
} 
void LCD_2DIG(unsigned char addr,unsigned char tmpdata) 
{ 
     send_command(addr); 
     send_data(tmpdata/10+'0');  
     send_data(tmpdata%10+'0');  
      
} 
 
void LCD_U32_DOT(long ADC0,unsigned char dot)////显示6位10进制,dot几位小数位, 
{   unsigned char DIG[10]; 
    long tmp; 
    unsigned char f=0; 
    unsigned char i,j; 
    tmp=ADC0; 
    
     
    if(ADC0<0) 
    ADC0=0-ADC0; 
     
    DIG[9]=0; 
    for(i=8;i>0;i--) 
    { 
        if(dot&&(dot==(8-i))) 
        { DIG[i]='.';i--;} 
        DIG[i]=ADC0%10+'0'; 
        ADC0/=10; 
    } 
    // DIG[0]=ADC0%10+'0' 
    DIG[i]=ADC0%10+'0'; 
     
    for(i=0;i<9;i++)// BUG--for(i=0;i<8;i++)只有一位负值时,负号不显示 
    {                //改为 for(i=0;i<9;i++)后,为0时不显示,另加 
                    // if(tmp==0)  DIG[8]='0'; 
     
        if(f==0)// 
        { 
             
            if((DIG[i]!='0' )||(dot&&(i==(7-dot))))//第一个不为0 
            { 
               f=1; 
               j=i; 
               if(tmp<0) 
               { 
                 DIG[i-1]='-';//minus 
               } 
               break; 
            } 
            DIG[i]=' ';// space 
        }  
    } 
    if(tmp==0) 
     DIG[8]='0'; 
     
     
  WriteStr(0x91,DIG); 
     
} 
 
void lcd_clr1() 
  {  WriteStr(0X80,"                "); } 
void  lcd_clr2() 
{    WriteStr(0X90,"                "); } 
void lcd_clr3() 
{   WriteStr(0X88,"                "); } 
void lcd_clr4()  
 {   WriteStr(0X98,"                "); } 
void lcd_clr() 
{ 
    lcd_clr1() ; 
    lcd_clr2() ; 
    lcd_clr3() ; 
    lcd_clr4() ; 
} 
void LCD_S32(unsigned char address,long ADC0)////显示6位10进制, 
{    
    unsigned char dot=0;//dot几位小数位, 
    unsigned char DIG[10]; 
    long tmp; 
    unsigned char f=0; 
    unsigned char i,j; 
    tmp=ADC0; 
    
       
     
    if(ADC0<0) 
    ADC0=0-ADC0; 
     
    DIG[9]=0; 
    for(i=8;i>0;i--) 
    { 
        if(dot&&(dot==(8-i))) 
        { DIG[i]='.';i--;} 
        DIG[i]=ADC0%10+'0'; 
        ADC0/=10; 
    } 
    // DIG[0]=ADC0%10+'0' 
    DIG[i]=ADC0%10+'0'; 
     
    for(i=0;i<9;i++)// BUG--for(i=0;i<8;i++)只有一位负值时,负号不显示 
    {                //改为 for(i=0;i<9;i++)后,为0时不显示,另加 
                    // if(tmp==0)  DIG[8]='0'; 
     
        if(f==0)// 
        { 
             
            if((DIG[i]!='0' )||(dot&&(i==(7-dot))))//第一个不为0 
            { 
               f=1; 
               j=i; 
               if(tmp<0) 
               { 
                 DIG[i-1]='-';//minus 
               } 
               break; 
            } 
            DIG[i]=' ';// space 
        }  
    } 
    if(tmp==0) 
     DIG[8]='0'; 
     
  WriteStr(address,DIG); 
     
} 
#endif