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

📄 display.c

📁 一个充电控制器的完整单片机程序
💻 C
字号:
//-----------------
//change value that display in lcd
//-----------------
#include <string.h>
#include <ABSACC.H>
#include <stdio.h>
#include <INTRINS.h>
#include <stdlib.h>
#include <AT89X52.H>

#include "CHARGER.H"

//
//----------------
//main program
////--------------
static unsigned char month_is(unsigned char *s)
{
	unsigned char data i;
	code char *m[]={"Jan","Feb","Mar","Apr","May","Jun","Jnl","Aug","Sep","Oct","Nov","Dec"};
	for(i=0;;i++)if((m[i][0]==s[0])&&(m[i][1]==s[1])&&(m[i][2]==s[2]))return i+1;
}
static void	now_is(unsigned char *s)
{
	code unsigned char *t[]={__DATE__,__TIME__};

	s[0]=1;
	s[1]=atoi(t[1]+3);
	s[2]=atoi(t[1]);

	s[3]=atoi(t[0]+4);
	s[4]=month_is(t[0]);
	s[5]=atoi(t[0]+8);
}

//---------------------
//hardware reset flag
unsigned char data bootflag _at_ 0x9;
extern bit bdata boostflag;

static void init(void)
{
	unsigned int data i;
	unsigned char xdata *string;//[8];

	for(i=0;i<3;i++)
	{
		delay(1000);//Waiting for all right
		/*1*///init port of 51
		RESET_DOG;
		P8255D=0x80;//AoBoCo,8255 mode 0, all port output
		P8255A=0xFF;
		P8255B=0xFF;
	}
/*2*///init lcd
  WC_LCD(SET8B);
  WC_LCD(SCR_TFF);
/*3*///init history area to save
  RESET_DOG;
	if(bootflag!=0xAA)
	{

		string=0xC000;

  	RESET_DOG;
		for(i=0;i<0x2000;i++)*string++=0;
  	RESET_DOG;

		init_history_buffer();

		boostflag=1;

/*4*///init system work point & rate
		if(sys[11]<2230||sys[11]>3230){sys[11]=0;just=0;}
		//如果存在系统设置,则不进行缺省设置
		if(!(sys[7]==48||sys[7]==110||sys[7]==220||sys[7]==300))
		{
			init_rate_workpoint(DEFSYSV);
			password=8952;
		}
 	 	RESET_DOG;;

/*5*///init realtimer
		now_is(&XBYTE[0xC400]);
//		setup12887(&XBYTE[0xC400]);
  	RESET_DOG;

		bootflag=0xAA;
	}

  start12887();
/*7*///init interrupt
	EX0=1;	EX1=1;
	IT0=1;	IT1=1;//interrupt mode download side

/*8*///init_timer0();//enable readkey,reset dog
  TMOD &= 0XF0;   
  TMOD |= 0X1;  //mode 1 max is 106.66666ms on 7.3728M
  TL0 = 0X00;    
  TH0 = 0X88;    //on 7.3728M,50ms(0x8800);
  ET0 = 1;       
  TF0 = 0;
  TR0 = 1; 

 	EA=1;	
	keyrst(0);
	
	controlstate=0x20;//state display reset

  RESET_DOG;
}

//--------------
extern code char *atstate;
//-----------------------
void main(void)
{
 	init();//check soft reset 
	init_serial();
	Wmodem(atstate);
  while(1)
  {
//2005/4
init_rate_workpoint(DEFSYSV); 
//2005/4
  	RESET_DOG;
    getadin();//get ad input
		account();//account work data of today
		control();//control extern switcher with battery volatage
		firstscr();//display timer & battery volatage
    menu();//is menu enter
    save();//save history data per once day 
		SetSys();//Set sysSet with data of recived
		if(tlong&0x0FF==0)
			Wmodem(atstate);//Period 256 Second
	}
}



⌨️ 快捷键说明

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