format.c

来自「在8052下实现电平电压测试功能,自己开发的单片系统」· C语言 代码 · 共 71 行

C
71
字号
/*
----------------------------------------------------------
;		(c) Copyright xami All Rights Reserved              
----------------------------------------------------------
;	SOURCE_FILE:    FORMAT.H
;	APPLICATION:	80c51\80c52
;	DESCRIPTION:    格式化取得的频率值,送显存
;	AUTHOR:         xami
;	DATE:           28 Apr. 2007
----------------------------------------------------------
*/
void panduan(void)
{
		if(temp_f>= 10000000){
			digit_temp[0]= digit[0][temp_f/10000000];
			digit_temp[1]= digit[0][(temp_f/1000000)%10];
			digit_temp[2]= digit[0][(temp_f/100000)%10];			
			digit_temp[3]= digit[0][(temp_f/10000)%10];			
			digit_temp[4]= digit[1][(temp_f/1000)%10];			
			digit_temp[5]= digit[0][(temp_f/100)%10];				//最后舍去两位
		}else if(temp_f>= 1000000){
			digit_temp[0]= digit[0][temp_f/1000000];
			digit_temp[1]= digit[0][(temp_f/100000)%10];
			digit_temp[2]= digit[0][(temp_f/10000)%10];			
			digit_temp[3]= digit[1][(temp_f/1000)%10];			
			digit_temp[4]= digit[0][(temp_f/100)%10];			
			digit_temp[5]= digit[0][(temp_f/10)%10];				//最后舍去一位				
		}else if(temp_f>= 100000){
			digit_temp[0]= digit[0][temp_f/100000];
			digit_temp[1]= digit[0][(temp_f/10000)%10];
			digit_temp[2]= digit[1][(temp_f/1000)%10];			
			digit_temp[3]= digit[0][(temp_f/100)%10];			
			digit_temp[4]= digit[0][(temp_f/10)%10];			
			digit_temp[5]= digit[0][(temp_f)%10];					//无舍去				
		}else if(temp_f>= 10000){
			digit_temp[0]= 0x00;									//第一位"null"
			digit_temp[1]= digit[0][temp_f/10000];
			digit_temp[2]= digit[1][(temp_f/1000)%10];			
			digit_temp[3]= digit[0][(temp_f/100)%10];			
			digit_temp[4]= digit[0][(temp_f/10)%10];			
			digit_temp[5]= digit[0][(temp_f)%10];									
		}else if(temp_f>= 1000){
			digit_temp[0]= 0x00;									//第一位"null"
			digit_temp[1]= 0x00;									//第二位"null"
			digit_temp[2]= digit[1][temp_f/1000];			
			digit_temp[3]= digit[0][(temp_f/100)%10];			
			digit_temp[4]= digit[0][(temp_f/10)%10];			
			digit_temp[5]= digit[0][(temp_f)%10];									
		}else if(temp_f>= 100){
			digit_temp[0]= 0x00;									//第一位"null"
			digit_temp[1]= 0x00;									//第二位"null"
			digit_temp[2]= digit[1][0];								//第三位"0."
			digit_temp[3]= digit[0][temp_f/100];			
			digit_temp[4]= digit[0][(temp_f/10)%10];			
			digit_temp[5]= digit[0][(temp_f)%10];									
		}else if(temp_f>= 10){
			digit_temp[0]= 0x00;									//第一位"null"
			digit_temp[1]= 0x00;									//第二位"null"
			digit_temp[2]= digit[1][0];								//第三位"0."
			digit_temp[3]= digit[0][0];								//第四位"0"
			digit_temp[4]= digit[0][temp_f/10];			
			digit_temp[5]= digit[0][(temp_f)%10];									
		}else{
			digit_temp[0]= 0x00;									//第一位"null"
			digit_temp[1]= 0x00;									//第二位"null"
			digit_temp[2]= digit[1][0];								//第三位"0."
			digit_temp[3]= digit[0][0];								//第四位"0"
			digit_temp[4]= digit[0][0];								//第五位"0"
			digit_temp[5]= digit[0][temp_f];									
		}	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?