⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display.c

📁 cs5460a做功率表用 cs5460a做功率表用 cs5460a做功率表
💻 C
字号:
/**********************************************
公司名称:
文 件 名: 
版 本 号:
程序设计:
说    明:
完成日期:
修改日期:
功能摘要:	
***********************************************/
#define _Display
#include "includes.h"

const uint8 LedTab[] PROGMEM={
                          		    0x3F,0x06,0x5B,0x4F,0x66,
	       	              			0x6D,0x7D,0x07,0x7F,0x6F, /*0-9*/

									0xBF,0x86,0xDB,0xCF,0xE6,
	       	              			0xED,0xFD,0x87,0xFF,0xEF, /*0.-9.*/

	                      			0x77,0x7C,0x39,0x5E,0x79, /*A\b \C\d\E*/
	      	              			0x71,0x6f,0x74,0x06,0x1e, /*F\g \h\I\J*/
                          		    0x00,0x38,0x00,0x37,0x3F, /*K\L \M\N\O*/
	                      			0x73,0xBF,0x50,0x6D,0x78, /*P\0.\R\S\T*/
                          		    0x3E,0x3E,0x00,0x00,0x6E, /*U\V\W\X\Y*/
                          		    0x5B,0x40,                /*Z\-\*/
									0x00,					  //47
	                     		};

uint8 Led[lighten_size];
uint8 DispBuf[lighten_size];
uint8 fDispNow = 0;         //要求立刻显示标志
volatile uint8 fTimer0_1ms;
WAIT_TIME_STRUCT	Refresh_AD = {0,_500MS};
void DispPinInit(void);
void DispProcess(void);
void HC164SendByte(uint8 byte);
void DispPinInit(void);
void  SETB_IO(uint8 IO_NO);			      //位选口的控制

//--------------------------------------------

#define   bit_shut()  \
do			\
{		DIG1=OFF;\
		DIG2=OFF;\
		DIG3=OFF;\
		DIG4=OFF;\
		DIG5=OFF;\
}while(0)

//------------------------------
SIGNAL(SIG_OVERFLOW0)    
{
   static uint8 LedNum = 0;
   
   TCNT0 = 0x100 - (uint32)((float)F_CPU * CLOCK_TIME0 / F_N_TIME0 / 1000);   
      
   DispPinInit();
   HC164SendByte(Led[LedNum]);         				//送段码
   if (LedNum > 4)  bit_shut();
   else SETB_IO(LedNum);             		//送位选
   if (++LedNum == lighten_size) LedNum = 0;         
}
//---------------------------------------------

void  HC164SendByte(uint8 byte)	
{	
   unsigned char i;
    HC164_CLK = 0;
   for(i=0;i<8;i++)
    {	
   	    HC164_CLK=0;
   		if( byte&0x80 )
		  { HC164_Data=1; }
   		else
		  { HC164_Data=0; }
		byte<<= 1; 
		HC164_CLK=1;

    }	  
}

//----------------------------------------------

void SETB_IO(uint8 IO_NO)	  	
{
	bit_shut();
	switch (IO_NO)		
		{
			case 0:	DIG1=ON;break;
			case 1:	DIG2=ON;break;
			case 2:	DIG3=ON;break;
			case 3:	DIG4=ON;break;
			case 4:	DIG5=ON;break;			
	  		default:        break;
		}
}


//----------------------------------------------
void  DispProcess(void)           //显示段码转换函数
{
  uint8 i;
  static uint8 DispTime = 0;

  if ((Refresh_AD.fGetTime) || (fDispNow))
     {
       Refresh_AD.fGetTime = 0;
       Refresh_AD.WaitTime = _500MS;

//----------------------------------------------------------------
       if (TaskID == 0)
	      {
       	 	 DispBuf[ROW_5] = HIDE;
      	     DoPot(&DispBuf[ROW_1],Ps);
      	     if (Ps_Neg == 1) DispBuf[ROW_5] = 46;
/*			DispBuf[ROW_5] = HIDE;
			DispBuf[ROW_4] = HIDE;
			DispBuf[ROW_3] = HIDE;
			DispBuf[ROW_2] = HIDE;
			DispBuf[ROW_1] = HIDE;

			if (V_sign_A == 1) DispBuf[ROW_5] = 46;
			if (I_sign_A == 1) DispBuf[ROW_4] = 46;
			if (V_sign_B == 1) DispBuf[ROW_3] = 46;
			if (I_sign_B == 1) DispBuf[ROW_2] = 46;*/
           }
        DispTime++;
//-----------------------------------------------------------------		      
       
        for (i=0; i<lighten_size; i++)     //进行显示数据更新
            { Led[i] = pgm_read_byte(&LedTab[DispBuf[i]]);  }      
        if (DispTime >= 2)  //进行闪烁处理
          {
             DispTime = 0;
             if (TaskID == 0) 
			    {
           		   if ((!(AlarmSwitch & 0x01)) && fH_Alarm) 
				      {  Dis_info(&DispBuf[ROW_5],"h-alr");	}
            
           		   if ((!(AlarmSwitch & 0x01)) && fL_Alarm)
				      {	Dis_info(&DispBuf[ROW_5],"l-alr");	}
           		 
           		   for (i=0; i<lighten_size; i++)    //进行显示数据更新
       				  {  Led[i] = pgm_read_byte(&LedTab[DispBuf[i]]);} 
                  }
           }             
       }
   fDispNow = 0;
}
//----------------------------------------------
void DispPinInit(void)
{
    PORTB &= 0xF8;
    PORTD &= 0x3f;      
}
//----------------------------------------------

⌨️ 快捷键说明

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