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

📄 display.c

📁 电力行业必备。有错的地方
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                               	江苏广一科技有限公司
**                                     研    发    部
**                                        浙江配变
**
**                                 
**
**--------------文件信息--------------------------------------------------------------------------------
**文   件   名: display.c
**创   建   人: 
**最后修改日期: 2007年10月17日
**描        述: 
**              
**--------------历史版本信息----------------------------------------------------------------------------
** 创建人: 
** 版  本: 
** 日 期: 
** 描 述: 
**
**--------------当前版本修订------------------------------------------------------------------------------
** 修改人: 
** 日 期: 
** 描 述: 
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#define  DISPLAY_GLOBALS 

#include "display.h"
#include "XLCD.h"
#include "powerram.h"
#include "COMM.h"
#include "gprsmanag.h"
#include "main.h"
#include "Clock.H"
#include "stipulparse.h"
#include "GPRS.h"
#include "curdata.h"
/*********************************************************************************************************
** 函数名称: display
** 功能描述: 显示函数
**
** 输 入: 	
**		
** 输 出:  
**         
** 全局变量: 
** 调用模块: 
**
** 作 者: 
** 日 期: 
**-------------------------------------------------------------------------------------------------------
** 修改人:
** 日 期:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void display(void)
{
	
	uint8	buf[32];
	//uint8	i;
	//uint8	len;
	uint16	time[7];
	//uint8	err;
	uint8	temp;
	//static	uint8	counter;
	static	uint8	page;											// 显示页记录
	//static 	uint8	signal;											// 信号强度
	static	uint8	logsuc;											// 登录成功
	uint8	flag;
	
	
	
	if (page>=9)
	{
		page = 0;
	}
	/*
	if ((counter>10)&&(GprsManagPar.on))
	{
		//signal = 0;
		counter = 0;
		buf[0] = 0x20;													// 读GPRS信号强度
		buf[1] = 0xE3;
		OSMutexPend(Comm_Sem, 0, &err);
		GprsInitFlag = 1;
		ReadGprsCmd(buf);
		//GprsInitFlag = 0;
		OSMutexPost(Comm_Sem);
		OSTimeDly(200);
		//while ((len=ReadGprsBuf())==0);
		OSMutexPend(Comm_Sem, 0, &err);
		//GprsInitFlag = 1;
		len = ReadGprsBuf();
		GprsInitFlag = 0;
		OSMutexPost(Comm_Sem);
		if (len!=0)
		{
			for (i=0;i<len;i++)
			{
				if (GprsCommBuf[i]==0x68)
				{
					if ((GprsCommBuf[i+7]==0x68)&&(GprsCommBuf[i+15]==0x16)&&
						(GprsCommBuf[i+10]==0x20)&&(GprsCommBuf[i+11]==0xE3))
					{
						CommFlush(COMM2);	
						signal = GprsCommBuf[i+12];
						break;
					}	
				}
				else
				{
					continue;
				}
			}									
		}
	}
	else
	{
		counter ++;
	}
	*/
	logsuc = 0;
	if (GPRSIsOnline())
	{
		logsuc = 1;
	}
	DateTimeRead(&time[0], &time[1], &time[2], &time[3], 
				 &time[4], &time[5], &time[6]);	
	switch (page)
	{
		case 0:
			buf[0] = 0x20;
			buf[1] = 0x20;
			temp = HEX2BCD((uint8)time[4]);
			buf[2] = ((temp>>4)&0x0F)|0x30;
			buf[3] = (temp&0x0F)|0x30;
			temp = HEX2BCD((uint8)time[5]);
			buf[4] = ((temp>>4)&0x0F)|0x30;
			buf[5] = (temp&0x0F)|0x30;
			temp = HEX2BCD((uint8)time[6]);
			buf[6] = ((temp>>4)&0x0F)|0x30;
			buf[7] = (temp&0x0F)|0x30;
			ClrLcd();
			ConfigTitleStr(14,1);										// 显示"时间"
			sayTitleStr(1,0);
			sayNumStr(buf, 0x6C);										// 显示时间
			page ++;
			break;
		case 1:
			buf[0] = 0x32;
			buf[1] = 0x30;
			temp = HEX2BCD(time[0]%100);
			buf[2] = ((temp>>4)&0x0F)|0x30;
			buf[3] = (temp&0x0F)|0x30;
			temp = HEX2BCD((uint8)time[1]);
			buf[4] = ((temp>>4)&0x0F)|0x30;
			buf[5] = (temp&0x0F)|0x30;
			temp = HEX2BCD((uint8)time[2]);
			buf[6] = ((temp>>4)&0x0F)|0x30;
			buf[7] = (temp&0x0F)|0x30;
			ClrLcd();
			ConfigTitleStr(9,1);										// 显示"日期"
			sayTitleStr(1,0);
			sayNumStr(buf, 0x6C);										// 显示日期
			page ++;
			break;
		case 2:
			ClrLcd();
			ConfigTitleStr(6,1);										// 显示"电"
			sayTitleStr(1,0);
			ConfigTitleStr(5,1);										// 显示"压"
			sayTitleStr(1,0);											
			sayTitleStr(5,0x10);										// 显示"Ua"
			buf[0] = 0 + 0x30;
			buf[1] = 5 + 0x30;
			buf[2] = 0 + 0x30;
			sayFunCode(buf, 0);											// 显示功能码
			buf[0] = 0x20;
			buf[1] = 0x20;
			buf[2] = 0x20;
			buf[3] = 0x20;
			buf[4] = 0x20;
			temp = cur_data[0].XB611[1];
			buf[5] = temp&0x0F|0x30;
			temp = (cur_data[0].XB611[0]>>4);
			buf[6] = (temp&0x0F)|0x30;
			temp = cur_data[0].XB611[0];
			buf[7] = temp&0x0F|0x30;
			sayNumStr(buf, 0x00);
			sayTitleStr(27,1);											// 显示"V"
			page ++;
			break;
		case 3:
			ClrLcd();
			ConfigTitleStr(6,1);										// 显示"电"
			sayTitleStr(1,0);
			ConfigTitleStr(5,1);										// 显示"压"
			sayTitleStr(1,0);
			sayTitleStr(5,0x20);										// 显示"Ub"
			buf[0] = 0 + 0x30;
			buf[1] = 5 + 0x30;
			buf[2] = 1 + 0x30;
			sayFunCode(buf, 0);											// 显示功能码
			buf[0] = 0x20;
			buf[1] = 0x20;
			buf[2] = 0x20;
			buf[3] = 0x20;
			buf[4] = 0x20;
			temp = cur_data[0].XB612[1];
			buf[5] = temp&0x0F|0x30;
			temp = (cur_data[0].XB612[0]>>4);
			buf[6] = (temp&0x0F)|0x30;
			temp = cur_data[0].XB612[0];
			buf[7] = temp&0x0F|0x30;
			sayNumStr(buf, 0x00);
			sayTitleStr(27,1);											// 显示"V"
			page ++;
			break;
		case 4:
			ClrLcd();
			ConfigTitleStr(6,1);										// 显示"电"
			sayTitleStr(1,0);
			ConfigTitleStr(5,1);										// 显示"压"
			sayTitleStr(1,0);
			sayTitleStr(5,0x40);										// 显示"Uc"
			buf[0] = 0 + 0x30;
			buf[1] = 5 + 0x30;
			buf[2] = 2 + 0x30;
			sayFunCode(buf, 0);											// 显示功能码
			buf[0] = 0x20;
			buf[1] = 0x20;
			buf[2] = 0x20;
			buf[3] = 0x20;
			buf[4] = 0x20;
			temp = cur_data[0].XB613[1];
			buf[5] = temp&0x0F|0x30;
			temp = (cur_data[0].XB613[0]>>4);
			buf[6] = (temp&0x0F)|0x30;
			temp = cur_data[0].XB613[0];
			buf[7] = temp&0x0F|0x30;
			sayNumStr(buf, 0x00);
			sayTitleStr(27,1);											// 显示"V"
			page ++;
			break;
		case 5:
			ClrLcd();
			ConfigTitleStr(6,1);										// 显示"电"
			sayTitleStr(1,0);
			ConfigTitleStr(2,1);										// 显示"流"
			sayTitleStr(1,0);											
			sayTitleStr(7,0x02);										// 显示"Ia"
			buf[0] = 0 + 0x30;
			buf[1] = 5 + 0x30;
			buf[2] = 3 + 0x30;
			sayFunCode(buf, 0);											// 显示功能码
			buf[0] = 0x20;
			buf[1] = 0x20;
			buf[2] = 0x20;
			buf[3] = 0x20;
			temp = (cur_data[0].XB621[1]>>4)&0x0F;
			buf[4] = temp|0x30;
			temp = cur_data[0].XB621[1];
			buf[5] = temp&0x0F|0x30;
			temp = (cur_data[0].XB621[0]>>4);
			buf[6] = (temp&0x0F)|0x30;
			temp = cur_data[0].XB621[0];
			buf[7] = temp&0x0F|0x30;
			sayNumStr(buf, 0x40);
			sayTitleStr(20,1);										// 显示"A"
			page ++;
			break;
		case 6:
			ClrLcd();
			ConfigTitleStr(6,1);										// 显示"电"
			sayTitleStr(1,0);
			ConfigTitleStr(2,1);										// 显示"流"
			sayTitleStr(1,0);											
			sayTitleStr(7,0x08);										// 显示"Ib"
			buf[0] = 0 + 0x30;
			buf[1] = 5 + 0x30;
			buf[2] = 4 + 0x30;
			sayFunCode(buf, 0);											// 显示功能码
			buf[0] = 0x20;
			buf[1] = 0x20;
			buf[2] = 0x20;
			buf[3] = 0x20;
			temp = (cur_data[0].XB622[1]>>4)&0x0F;
			buf[4] = temp|0x30;
			temp = cur_data[0].XB622[1];
			buf[5] = temp&0x0F|0x30;
			temp = (cur_data[0].XB622[0]>>4);
			buf[6] = (temp&0x0F)|0x30;
			temp = cur_data[0].XB622[0];
			buf[7] = temp&0x0F|0x30;
			sayNumStr(buf, 0x40);
			sayTitleStr(20,1);										// 显示"A"
			page ++;
			break;
		case 7:
			ClrLcd();
			ConfigTitleStr(6,1);										// 显示"电"
			sayTitleStr(1,0);
			ConfigTitleStr(2,1);										// 显示"流"
			sayTitleStr(1,0);											
			sayTitleStr(7,0x40);										// 显示"Ic"
			buf[0] = 0 + 0x30;
			buf[1] = 5 + 0x30;
			buf[2] = 5 + 0x30;
			sayFunCode(buf, 0);											// 显示功能码
			buf[0] = 0x20;
			buf[1] = 0x20;
			buf[2] = 0x20;
			buf[3] = 0x20;
			temp = (cur_data[0].XB623[1]>>4)&0x0F;
			buf[4] = temp|0x30;
			temp = cur_data[0].XB623[1];
			buf[5] = temp&0x0F|0x30;
			temp = (cur_data[0].XB623[0]>>4);
			buf[6] = (temp&0x0F)|0x30;
			temp = cur_data[0].XB623[0];
			buf[7] = temp&0x0F|0x30;
			sayNumStr(buf, 0x40);
			sayTitleStr(20,1);											// 显示"A"
			page ++;
			break;
		case 8:															// 正总有功电量
			ClrLcd();
			ConfigTitleStr(17,1);										// 显示"正"
			sayTitleStr(1,0);
			ConfigTitleStr(19,1);										// 显示"总"
			sayTitleStr(1,0);	
			ConfigTitleStr(8,1);										// 显示"有"
			sayTitleStr(1,0);
			ConfigTitleStr(7,1);										// 显示"工"
			sayTitleStr(1,0);
			ConfigTitleStr(4,1);										// 显示"电"
			sayTitleStr(1,0);		
			ConfigTitleStr(23,1);										// 显示"量"
			sayTitleStr(1,0);
															
			//sayTitleStr(7,0x40);										// 显示"Ic"
			buf[0] = 0 + 0x30;
			buf[1] = 0 + 0x30;
			buf[2] = 1 + 0x30;
			sayFunCode(buf, 0);											// 显示功能码
			
			temp = (cur_data[0].X9010[3]>>4)&0x0F;
			buf[0] = temp|0x30;
			temp = cur_data[0].X9010[3];
			buf[1] = temp&0x0F|0x30;
			temp = (cur_data[0].X9010[2]>>4)&0x0F;
			buf[2] = temp|0x30;
			temp = cur_data[0].X9010[2];
			buf[3] = temp&0x0F|0x30;
			temp = (cur_data[0].X9010[1]>>4)&0x0F;
			buf[4] = temp|0x30;
			temp = cur_data[0].X9010[1];
			buf[5] = temp&0x0F|0x30;
			temp = (cur_data[0].X9010[0]>>4)&0x0F;
			buf[6] = temp|0x30;
			temp = cur_data[0].X9010[0];
			buf[7] = temp&0x0F|0x30;
			sayNumStr(buf, 0x40);
			
			sayTitleStr(21,1);											// 显示"k"
			sayTitleStr(26,1);											// 显示"w"
			sayTitleStr(22,1);											// 显示"k"
			page ++;
			break;
		default:
			break;
	}
	
	flag = 0x00;														// 判断失压
	if ((cur_data[0].XB611[0]==0)&&(cur_data[0].XB611[1]==0))
	{
		flag = 0x01;
		temp = 0x01;
	}
	if ((cur_data[0].XB612[0]==0)&&(cur_data[0].XB612[1]==0))
	{
		flag &= 0x01;
		temp |= 0x02;
	}
	if ((cur_data[0].XB613[0]==0)&&(cur_data[0].XB613[1]==0))
	{
		flag &= 0x01;
		temp |= 0x04;
	}
	
	sayTitleStr(15,flag);												// 显示"失压"
	sayTitleStr(17,temp);												// 显示"A/B/C"
				
	sayTitleStr(9,signal);												// 显示GPRS信号强度
	sayTitleStr(10,logsuc);												// 显示是否成功登录主站
}

⌨️ 快捷键说明

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