?? callcheck.c
字號:
//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 i,j,v;
unsigned int bl_count,call_count,call_flag;
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_8(){} // timer/event 0
void isr_c(){} // timer/event 1
//initialize registers for safeguard
void safeguard_init(){
_intc0 = 0x03;
_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 isr_4()// external ISR
{_eei=0;
v = 0;
do
{
while(rx); //wait start bit
for(i=0;i<8;i++)
{
_delay(T);
if (rx) v |= (unsigned char)0x80;
v >>= 1;
}
_delay(T);//skip stop bit
_delay(T);
}while(v!=0x17);
for(j=0;j<23;j++) //this is the useful data,begin to receive
{
v = 0;
while(rx); //wait start bit
for(i=0;i<8;i++)
{
_delay(T);
if (rx) v |= (unsigned char)0x80;
v >>= 1;
}
_delay(T);//skip stop bit
_delay(T);
msg[j]=v; //stored the data
}
call_flag=1;
}
void main()
{
unsigned int key_flag;
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
_13_5=1; //set interrupt pin to input mode
_emi=1;_eei=1; //open interrupt
call_flag=0; //call receive flag
_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&&call_flag==0);
show://show the caller numbers
call_flag=0;
_eei=1;
clear();
//*********mode*********//
write_com(0x80);
for(j=0;j<6;j++)
write_data(work_str[j]);//output data
//***display the month,date,hour,minute**//
date_time();
//***display the call number**//
write_com(0x89);//output from the 3th line
for(j=12;j<23;j++)
write_data(msg[j]);//output data
//***are***//
write_com(0x98);//output from the 4th line
for(j=0;j<12;j++)
write_data(are[j]);//output data
for(j=0;j<10;j++)
mydelay();
goto show;
}
void receive(unsigned char *val)
{}
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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -