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

📄 jk0061119_lcd._h

📁 Modbus RTU 的C语言程序
💻 _H
📖 第 1 页 / 共 2 页
字号:
void  read_EEprom_to_array(char address_array,char *pointer_EE,char i);
void  read_Data_to_array(char address_array,char i);
void  Var_4_throw_5_in(void);
//void error_read_EEprom(char address_array,char error_data);
/////////////////////////////////////////////////////////////
void ser_in( char c)/*serial输入程序*/
{
    char BitCnt;   
   for(BitCnt=0;BitCnt<8;BitCnt++)  
     {
	  if((c<<BitCnt)&0x80)PORTA|=0x02;
	  else  PORTA&=0xFD; /// 1111 0111                          
      PORTA|=0x04;     
      PORTA&=0xFB;
	  }
 } 
/////////////////////////////////////////////////////
void wcode ( char cmd)/*写命令*/
{     
  PORTA&=0xFE;
  delay(1);
  PORTA|=0x01;
  ser_in(0xf8);
  ser_in(cmd&0xf0);
  ser_in((cmd&0x0f)<<4);
}
////////////////////////
void wdata( char dat)/*写数据*/
{
 // delayBF(); 
  PORTA&=0xFE;
  delay(1);
  PORTA|=0x01;
  ser_in(0xfa);
  ser_in(dat&0xf0);
  ser_in((dat&0x0f)<<4);
   
}

void  LCD_display(void)
{
    char  i;
    wcode(0x30);//切换为普通功能
	wcode(0x80);//地址归0
	wcode(0x34);//切换为扩展功能
	P_LCD_display=LCD_Display_ram;
	for(i=0;i<64;i++)
	 {
	    WDR(); 
	    wdata(*P_LCD_display);
		P_LCD_display++;
	  }
 }
unsigned int  calcul_value_decimal(unsigned int c,unsigned int a)
{
     
     temp_temp=c;
	 temp_temp*=a;
	 c=temp_temp%4095;
	 //c=temp_temp%3276;
	 //if(c>1638)
	 if(c>2047)
	 c=1;
	 else
	 c=0;
	 //temp_temp/=3276;
	 temp_temp/=4095;
	 c+=temp_temp;
	 return(c);   
 }
////////////////////////////
void  calcul_value_ASCLL_potentiometer(unsigned int c)///本函数仅在校准系数时用到
{
    unsigned int a;
	WDR(); 
    a=c/1000;
	ASCLL_byte1_potentiometer=a+0x30;
	if(ASCLL_byte1_potentiometer==0x30)
	ASCLL_byte1_potentiometer=0x20;
	c=c%1000;
	a=c/100;
	ASCLL_byte2_potentiometer=a+0x30;
	if((ASCLL_byte2_potentiometer==0x30)&&(ASCLL_byte1_potentiometer==0x20))
	ASCLL_byte2_potentiometer=0x20;
	c=c%100;
	a=c/10;
	ASCLL_byte3_potentiometer=a+0x30;
	c=c%10;
	ASCLL_byte4_potentiometer=c+0x30;
 }
 ////////////////////////////////////////////////////
void  calcul_value_ASCLL(unsigned int c)
{
    unsigned int a;
	WDR(); 
    a=c/1000;
	ASCLL_byte1=a+0x30;
	if(ASCLL_byte1==0x30)
	ASCLL_byte1=0x20;
	c=c%1000;
	a=c/100;
	ASCLL_byte2=a+0x30;
	if(ASCLL_byte1<0x30)
	    if(ASCLL_byte2==0x30)
	        ASCLL_byte2=0x20;
	c=c%100;
	a=c/10;
	ASCLL_byte3=a+0x30;
	c=c%10;
	ASCLL_byte4=c+0x30;
 }
 /////////////////////////////////////////////////
void  LCD_map0_ready(void)
{
    char i;
	read_EEprom_to_array(0,HM,4);
	read_EEprom_to_array(4,DY,5);
	read_EEprom_to_array(16,CD,4);
	read_EEprom_to_array(20,DL,5);
	read_EEprom_to_array(32,KM,4);
	read_EEprom_to_array(36,DY,5);
	read_EEprom_to_array(48,KM,4);
	read_EEprom_to_array(52,DL,5);
	LCD_Display_ram[15]=0x56;
	LCD_Display_ram[47]=0x56;
	LCD_Display_ram[31]=0x41;
	LCD_Display_ram[63]=0x41;
	calcul_value_ASCLL(calcul_value_decimal(v_HM_Voltage,3000));
	read_Data_to_array(9,4);
	LCD_Display_ram[13]=ASCLL_byte4;
	calcul_value_ASCLL(calcul_value_decimal(v_KM_Voltage,3000));
	read_Data_to_array(41,4);
	LCD_Display_ram[45]=ASCLL_byte4;
	calcul_value_ASCLL(calcul_value_decimal(A_CD_Current,*A_Current_BypassSensor));
	read_Data_to_array(25,4);
	LCD_Display_ram[29]=ASCLL_byte4;
	calcul_value_ASCLL(calcul_value_decimal(A_KM_Load_Current,*A_Current_Sensor));
    read_Data_to_array(57,4);
	LCD_Display_ram[61]=ASCLL_byte4;
	for(i=0; i<4; i++)
	    LCD_Display_ram[12+i*16]=0x2E;
 }
 void  LCD_map1_ready(void)
 {
    read_EEprom_to_array(4,ZC,4);
	read_EEprom_to_array(8,XX,4);
	read_EEprom_to_array(20,SJ,4);
	read_EEprom_to_array(24,CX,4);
	read_EEprom_to_array(36,CS,4);
	read_EEprom_to_array(40,SZ,4);
	read_EEprom_to_array(52,BB,4);
	read_EEprom_to_array(56,XX,4);
	if(press_key_value_pc0==1)
	  {
	     LCD_Display_ram[1]=0x02;
	          LCD_Display_ram[2]=0x1A;
	   }
	else if(press_key_value_pc0==2)
	  {
	     LCD_Display_ram[33]=0x02;
	          LCD_Display_ram[34]=0x1A;
	   }
	else if(press_key_value_pc0==3)
	  {
	     LCD_Display_ram[17]=0x02;
	          LCD_Display_ram[18]=0x1A;
	   }
	else
	  {
	     LCD_Display_ram[49]=0x02;
	          LCD_Display_ram[50]=0x1A;
	   }
	
  }
 void  LCD_map2_ready(void)
 {
    char i;
	for(i=0; i<4; i++)
		LCD_Display_ram[i*16+15]=0x41;
	read_EEprom_to_array(2,FLQ,7);
	calcul_value_ASCLL(*A_Current_BypassSensor);
	read_Data_to_array(11,3);
	//////////////////////////////////////
	read_EEprom_to_array(18,FC,4);
	read_EEprom_to_array(22,DL,5);
	calcul_value_ASCLL(*A_Current_FC);
	read_Data_to_array(27,2);
	
	/////////////////////////////////
	read_EEprom_to_array(34,JC,4);
	read_EEprom_to_array(38,DL,5);
	calcul_value_ASCLL(*A_Current_JC);
	read_Data_to_array(43,2);
	/////////////////////////////
	read_EEprom_to_array(50,ZH,4);
	read_EEprom_to_array(54,DL,5);
    calcul_value_ASCLL(*A_Current_FC_Change_JC);
    read_Data_to_array(59,2);
  }
  void  LCD_map3_ready(void)
 {
    char i;
    read_EEprom_to_array(2,HM,4);
	read_EEprom_to_array(6,GY,5);
	calcul_value_ASCLL(calcul_value_decimal(*Voltage_HM_High_Alarm,3000));
	Var_4_throw_5_in();
    read_Data_to_array(11,3);
	///////////////////////////////
	read_EEprom_to_array(34,HM,4);
	read_EEprom_to_array(38,QY,5);
	calcul_value_ASCLL(calcul_value_decimal(*Voltage_HM_Low_Alarm,3000));
	Var_4_throw_5_in();
    read_Data_to_array(43,3);
	/////////////////////////////////////
	read_EEprom_to_array(18,KM,4);
	read_EEprom_to_array(22,GY,5);
	calcul_value_ASCLL(calcul_value_decimal(*Voltage_KM_High_Alarm,3000));
	Var_4_throw_5_in();
    read_Data_to_array(27,3);
	//////////////////////////////////////////
	read_EEprom_to_array(50,KM,4);
	read_EEprom_to_array(54,QY,5);
	calcul_value_ASCLL(calcul_value_decimal(*Voltage_KM_Low_Alarm,3000));
	Var_4_throw_5_in();
    read_Data_to_array(59,3);
	for(i=0; i<4; i++)
	  { 
	    LCD_Display_ram[i*16+15]=0x56;
	  }
  }
  void  LCD_map4_ready(void)
 {
   	read_EEprom_to_array(2,CGQ,7);
	calcul_value_ASCLL(*A_Current_Sensor);
	read_Data_to_array(11,3);
	LCD_Display_ram[15]=0x41;
	//////////////////////////////////////////////
	read_EEprom_to_array(18,JC,4);
	read_EEprom_to_array(22,XS,5);
	calcul_value_ASCLL(*Time_Limited_JC);
	read_Data_to_array(28,1);
	LCD_Display_ram[31]=0x6D;
	//////////////////////////////////////////////
	read_EEprom_to_array(34,JC,4);
	read_EEprom_to_array(38,JG,5);
	calcul_value_ASCLL(*Time_Interval_JC);
	LCD_Display_ram[43]=ASCLL_byte1;
	LCD_Display_ram[44]=ASCLL_byte2;
	LCD_Display_ram[45]=ASCLL_byte3;
	LCD_Display_ram[46]=ASCLL_byte4;
	LCD_Display_ram[47]=0x68;
	////////////////////////////////////////
	read_EEprom_to_array(50,JC,4);
	read_EEprom_to_array(54,YS,5);
	calcul_value_ASCLL(*Time_Delay_JC);
	read_Data_to_array(60,1);
	LCD_Display_ram[63]=0x6D;
   }
 void  LCD_map5_ready(void)
 {
    char i;
	P_LCD_display=LCD_Display_ram;
	P_LCD_display+=32;
	EEPROMReadBytes((int)&password_in_1,P_LCD_display,16);
	P_LCD_display+=16;
	EEPROMReadBytes((int)&password_in_2,P_LCD_display,16);
	i=press_key_value_pc2;
	if(i<5)
	 {   
	    LCD_Display_ram[21+i]=0x19;
	    LCD_Display_ram[53+i]=0x30+press_key_value_pc0;
     }
  }
