uifunction.c

来自「基于c的电动机保护程序」· C语言 代码 · 共 886 行 · 第 1/2 页

C
886
字号
        temp_pointToInt = temp_point * 1000 ;
        temp_pointToInt %= 100 ;


        if( temp_pointToInt >= 5 )
        {
        	 Float2LedValue[0] = Numdot[ temp_int ] ;
            temp_pointToInt = temp_point * 10 ;

/***************************小数部分*********************************/
            Float2LedValue[1] = LedNum[ temp_pointToInt ];
            temp_pointToInt = temp_point * 100 - temp_pointToInt*10;
            Float2LedValue[2] = LedNum[ temp_pointToInt ];
          

       }
       
/************************************************************/
          
       else
       {
            temp_pointToInt = temp_point * 10 ;
            Float2LedValue[0] = Numdot[ temp_int ] ;
/***************************小数部分*********************************/
            temp_pointToInt = temp_point * 10 ;
            Float2LedValue[1] = LedNum[ temp_pointToInt ];
            temp_pointToInt = temp_point * 100 - temp_pointToInt*10;
            Float2LedValue[2] = LedNum[ temp_pointToInt ];
        }
    }
       
         
  /************************************************************/

Data[0] =  Float2LedValue[0];
Data[1] =  Float2LedValue[1];
Data[2] =  Float2LedValue[2];

}

  



	





//设定数值时,首先用DOWN确定小数点位置,enter确定,然后
//用DOWN确定每一位的数值,按enter到下一位,然后用up翻页,
//翻页也代表确认先前的设定


								
int dotPosition = 0; // 小数点位置 0为tempDate 最左边

float Led2Float(void)
{
	U16 tempData[3];
	
	int i;
	
	    
	int resultTemp = 0;
	float result = 0;
	int temp = 1;
	enum  num {zero = 0x00FC, one = 0x0060, two = 0x00DA, three = 0x00F2, four = 0x0066, 
	five = 0x00B6,six = 0x00BE, seven = 0x00E0, eight = 0x00FE, nine = 0x00E6, ten = 0x000 }; 

	
	
	tempData[0] = LED_2;
	tempData[1] = LED_3;
	tempData[2] = LED_4;
	
	

	for( i = (3 - Bit_NeedSet ); i < Bit_NeedSet; i++)
	{
		if( ( ( tempData[i] >> 8 ) & dot ) != dot )
		{
			dotPosition ++ ;
		}
		else
		{
			break;
		}
	}


	for( i = 2; i < ( 3 - Bit_NeedSet ); i--)
	{
		
		
		switch( ( tempData[ i ] >> 8 ) & 0xFE )
		{
			case zero:
				resultTemp = resultTemp + (0 * temp);
				temp *= 10;
				break;

			case one:
				resultTemp = resultTemp + (1 * temp);
				temp *= 10;
				break;

			case two:
				resultTemp = resultTemp + (2 * temp);
				temp *= 10;
				break;

			case three:
				resultTemp = resultTemp + (3 * temp);
				temp *= 10;
				break;

			case four:
				resultTemp = resultTemp + (4 * temp);
				temp *= 10;
				break;

			case five:
				resultTemp = resultTemp + (5 * temp);
				temp *= 10;
				break;

			case six:
				resultTemp = resultTemp + (6 * temp);
				temp *= 10;
				break;

			case seven:
				resultTemp = resultTemp + (7 * temp);
				temp *= 10;
				break;

			case eight:
				resultTemp = resultTemp + (8 * temp);
				temp *= 10;
				break;

			case nine:
				resultTemp = resultTemp + (9 * temp);
				temp *= 10;
				break;

			case ten:
				resultTemp = resultTemp + (10 * temp);
				temp *= 10;
				break;
		}
	}


	if( resultTemp == 0 )
	{
		result = 0;
	}
	else
	{



		switch( dotPosition )
		{
			case 0:
				result = resultTemp / 100 ;
				break;

			case 1:
				result = resultTemp /10 ;
				break;

			case 2:
				result = resultTemp;
				break;

			default:
				break;
		}
	}
		

}


void Led2Bool(void)
{
	U16 temp;
	if( Bit_NeedSet == 3)
	{
		temp = LED_2;
		switch( temp >> 8  )
		{
			case 0x00FC: //  "0"
				(( Menu_Top_Struct * )ActiveMenuAdd)->data[0] = 0;
				break;

			case 0x0060:   // "1"
				(( Menu_Top_Struct * )ActiveMenuAdd) ->data[0] = 1;
				break;
		}
	}


	temp = LED_3;
	switch( temp >> 8  )
	{
			case 0x00FC: //  "0"
				(( Menu_Top_Struct * )ActiveMenuAdd) ->data[1] = 0;
				break;

			case 0x0060:   // "1"
				(( Menu_Top_Struct * )ActiveMenuAdd) ->data[1] = 1;
				break;
	}


	temp = LED_4;
	switch( temp >> 8  )
	{
			case 0x00FC: //  "0"
				(( Menu_Top_Struct * )ActiveMenuAdd) ->data[2] = 0;
				break;

			case 0x0060:   // "1"
				(( Menu_Top_Struct * )ActiveMenuAdd) ->data[2] = 1;
				break;
	}
}




