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

📄 mmi.c

📁 msp430与图形液晶接口(12232),需要自己定义字库
💻 C
📖 第 1 页 / 共 5 页
字号:
		case YK_CONFIG_PAGE:
			if (coe_data==0x50) Lprint(3,1,"传动分闸",LCD_NORMAL);
			else if (coe_data==0x60) Lprint(3,1,"传动合闸",LCD_NORMAL);
			#if DEVICE_TYPE==11 || DEVICE_TYPE==21
				else if (coe_data==0x10) Lprint(3,1,"传动控一",LCD_NORMAL);
				else if (coe_data==0x20) Lprint(3,1,"传动控二",LCD_NORMAL);
				else if (coe_data==0x30) Lprint(3,1,"传动控三",LCD_NORMAL);
				else if (coe_data==0x40) Lprint(3,1,"传动控四",LCD_NORMAL);
			#endif
			#if DEVICE_TYPE==35
				else if (coe_data==0x10) Lprint(3,1,"传动跳低侧",LCD_NORMAL);
				else if (coe_data==0x40) Lprint(3,1,"传动跳母联",LCD_NORMAL);
				else if (coe_data==0x18) Lprint(3,1,"传动跳三侧",LCD_NORMAL);
			#endif
			#if DEVICE_TYPE==45 || DEVICE_TYPE==46
				else if (coe_data==0x10) Lprint(3,1,"传动跳高侧",LCD_NORMAL);				
				else if (coe_data==0x40) Lprint(3,1,"传动跳母联",LCD_NORMAL);
				else if (coe_data==0x20) Lprint(3,1,"传动主变升",LCD_NORMAL);
				else if (coe_data==0x30) Lprint(3,1,"传动主变降",LCD_NORMAL);
			  else if (coe_data==0x18) Lprint(3,1,"传动跳三侧",LCD_NORMAL);
			#endif	
			Lprint(0,0,config_str,LCD_NORMAL);	
			if (arrow_state==0x55)
			{
				if(arrow_point==0) Lprint(0,0,arrow_str,LCD_NORMAL);
				else if(arrow_point==1) Lprint(7,0,arrow_str,LCD_NORMAL);				
			}		
		break;
		case MODIFY_PAGE :	//修改页
			Lprint(0,1,modify_str[0],LCD_NORMAL);			
			Lprint(0,0,modify_str[1],LCD_NORMAL);	
			if (arrow_state==0x55)
			{
				if(arrow_point==0) Lprint(0,1,arrow_str,LCD_NORMAL);
				else if(arrow_point==1) Lprint(8,1,arrow_str,LCD_NORMAL);
				else if(arrow_point==2) Lprint(0,0,arrow_str,LCD_NORMAL);
				else if(arrow_point==3) Lprint(8,0,arrow_str,LCD_NORMAL);
			}
		break;
		case TIME_PAGE:		//时间页
			Lprint(4,1,time_str[0],LCD_NORMAL);
			Lprint(4,0,time_str[1],LCD_NORMAL);
			dis_time_dynamic_page();
		break;
		case KCH_PAGE:		//系数页
			for(i=0;i<2;i++)
			{
				Lprint(0,1-i,kch_str[page_point*2+i],LCD_NORMAL);		
				Lprint(9,1-i,".",LCD_NORMAL);				
				dec_to_4bit(&bit[0],kch_data[page_point*2+i]);
				pp=cursor_point+cursor_line*4;
				for(j=0;j<4;j++)
				{
					if(j==0) x=8+j;
					else x=9+j;
					sprintf(s,"%d\0",bit[j]);					
					if ((j+i*4)==pp && cursor_state==0x55) Lprint(x,1-i,s,LCD_UNDERLINE);	
					else Lprint(x,1-i,s,LCD_NORMAL);
				}			
			}
		break;
		case SET_PAGE:			//定值页	
			for(i=0;i<2;i++)
			{
				Lprint(0,1-i,set_str[page_point*2+i],LCD_NORMAL);	
				type=set_type[page_point*2+i];
				if (type!=0x55)		//显示数据不为空
				{
					v=set_data[page_point*2+i];					
					if (cursor_state==0x55 && i==cursor_line)	ll=0x55;
					else ll=0;
				  if (type>=4 && type<=7) //投退
				  {
				  	if (ll==0x55)	Lprint(10,1-i,"_",LCD_NORMAL);			
				  	if (type==4 || type==5)				  	
				  		Lprint(11,1-i,ll_str[(type-4)*2+v],LCD_NORMAL);
				  	else 	
				  		Lprint(11,1-i,ll_str[(type-6)*3+v+4],LCD_NORMAL);
				  }			
				  else
				  { 				  	
					  set_data_handle(page_point*2+i);	
					  v=set_data[page_point*2+i];			
				  	if (type==0 || type==1 || type==8 || type==9) //四位数包括0位/1位/2位小数
					  {					  	
					  	
					  	if (type==8)pp=8;		//频率显示向前提一位(单位HZ占2个字符)
					  	else	pp=9;
					  	dec_to_4bit(&bit[0],v);				
					  	s_enable=0;					
					  	if (type==0  || type==8) xsd=2;	//2位小数
					  	else if (type==1) xsd=3;	//1位小数
					  	else xsd=4;		//无小数
					  	if (type!=9) 	Lprint(pp+xsd,1-i,".",LCD_NORMAL);	
					  	for(j=0;j<4;j++)
					  	{
					  		sprintf(s,"%d\0",bit[j]);
					  		if(type!=9)
					  		{
					  			if(j<xsd) x=pp+j;
									else x=pp+1+j;
								}
								else x=pp+2+j;
								if (ll==0x55)		//有光标选定情况下显示所有数字
								{
						  		if (j==cursor_point ) Lprint(x,1-i,s,LCD_UNDERLINE);	
									else Lprint(x,1-i,s,LCD_NORMAL);
								}
								else	
								{	
									if (bit[j]>0) s_enable=0x55;				
									if (s_enable==0x55 || j>=(xsd-1)) Lprint(x,1-i,s,LCD_NORMAL);
								}
					  	}
					  }
					  else  if (type==2 ) //3位数不包括小数
					  {				  	
					  	dec_to_3bit(&bit[0],v);			
					  	s_enable=0;	
					  	for(j=0;j<3;j++)
					  	{
					  		sprintf(s,"%d\0",bit[j]);
				  			x=11+j;							
								if (ll==0x55)		//有光标选定情况下显示所有数字
								{
						  		if (j==cursor_point ) Lprint(x,1-i,s,LCD_UNDERLINE);	
									else Lprint(x,1-i,s,LCD_NORMAL);
								}
								else	
								{	
									if (bit[j]>0) s_enable=0x55;											
									if (s_enable==0x55 || j==2) 	Lprint(x,1-i,s,LCD_NORMAL);
								}
					  	}
					  }
					  else  if (type==3 ) //2位数不包括小数
					  {					  	
					  	dec_to_2bit(&bit[0],v);				
					  	for(j=0;j<2;j++)
					  	{
					  		sprintf(s,"%d\0",bit[j]);
				  			x=9+j;							
								if (ll==0x55)		//有光标选定情况下显示所有数字
								{
						  		if (j==cursor_point ) Lprint(x,1-i,s,LCD_UNDERLINE);	
									else Lprint(x,1-i,s,LCD_NORMAL);
								}
								else	
								{					
									if (bit[j]>0 || j==1) Lprint(x,1-i,s,LCD_NORMAL);
								}
					  	}
					  }
					}
				}
			}
		break;
		case COM_PAGE:		//通讯页
			Lprint(0,1,com_str[0],LCD_NORMAL);			
			Lprint(0,0,com_str[1],LCD_NORMAL);	
		break;
		case ASP_PAGE:		//ASP页			
			Lprint(0,1,asp_str[asp_line_point*2],LCD_NORMAL);			
			Lprint(0,0,asp_str[asp_line_point*2+1],LCD_NORMAL);	
			if (asp_line_point==0) //显示动作值
			{
				sprintf(s,"%d\0",page_point);
				Lprint(4,1,s,LCD_NORMAL);		
				tt=asp_data[page_point].type;
				if (tt<48)
					Lprint(6,1,asp_type_str[tt],LCD_NORMAL);	//动作类型
				else
					Lprint(6,1,"无",LCD_NORMAL);	//动作类型
				if (tt<48)
					pp=asp_unit_index[tt];
				else
					pp=0;
				if (pp==3)    // 频率占2位
				  Lprint(13,0,asp_unit_str[pp],LCD_NORMAL);		//单位
				else
				  Lprint(14,0,asp_unit_str[pp],LCD_NORMAL);		//单位
				if(pp!=0)
				{					
					f=(float)asp_data[page_point].data;					
					if (pp==1)				// 电流0
						f=f*100/8191;
					else if(pp==2)		// 电压
						f=f*140/8191;
					else if(pp==3)		// 频率
						f=f/1000;
					sprintf(s,"%5.3f\0",f);								//动作值
					Lprint(7,0,s,LCD_NORMAL);
				}
				pp=asp_data[page_point].phase;
				if (pp>0 && pp<4)
				{
					if (tt==45 || tt==46)	//过流1段\2段显示不下了
						Lprint(14,1,asp_phase_str[pp],LCD_NORMAL);	//动作相
					else
					{
						Lprint(12,1,asp_phase_str[pp],LCD_NORMAL);	//动作相
						Lprint(13,1,"相",LCD_NORMAL);
					}
				}
			}
			else 			//显示时间
			{			
				sprintf(s,"%4d\0",(asp_data[page_point].year+2000));
				Lprint(0,1,s,LCD_NORMAL);
				sprintf(s,"%2d\0",asp_data[page_point].month);
				Lprint(6,1,s,LCD_NORMAL);			
				sprintf(s,"%2d\0",asp_data[page_point].day);
				Lprint(10,1,s,LCD_NORMAL);
				sprintf(s,"%2d\0",asp_data[page_point].hour);
				Lprint(2,0,s,LCD_NORMAL);
				sprintf(s,"%2d\0",asp_data[page_point].minute);
				Lprint(6,0,s,LCD_NORMAL);
				sprintf(s,"%2d\0",asp_data[page_point].second);
				Lprint(10,0,s,LCD_NORMAL);	
			}
		break;
		case MODIFY_RETUREN_PAGE:
			Lprint(4,1,modify_return_str,LCD_NORMAL);	
			if (write_eep_ok==0x55)
				Lprint(6,0,"成功",LCD_NORMAL);	
			else
				Lprint(6,0,"失败",LCD_NORMAL);	
		break;
		case READ_WAIT_PAGE:
			Lprint(4,1,read_wait_str[0],LCD_NORMAL);	
			Lprint(4,0,read_wait_str[1],LCD_NORMAL);	
		break;
		case COE_WAIT_PAGE:
			Lprint(2,1,coe_wait_str[0],LCD_NORMAL);	
			Lprint(2,0,coe_wait_str[1],LCD_NORMAL);
		break;
		case COE_RETURN_PAGE:
			if (coe_return_data==0x31)		//传动成功
				Lprint(0,1,coe_return_str[0],LCD_NORMAL);	
			else					
			{
				Lprint(0,1,coe_return_str[1],LCD_NORMAL);//传动失败
				if (coe_return_data==0x52)	//硬压板未投入
					Lprint(0,0,coe_return_str[2],LCD_NORMAL);
				else if (coe_return_data==0x51)												//校验错
					Lprint(0,0,coe_return_str[3],LCD_NORMAL);
				else if (coe_return_data==0x53)												//五防闭锁
					Lprint(0,0,coe_return_str[4],LCD_NORMAL);
			}
		break;
		case ERRO_PAGE:			
				Lprint(3,1,erro_str[erro_point],LCD_NORMAL);				
		break;
		case HELP_PAGE:
			Lprint(1,1,help_str[0],LCD_NORMAL);	
			Lprint(2,0,help_str[1],LCD_NORMAL);
		break;
		case RDR_PAGE:			
			Lprint(2,1,"地址:     H",LCD_NORMAL);	
			hex_to_4bit(&bit[0],rdr_addr_bak);
			for(i=0;i<4;i++)
			{
				sprintf(s,"%1x\0",bit[i]);
				if (cursor_state==0x55 && i==cursor_point)
					Lprint(7+i,1,s,LCD_UNDERLINE);	
				else
					Lprint(7+i,1,s,LCD_NORMAL);	
			}
			for(i=0;i<3;i++)
			{
				hex_to_4bit(&bit[0],rdr_data[i]);
				for(j=0;j<4;j++)
				{
					sprintf(s,"%1x\0",bit[j]);
					Lprint(5*i+j,0,s,LCD_NORMAL);	
				}
			}
		break;
		case LOCK_PAGE:
			Lprint(0,1,lock_str[0],LCD_NORMAL);	
			Lprint(0,0,lock_str[1],LCD_NORMAL);
			sprintf(s,"%2d\0",main_type);	
			Lprint(5,0,s,LCD_NORMAL);
			sprintf(s,"%2d\0",DEVICE_TYPE);	
			Lprint(13,0,s,LCD_NORMAL);
		break;
		case YK_ENABLE_PAGE:
			if(yk_enable_flag==0x55)
			{
				Lprint(0,1,yk_enable_str[0],LCD_NORMAL);	
				Lprint(0,0,yk_enable_str[1],LCD_NORMAL);
				sprintf(s,"%1d\0",yk_enable_count);	
				Lprint(12,1,s,LCD_NORMAL);
			}
			else Lprint(0,1,yk_enable_str[2],LCD_NORMAL);	
			
		break;
		default:			
		break;
	}
}