void  LCD_map6_ready(void)
{
    P_LCD_display=LCD_Display_ram;
	EEPROMReadBytes((int)&Copyright,P_LCD_display,16);
	P_LCD_display+=16;
	EEPROMReadBytes((int)&TEL,P_LCD_display,16);
	P_LCD_display+=16;
	EEPROMReadBytes((int)&GTMBU,P_LCD_display,16);
	P_LCD_display+=16;	
	EEPROMReadBytes((int)&FAX,P_LCD_display,16);
}
void  LCD_map7_ready(void)
{
   char  i;
   P_LCD_display=LCD_Display_ram;
	EEPROMReadBytes((int)&password_error_1,P_LCD_display,16);
	P_LCD_display+=16;
	EEPROMReadBytes((int)&password_error_3,P_LCD_display,16);
	P_LCD_display+=16;
	EEPROMReadBytes((int)&password_error_2,P_LCD_display,16);
    P_LCD_display+=16;
	EEPROMReadBytes((int)&TEL,P_LCD_display,16);
 }
/////////////
void  LCD_map8_ready(void)
{
    read_EEprom_to_array(0,WSJ,10);
}
/////////////////////////////////////////////////////////////////////////////
     
void  LCD_map11_ready(void)//分流器设置
  {
     if(Flag_press_key)	    
	    calcul_value_ASCLL(*A_Current_BypassSensor);
	 read_EEprom_to_array(32,FLQ,6);
	  read_EEprom_to_array(38,SZ,5);
	 LCD_Display_ram[56]=ASCLL_byte3;
	 if(ASCLL_byte2==0x20)
		   ASCLL_byte2=0x30;
	 LCD_Display_ram[55]=ASCLL_byte2;
	 if(ASCLL_byte1==0x20)
	   ASCLL_byte1=0x30;
	 LCD_Display_ram[54]=ASCLL_byte1;
	 LCD_Display_ram[57]=0x41;
   }
void  LCD_map12_ready(void)//均充电流设置
{
	 if(Flag_press_key)	    
	    calcul_value_ASCLL(*A_Current_JC);

⌨️ 快捷键说明

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