void SetDotPosition(void)
{
	U16 tempData[3];
	int i;
	
	tempData[0] = LED_2;
	tempData[1] = LED_3;
	tempData[2] = LED_4;
	

	if( dotPosition != 2)
	{
		dotPosition++;
	}
	else
	{
		dotPosition = 0;
	}

	for( i = 0; i < 3; i++)
	{
		tempData[ i ] =  tempData[ i ]  & ( 0xFE << 8 ) ;
	}

	tempData[ dotPosition ] =  tempData[ dotPosition ] + (0x1 << 8 );
	LED_2 = tempData[ 0 ] ;
	LED_3 = tempData[ 1 ] ;
	LED_4 = tempData[ 2 ] ;


}



void ChangeLED(void)
{
	U16 tempData[3] ;
	U16 temp;
	enum  num {zero = 0x00FC, one = 0x0060, two = 0x00DA, three = 0x00F2, four = 0x0066, 
	five = 0x00B6,six = 0x00BE, seven = 0x00E0, eight = 0x00FE, nine = 0x00E6, ten = 0x000 }; 

	temp = tempData[ Cursor ];
	tempData[0] = LED_2;
	tempData[1] = LED_3;
	tempData[2] = LED_4;

     
	if( Menu_Level != 0 )
	{

		switch( ( temp >> 8 ) & 0xFE )
		{
			case zero:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[1] << 8 ) & 0xFE00 );
				break;

			case one:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[2] << 8 ) & 0xFE00 );
				break;

			case two:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[3] << 8 ) & 0xFE00 );
				break;

			case three:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[4] << 8 ) & 0xFE00 );
				break;

			case four:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[5] << 8 ) & 0xFE00 );
				break;

			case five:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[6] << 8 ) & 0xFE00 );
				break;

			case six:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[7] << 8 ) & 0xFE00 );
				break;

			case seven:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[8] << 8 ) & 0xFE00 );
				break;

			case eight:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[9] << 8 ) & 0xFE00 );
				break;

			case nine:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[0] << 8 ) & 0xFE00 );
				break;

			case ten:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[10] << 8 ) & 0xFE00 );
				break;

			default:
				break;
		}
	}
	else
	{
		switch( ( temp >> 8 ) & 0xFE )
		{
			case zero:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[1] << 8 ) & 0xFE00 );
				break;

			case one:
				tempData[ Cursor ] = ( tempData[ Cursor ] & 0x1FF ) & ( ( Num[0] << 8 ) & 0xFE00 );
				break;
		}
	}
	
	LED_2 = tempData[ 0 ];
	LED_3 = tempData[ 1 ];
	LED_4 = tempData[ 2 ];
	
}



void Display_Process(void)
{
	U16 LedValue[3];
	int j,k,l,m;
	
/****************************设定时候的显示*******************/
	if( Func_Select  == Setting )
	{
		

		ActiveMenuAdd = MenuNode_Scan( Protect_Select, Menu_Level );

		if( Menu_Level == 0)
		{
			LED_1 = ((Menu_Top_Struct *)ActiveMenuAdd) -> symbolData[0] ;
			
			if( ( ((Menu_Top_Struct *)ActiveMenuAdd) -> BitNeedSet) !=3 )
			{
				LED_2 = ((Menu_Top_Struct *)ActiveMenuAdd) -> symbolData[1] ;
			}
			else
			{
				Float2Led( *(((Menu_Top_Struct *)ActiveMenuAdd)->data[0]) ,LedValue);
				LED_2 =LedValue[0];   
			}
				
				Float2Led( *(((Menu_Top_Struct *)ActiveMenuAdd)->data[1]),LedValue);
				LED_3 =LedValue[0];

				Float2Led( *(((Menu_Top_Struct *)ActiveMenuAdd)->data[1]),LedValue);
				LED_4 =LedValue[0];
		}

		else
		{
			LED_1 = ((SonMenu_Struct *)ActiveMenuAdd) -> symbolData[0];

			if( (((SonMenu_Struct *)ActiveMenuAdd) -> BitNeedSet) !=3 )
			{
				LED_2 = ((SonMenu_Struct *)ActiveMenuAdd) -> symbolData[1] ;
				Float2Led(  *(((SonMenu_Struct *)ActiveMenuAdd) -> dataAdd),LedValue);
				LED_3 = LedValue[0];
				LED_4 = LedValue[1];
			}

			else
			{
				Float2Led( *(((SonMenu_Struct *)ActiveMenuAdd) -> dataAdd),LedValue );
				LED_2 =  LedValue [0];
				LED_2 =  LedValue [1];
				LED_2 =  LedValue [2];
				
			}
		}
	}
		
/****************************************测量时候的显示***************/
	else
	{
		
		LED_1 = Symbol_Segment[ Protect_Select *2 ] ;
		if( Symbol_Segment[ Protect_Select*2 + 1 ]  != 0 )
		{
			LED_2 = Symbol_Segment[ Protect_Select * 2 + 1 ] ;
			
				Float2Led((*((float *)(*(unsigned long *)(MeasureDisplayData_Add+Protect_Select)))) ,  LedValue);
				
				j= MeasureDisplayData_Add;
				k= *((float *)(*(unsigned long *)(MeasureDisplayData_Add+Protect_Select)));
				LED_3 = LedValue[0];
				LED_4 = LedValue[1] ;
				
		}
			
		else
		{
			LED_2 = LedValue[0];
			LED_3 = LedValue[1];
			LED_4 = LedValue[2];
		}
	}

}

⌨️ 快捷键说明

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