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

📄 cover2.c

📁 基于盛群单片机HT46R24的来电显示系统
💻 C
📖 第 1 页 / 共 4 页
字号:
//Serial_r.c
//
//Body: HT46R24
//Mask option
//WDT : Disable
//the others use the default value

#include <ht46r24.h>

#pragma vector isr_4 @ 0x4
#pragma vector isr_8 @ 0x8
#pragma vector isr_c @ 0xc

#define s0	_16_0	//确定  //link to pc0
#define s1  _16_1	//上翻  //link to pc1
#define s2  _16_2	//下翻  //link to pc2
#define s3	_16_3	//取消  //link to pc3

#define rx   _18_1                 //receive pin
#define _pd1c _19_1                //receive pin's control reg

#define RST _12_4                  //reset connet to _pa4
#define RS _12_3                   //rs link to pa3
#define RW _12_2                   //r/w link to pa2
#define E _12_1                    //link to pa1
#define OUTPUT _pb                 //link to lcd's data line

#define SPACE 1573                   //baudrate 1200 = 8M/4/(T+14) ==> T =1573
#define T 50000

unsigned int data,j,i;
unsigned int bl_count,call_count;

unsigned key_flag,ud_flag,key_enter;

unsigned int msg[24];
unsigned int num[10][19];//用num代替msg_1 msg_2//10/19
unsigned int bl_list[10][12];//用bl_list代替msg_3//10/12

const unsigned char str_1[4]={"确定"};
const unsigned char str_2[4]={"取消"};
const unsigned char str_3[2]={0xa1,0xfd};
const unsigned char str_4[2]={"→"};

const unsigned char normal_1[5]={"普通:"};
const unsigned char normal_2[8]={"Welcome!"};
const unsigned char normal_3[6]={"查询:"};
const unsigned char normal_4[14]={"功能:长按确定"};

const unsigned char search_1[5]="查询:";

const unsigned char function_1[5]="功能:";
const unsigned char function_2[10]="添加黑名单";
const unsigned char function_3[10]="修改黑名单";
const unsigned char function_4[10]={0xc9,0xbe,0xb3,0xfd,0xba,0xda,0xc3,0xfb,0xb5,0xa5};

 const unsigned char blacklist_1[7]="黑名单:";
 const unsigned char blacklist_n1[2]="①";
 const unsigned char blacklist_n2[2]="②";
 const unsigned char blacklist_n3[2]="③";
 const unsigned char blacklist_n4[2]="④";
 const unsigned char blacklist_n5[2]="⑤";
 const unsigned char blacklist_n6[2]="⑥";
 const unsigned char blacklist_n7[2]="⑦";
 const unsigned char blacklist_n8[2]="⑧";
 const unsigned char blacklist_n9[2]="⑨";
 const unsigned char blacklist_n10[2]="⑩";


 const unsigned char work_1[5]="工作:";
 const unsigned char work_2[7]="所在地:";
 
void mydelay();

//液晶显示部分
void rst_lcd();                  //restet the lcd 
void chk_busy();                 //check the lcd busy or not
void write_com(unsigned int a);  //write the command to the lcd
void write_data(unsigned int a); //write the data to the lcd
void clear();                    //clear the characters on the lcd

//界面部分
unsigned int normal();
unsigned int search();
unsigned int function();
void add();
void revise();
void del_bl();

//ISR for safequard
void isr_4(){} // external ISR
void isr_8(){} // timer/event 0
void isr_c(){} // timer/event 1

//initialize registers for safeguard
void safeguard_init(){
        _intc0 = 0;
        _intc1 = 0;
        _tmr0c = 0;
        _tmr0h = 0;
        _tmr0l = 0;
        _tmr1c = 0;
        _tmr1h = 0;
        _tmr1l = 0;
        _pac = 0x00;  //output mode,used as the command line to the lcd
        _pbc = 0xff;  //input mode
        _pcc = 0xff;
        _pdc = 0xff;
        _pfc = 0xff;
}

const unsigned char yue[2]="月";
const unsigned char ri[2]="日";
const unsigned char dian[2]="点";
const unsigned char fen[2]="分";
const unsigned char work_str[6]="工作:";
const unsigned char are[12]="所在地:重庆";

void receive(unsigned char *);   //serial port receive data function.
void date_time();


void main()
{
	
	 unsigned int key_flag;
	 data==0;call_count=0;
	 
        for(j=0;j<24;j++)
        msg[j]=0;               //initial the datagroup

        safeguard_init();      
        _pd1c = 1;               //set receive pin to input mode       
   
 _pcc = 0xff;//input mode
 _17_4=0;//output mode  pcc4
 
         rst_lcd();
          write_com(0x34);//extern instruction
           write_com(0x30);//basic instruction
            write_com(0x01);//clear display
             write_com(0x06);//in wrting or reading,cursor's move direction
              write_com(0x0c);//open display,close cursor and no flash
                
     for(bl_count=0;bl_count<10;bl_count++)
      {
      	for(i=2;i<12;i++)
       bl_list[bl_count][i]=0x30;
       bl_list[bl_count][0]=0x20;bl_list[bl_count][1]=0x20;
		  }
		  bl_count=0;

        key_flag=0;

      do
      {
      	if(key_flag==0)
        {
        	clear();//clear screen
	  	     key_flag=normal();    //normal mode acquire key_flag==1 enter rogatory mode
	  	  }                                    //acquire key_flag==2 enter funtion mode
	      if(key_flag==1)
	      	{
	      		clear();
	      		 _delay(T);//delay50ms
	      		 _delay(T);//delay50ms
	      	    key_flag=search();
	      	    }
	      	 else if(key_flag==2)
	      	 	 {
	      	 	 	 clear();
	      	 	 	  _delay(T);//delay50ms
	      	 	 	  _delay(T);//delay50ms
	      	 	 	   key_flag=function();
	      	 	 	   }
	      }while(key_flag==0);   
}


void receive(unsigned char *val)
{
        unsigned char i, v;
        v = 0;
        while(rx); //wait start bit
        for(i=0; i<8; i++){
                _delay(SPACE);
                if (rx) v |= (unsigned char)0x80;
                v >>= 1;
        }
        _delay(SPACE);//skip stop bit
        _delay(SPACE);
        *val = v;
}

void mydelay()
{
	for(i=0;i<10;i++)
	 _delay(T);
}


void rst_lcd()
{
	RST=0;
    //for(i=0;i<10;i++)
	_delay(5000);//delay80ms
	RST=1;
	_delay(100);
}

void chk_busy()
{    _pbc=0x00;          //input mode
	OUTPUT=0x00;
    _pbc=0xff;          //input mode


	RS=0;
    RW=1;
    E=1;
   while(_14_7);       //if pb7==0 jump next
    _delay(1000);
	E=0;
}

void clear()
{
	write_com(0x01);//cls
	 write_com(0x34);//extern instruction
	  write_com(0x30);//basic instruction
	}


void write_com(unsigned int a)      //write command to lcd
{
	chk_busy();
        _pbc=0x0;      //output mode

	RS=0;
    RW=0;
	OUTPUT=a;
	E=1;
	_delay(100);
	E=0;
}

void write_data(unsigned int a)//write data to lcd
{
	chk_busy();
        _pbc=0x0;      //output mode
	RS=1;RW=0;
	OUTPUT=a;
	E=1;
	_delay(100);
	E=0;
}
void date_time()
{
           write_com(0x90);//output from the 4th line
            write_data(msg[2]);//output data
             write_data(msg[3]);//output data
              write_data(yue[0]);
               write_data(yue[1]);
                write_data(msg[4]);//output data
                 write_data(msg[5]);//output data
                  write_data(ri[0]);
                   write_data(ri[1]);
                    write_data(msg[6]);//output data
                     write_data(msg[7]);//output data
                      write_data(dian[0]);
                       write_data(dian[1]);
                        write_data(msg[8]);//output data
                         write_data(msg[9]);//output data
                          write_data(fen[0]);
                           write_data(fen[1]);
}

unsigned int normal()//普通模式normal mode
  {
  	unsigned int key_flag;
  	
    //***display****//
    write_com(0x80);//output from the 1th line
            for(i=0;i<5;i++)
             write_data(normal_1[i]);//普通normal

	  write_com(0x92);//output from the 2th line
        for(i=0;i<8;i++)
         write_data(normal_2[i]);//welcome!

    write_com(0x89);//output from the 3th line
            for(i=0;i<6;i++)
             write_data(normal_3[i]);//查询..rogatory
             
    write_com(0x99);//output from the 4th line
            for(i=0;i<14;i++)
             write_data(normal_4[i]);//功能..function
                      
    key_flag=0;
    do
    {
    	if(s1==0||s2==0)
    		{
    			mydelay();
    			 if(s1==0||s2==0)
    			 	key_flag=1;
    			}
    	if(s0==0)
    		{
    			for(i=0;i<5;i++)
    			{
    				mydelay();
    				mydelay();
    				 if(s0==0)
    				 	{key_flag=0;break;}
    				 	key_flag=2;
    				}
    			}              
    		}while(key_flag==0);
    		
    		return key_flag;        
  	} 
	
	

⌨️ 快捷键说明

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