void key_in()
{	
	INT8U key1,key2;
	if (key_hnd_delay>0)
	{
		key_hnd_delay--;
		return;
	}
	key1=~P6IN & 0x3f ;	
	key2=~P5IN& 0xe0;
	if (key1!=0 && key2==0)		key_now=key1;
	else if (key1==0 && key2!=0)	key_now=key2 | 0x0f;   //避免YK键和普通操作键重复
	else key_now=0;
	if (key_now!=NO_KEY)
	{		
		if(key_now==key_now_bak)
		{	
			key_count++;			
			if (key_count>50)			
			{
				key_hnd_delay=500;	//连续按键0.5S处理一次
				key_code=key_now;
				key_count=0;
				key_now_bak=0;
			}
		}
		key_now_bak=key_now;
	}
	else
	{
		key_code=0;
		key_count=0;
		key_now_bak=0;
	}
}
void  key_init()
{
	current_page=MAIN_PAGE;
	key_code=0;
	page_point=0;
	arrow_state=0;
	arrow_point=0;
  lcd_display_handle(current_page);
  sys_lock=0;
  no_key_time=0;
}
void key_handle(INT8U key)
{
	INT8U type;	
	INT8U pp;
	INT16U dd;
 	INT8U select_num;
 	INT8U bit[4];
 	key_code=0;
 	no_key_time=0; 	
 	if (sys_lock==0x55)
 	{
 		current_page=LOCK_PAGE;
 		if (lcd_off_flag==0x55)	//有键按下点亮液晶
	 	{
	 		lcd_off_flag=0;
			LCD_on();		
			LCD_clear();			
	 	}
	 	lcd_display_handle(current_page);		
		return;
 	} 	
 	if (lcd_off_flag==0x55)	//有键按下点亮液晶
 	{
 		lcd_off_flag=0;
		LCD_on();		
		LCD_clear();
		lcd_display_handle(current_page);		
		return;
 	}
 	lcd_off_flag=0; 	
 	#if DEVICE_TYPE != 61 		//主变综合装置无YK
 	if (key==KEY_YK_ENABLE)
 	{
 		yk_enable_count++;
 		yk_enable_time=5;
 		yk_enable_flag=0x55;
 		current_page=YK_ENABLE_PAGE;
 		lcd_display_handle(current_page);		
 		return;
	}
 	if (key==KEY_CLOSE || key==KEY_TRIP)
 	{
 		if( yk_enable_count==3)
 		{
 			yk_enable_flag=0;
	 		yk_enable_count=0;
	 		if (key==KEY_CLOSE)		coe_data=0x60;
	 		else coe_data=0x50;
	 		coe_data_bak=coe_data;
	 		coe_flag=0x55;
	 		current_page=COE_WAIT_PAGE;;
 			lcd_display_handle(current_page);		
 		}
 		else
 		{
 			yk_enable_flag=0;
 			yk_enable_count=0;
 			current_page=YK_ENABLE_PAGE;
 			lcd_display_handle(current_page);		
 		}
 		return;
 	}
 	yk_enable_count=0;
 	#endif
 	if (current_page==MAIN_PAGE) 	//主菜单
 	{
 	  if  ( arrow_state==0)	//主菜单下无光标选定
 	  {
      if (key==KEY_LEFT || key==KEY_RIGHT || key==KEY_UP || key==KEY_DOWN) 	
      {
        page_point=(page_point+1) % 2;
      }
      else if (key==KEY_ENTER)
      {
        arrow_state=0x55;
        arrow_point=0;
      }
      else if (key==KEY_ESC)
      {
      	if (asp_erro_flag==0x55)	asp_erro_flag=0;
    	}
 		}
 		else	//主菜单下有光标选定
 		{
      if (key==KEY_ESC)
      {
        arrow_state=0;
      }
      else if (key==KEY_RIGHT || key==KEY_LEFT)
      {
     		if (arrow_point==0 || arrow_point==2)
        	arrow_point++;
        else
        	arrow_point--;
      }
     else if (key==KEY_UP || key==KEY_DOWN)
      {
     		if (arrow_point==0 || arrow_point==1)
        	arrow_point+=2;
        else
        	arrow_point-=2;
      }
      else if (key==KEY_ENTER)
      {
      	pp=arrow_point+page_point*4;      	
      	if (pp==0 )				//主菜单下选定测量
      	{      		
      		current_page=YC_PAGE;
      		page_point=0;
      		drf_flag=0x55;
      	}
      	else if (pp==1)		//主菜单下选定状态
      	{      		

⌨️ 快捷键说明

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