/*
 * LCD.c
 *
 *  Created on: 2016-5-12
 *      Author: Administrator
 */

#include"ALL.h"


//;****************************************************************************************
//;* 函  数   名: ComIoSetHalfFun
//;* 函数功能: com口设置为半电平
//;* 入口参数: 无
//;* 返         回: 无
//;****************************************************************************************

void	ComIoSetHalfFun()
{

	//COM1
	TR04 =1;		//先设置为输入
	VBS13EN =1;
	//COM2
	TR03 =1;		//先设置为输入
	VBS12EN =1;

	//COM3
	TR01 =1;		//先设置为输入
	VBS11EN =1;

	//COM4
	TR00 =1;		//先设置为输入
	VBS10EN =1;

}



//;****************************************************************************************
//;* 函  数   名: LcdSegIoSetFun
//;* 函数功能: 显示输出数据端口设置函数
//;* 入口参数: 		dis_play
//;* 返         回: 无
//;****************************************************************************************
void	LcdSegIoSetFun(uchar8	dis_play)	//输出端口设置函数
{
	DIS_IO_SEG_1=dis_play;
	dis_play = dis_play>>1;


	DIS_IO_SEG_2=dis_play;
	dis_play = dis_play>>1;


	DIS_IO_SEG_3=dis_play;
	dis_play = dis_play>>1;


	DIS_IO_SEG_4=dis_play;
	dis_play = dis_play>>1;

	DIS_IO_SEG_5=dis_play;
	dis_play = dis_play>>1;

	DIS_IO_SEG_6=dis_play;
	dis_play = dis_play>>1;

	DIS_IO_SEG_7=dis_play;
	dis_play = dis_play>>1;

	DIS_IO_SEG_8=dis_play;
}




//;****************************************************************************************
//;* 函  数   名: ComTempSetFun
//;* 函数功能: COM显示寄存器设置函数
//;* 入口参数: 无
//;* 返         回: 无
//;****************************************************************************************
void	ComTempSetFun()
{
	if(CHANGE_SHOW_NUM_FLAG)
	{
		CHANGE_SHOW_NUM_FLAG=0;
		Com1Temp = 0;
		Com2Temp = 0;
		Com3Temp = 0xff;
		Com4Temp = 0;

		if(LcdNumQian&(1<<0)) Com1Temp |= (1<<0);			//1a
		if(LcdNumQian&(1<<1)) Com1Temp |= (1<<1);			//1b			//千位显示
		if(LcdNumQian&(1<<2)) Com3Temp |= (1<<1);			//1c
		if(LcdNumQian&(1<<3)) Com4Temp |= (1<<1);			//1d
		if(LcdNumQian&(1<<4)) Com3Temp |= (1<<0);			//1e
		if(LcdNumQian&(1<<5)) Com2Temp |= (1<<0);			//1f
		if(LcdNumQian&(1<<6)) Com2Temp |= (1<<1);			//1g


		if(LcdNumBai&(1<<0)) Com1Temp |= (1<<2);			//2a
		if(LcdNumBai&(1<<1)) Com1Temp |= (1<<3);			//2b			//百位显示
		if(LcdNumBai&(1<<2)) Com3Temp |= (1<<3);			//2c
		if(LcdNumBai&(1<<3)) Com4Temp |= (1<<3);			//2d
		if(LcdNumBai&(1<<4)) Com3Temp |= (1<<2);			//2e
		if(LcdNumBai&(1<<5)) Com2Temp |= (1<<2);			//2f
		if(LcdNumBai&(1<<6)) Com2Temp |= (1<<3);			//2g

		if(LcdNumTen&(1<<0)) Com1Temp |= (1<<4);			//3a
		if(LcdNumTen&(1<<1)) Com1Temp |= (1<<5);			//3b			//十位显示
		if(LcdNumTen&(1<<2)) Com3Temp |= (1<<5);			//3c
		if(LcdNumTen&(1<<3)) Com4Temp |= (1<<5);			//3d
		if(LcdNumTen&(1<<4)) Com3Temp |= (1<<4);			//3e
		if(LcdNumTen&(1<<5)) Com2Temp |= (1<<4);			//3f
		if(LcdNumTen&(1<<6)) Com2Temp |= (1<<5);			//3g


		if(LcdNumGe&(1<<0)) Com1Temp |= (1<<6);				//4a
		if(LcdNumGe&(1<<1)) Com1Temp |= (1<<7);				//4b			//个位显示
		if(LcdNumGe&(1<<2)) Com3Temp |= (1<<7);				//4c
		if(LcdNumGe&(1<<3)) Com4Temp |= (1<<7);				//4d
		if(LcdNumGe&(1<<4)) Com3Temp |= (1<<6);				//4e
		if(LcdNumGe&(1<<5)) Com2Temp |= (1<<6);				//4f
		if(LcdNumGe&(1<<6)) Com2Temp |= (1<<7);				//4g

		if(SHOW_TN_SEG_P1)  Com4Temp |= (1<<0);
		if(SHOW_TN_SEG_2P)  Com4Temp |= (1<<2);
		if(SHOW_TN_SEG_3P)  Com4Temp |= (1<<4);
		if(SHOW_TN_SEG_4P)  Com4Temp |= (1<<6);
	}
}



//;****************************************************************************************
//;* 函  数   名: ComScanFun
//;* 函数功能: COM显示寄存器输出函数
//;* 入口参数: ComScanMode
//;* 返         回: 无
//;****************************************************************************************
void	ComScanFun(uchar8 ComScanMode)
{
		switch(ComScanMode)
		{

		case	COM1_MODE_L:
			ComIoSetHalfFun();		//先将COM设置为半电平
			LcdSegIoSetFun(Com1Temp);
			COM1_SET_L			//描COM1低电平

			break;
		case	COM1_MODE_H:
			ComIoSetHalfFun();	//先将COM设置为半电平
			LcdSegIoSetFun(~Com1Temp);
			COM1_SET_H				//描COM1高电平
			break;

		case	COM2_MODE_L:
			ComIoSetHalfFun();	//先将COM设置为半电平
			LcdSegIoSetFun(Com2Temp);
			COM2_SET_L			//描COM2低电平
			break;
		case	COM2_MODE_H:
			ComIoSetHalfFun();		//先将COM设置为半电平
			LcdSegIoSetFun(~Com2Temp);
			COM2_SET_H			//描COM2高电平
			break;

		case	COM3_MODE_L:
			ComIoSetHalfFun();		//先将COM设置为半电平
			LcdSegIoSetFun(Com3Temp);
			COM3_SET_L			//描COM3低电平
			break;
		case	COM3_MODE_H:
			ComIoSetHalfFun();	//先将COM设置为半电平
			LcdSegIoSetFun(~Com3Temp);
			COM3_SET_H			//描COM3高电平
			break;


		case	COM4_MODE_L:
			ComIoSetHalfFun();	//先将COM设置为半电平
			LcdSegIoSetFun(Com4Temp);
			COM4_SET_L			//描COM4低电平
			break;
		case	COM4_MODE_H:
			ComIoSetHalfFun();	//先将COM设置为半电平
			LcdSegIoSetFun(~Com4Temp);
			COM4_SET_H			//描COM4高电平
			break;

		default:
			break;

		}




}
