|
这个是我同学搞的设计,他是网上买的程序,本质上就是个基于STC89C52的排队叫号,组成的东西也简单,2个STC,2个1602,蜂鸣器,一堆独立按键,还有个WT588D语言芯片和喇叭,通信用的是有线的串口。具体实现的功能我会发个视频链接。发出来也是为需要的人省点钱。具体的电气连接参考keil程序的引脚定义就可以了,语言芯片要导入的源文件也在压缩包里面。总体来讲这个设计没什么复杂的东西,正常的设计是不需要语音播报的。如果觉得独立按键较多也可以自己改成矩阵键盘,反正这东西焊独立按键也是要花点时间的。
视频的连接如下
https://pan.baidu.com/s/1vc_4T3Y6zcxwFNuki_eOEA
单片机源码:
- /*************************************************************************
- *工程名称: 排队叫号系统----叫号模块程序 *
- *单片机型号:STC89C52RC *
- *晶振频率:11.0592MHz *
- *作者:新兴光电 *
- *日期:2016-03-01 *
- *************************************************************************/
- #include<reg51.h>
- #include <intrins.h>
- #include "LCD1602.h"
- #define uchar unsigned char
- #define uint unsigned int
- #define FOSC 11059200L //系统晶振频率
- #define BAUD 9600 //串口波特率
- #define SMOD 1 //为1,加倍波特率计算
- #if SMOD
- #define TC_VAL (256-FOSC/16/12/BAUD)
- //#else #define TC_VAL (256-FOSC/32/12/BAUD)
- #endif
- /**********端口定义*******************************/
- sbit call_key1=P1^0; //呼叫键
- sbit recall_key1=P1^1; //重复呼叫键
- sbit mute_key1=P1^2; //消音键
- sbit stop_key1=P1^3; //暂停键
- sbit call_key2=P1^4; //呼叫键
- sbit recall_key2=P1^5; //重复呼叫键
- sbit mute_key2=P1^6; //消音键
- sbit stop_key2=P1^7; //暂停键
- sbit call_key3=P3^2; //呼叫键
- sbit recall_key3=P3^3; //重复呼叫键
- sbit mute_key3=P3^4; //消音键
- sbit stop_key3=P3^5; //暂停键
- sbit beep=P3^6; //蜂鸣器
- //语音相关
- sbit RST=P2^4; //复位脚 在非工业场合下这个可以不要
- sbit busy=P2^3; //WT588D忙检测端口 无播放时输出高电平
- sbit SDA=P2^2;
- sbit CS =P2^1;
- sbit SCL=P2^0;
- /**************************************************/
- /***********寄存器定义*****************************/
- /*
- uchar code TAB[12] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x40,0x00};
- //以上为共阴数码管段码表 0 1 2 3 4 5 6 7 8 9 - 无
- uchar dis_buf[9]; //显示缓存
- uchar dis_cnt; //显示计数 */
- //以下为串口用到的寄存器
- bit uart_busy; //串口忙检测
- bit uart_R_flag=0; //串口数据接收完毕标志
- bit uart_T_flag=0; //串口数据发送标志
- //uchar uart_buf; //串口数据寄存器
- //uchar count;
- uchar receive[4]; //数据接收格式 0xa5(起始位) 机器号(1~3) 呼叫号码(0x01取号) 0x5a(结束位)
- uchar send_buf[4]; //发送缓存 格式 0xa5(起始位) 机器号(1~3) 指令(0x01取号) 0x5a(结束位)
- uchar rec_cnt=0;
- //呼叫相关寄存器
- //uchar get_cnt=0; //取号计数
- //uchar call_cnt=0; //呼叫计数
- bit NO1_sta=0; //一号窗状态 0暂停呼叫,1开始呼叫
- bit NO2_sta=0; //二号窗状态
- bit NO3_sta=0; //三号窗状态
- uchar NO1_number; //窗口一号码
- uchar NO2_number; //窗口二号码
- uchar NO3_number; //窗口三号码
- //蜂鸣器相关定义
- bit beep_flag=0; //蜂鸣标志
- bit beep_end_flag=0;
- uchar beep_cnt=0; //蜂鸣器计数
- uchar beep_end_cnt=0;
- //语音播放地址定义:
- //0--播放"0"; 1--播放"1"; 2--播放"2"; 3--播放"3"; 4--播放"4"; 5--播放"5"; 6--播放"6"; 7--播放"7";
- //8--播放"8"; 9--播放"9"; 10--播放"请"; 11--播放"号到"; 12--播放"号窗口";
- // 三线串口,音频输出PWM,忙信号输出LOW
- //WT588D相关寄存器定义
- //一线,二线,三线有关
- #define H 1 //定义1为高电平
- #define L 0 //定义0为低电平
- //////////////变量/////////////////
- //bit flag = 1;
- bit B_DATA; //传输数据一位
- unsigned char SB_DATA = 0; //一字节公用数据缓存器
- unsigned char S_DATA = 0x00;
- bit play_flag=0; //播放标志
- uchar play_part_sta=0; //0为一号窗口,1为二号窗口,3为三号窗口
- uchar play_cnt;
- uchar play_end_cnt=7;
- uchar idata sound_buf1[7];
- uchar idata sound_buf2[7];
- uchar idata sound_buf3[7];
- /**************************************************/
- /***************延时程序***************************/
- void Delay1ms(uint t) //1ms延时程序
- {
- uchar j;
- while(t--)
- {
- for(j=0;j<125;j++)
- { ; }
- }
- }
- /**************************************************/
- /*************串口初始化程序***********************/
- void serial_init(void)
- {
- PCON=0x80;
- SCON=0x50; //8位数据串口,波特率可变 无校验位
- TMOD=0x21; //定时器1设为8位自动重装
- TH1=TC_VAL; //定时初始值
- TL1=TH1;
- ES = 1; //串口中断允许
- EA = 1; //总中断允许
- TR1=1;
- }
- /**************************************************/
- /***********串口中断服务程序*********************/
- void serial() interrupt 4
- {
- if (RI)
- {
- RI = 0; //串口接收中断完毕标志清0
- //uart_buf=SBUF; //接收数据
- // call_cnt=SBUF; //接收数据 获得叫号数
- receive[rec_cnt]=SBUF; //接收数据
- rec_cnt++;
- if(receive[0]==0xa5) //判断起始位
- {
- if(receive[rec_cnt-1]==0x5a&&rec_cnt==4) //数据接收完毕
- {
- uart_R_flag=1; //串口接收完毕标志
- }
- }
- else rec_cnt=0;
- if(rec_cnt>=4)
- rec_cnt=0;
- }
- if (TI)
- {
- TI = 0; //串口发送中断完毕标志清0
- uart_busy = 0; //串口忙标志清0
- }
- }
- /***************************************************/
- /*************串口发送一字节数据程序****************/
- void send_uart_dat(uchar dat)
- {
- while (uart_busy); //忙检测标志 等后上一字节数据发送完毕
- ACC = dat; //Calculate the even parity bit P (PSW.0)
- uart_busy = 1;
- SBUF = ACC; //发送数据至串口发送缓冲寄存器
- }
- /***************************************************/
- /*************串口发送字符串数据程序****************
- void send_uart_stringdat(uchar *s)
- {
- while (*s) //检查数据是否结束
- {
- send_uart_dat(*s++); //发送字符串
- }
- }
- /***************************************************/
- /********串口发送字符串数据程序*********************
- void send_uart_stringdat(uchar *send_dat)
- {
- do
- {
- send_uart_dat(*send_dat); //发送字符
- send_dat++;
- }while(*send_dat!='\0'); //检查数据是否结束
- }
- /***************************************************/
- /********数据转换用于显示***************************
- void cov_dis(uchar num1,uchar num2,uchar num3)
- {
- dis_buf[0]=TAB[num1/100]; //显示缓存
- dis_buf[1]=TAB[num1%100/10]; //显示缓存
- dis_buf[2]=TAB[num1%100%10]; //显示缓存
-
- dis_buf[3]=TAB[num2/100]; //显示缓存
- dis_buf[4]=TAB[num2%100/10]; //显示缓存
- dis_buf[5]=TAB[num2%100%10]; //显示缓存
-
- dis_buf[6]=TAB[num3/100]; //显示缓存
- dis_buf[7]=TAB[num3%100/10]; //显示缓存
- dis_buf[8]=TAB[num3%100%10]; //显示缓存
- }
- /***************************************************/
- /*********定时器0中断服务程序***********************/
- void timer0(void) interrupt 1
- {
- TL0 = 0x00; //设置定时初值 20ms 11.0592MHz
- TH0 = 0xB8; //设置定时初值
- /* P2=0xff;
- DIG1=1;
- Dport=0x00;
- dis_cnt++; //显示计数
- switch(dis_cnt)
- {
- case 1: DIG1=0; Dport=dis_buf[0]; break;
- case 2: DIG2=0; Dport=dis_buf[1]; break;
- case 3: DIG3=0; Dport=dis_buf[2]; break;
- case 4: DIG4=0; Dport=dis_buf[3]; break;
- case 5: DIG5=0; Dport=dis_buf[4]; break;
- case 6: DIG6=0; Dport=dis_buf[5]; break;
- case 7: DIG7=0; Dport=dis_buf[6]; break;
- case 8: DIG8=0; Dport=dis_buf[7]; break;
- case 9: dis_cnt=0; DIG9=0; Dport=dis_buf[8]; break;
- }
- */
- if(beep_flag==1) //蜂鸣标志
- {
- beep_cnt++; //蜂鸣计数
- if(beep_cnt>=25) //500ms计时
- {
- beep_cnt=0;
- beep=~beep;
- beep_end_cnt--;
- if(beep_end_cnt==0||beep_end_cnt==255)
- {
- beep_flag=0;
- beep_end_flag=1;
- }
- }
- }
- else
- {
- beep_cnt=0;
- beep=1; //关蜂鸣器
- }
- }
- /**********************************************************/
- /**********显示3位数据**************************/
- void dis_3byte(uchar dat)
- {
- LCD1602_Write(LCD1602_data,dat/100+0x30);
- LCD1602_Write(LCD1602_data,dat%100/10+0x30);
- LCD1602_Write(LCD1602_data,dat%10+0x30);
- }
- /***********************************************/
- /****************************************************/
- void Delay150us() //@12.000MHz
- {
- unsigned char i;
- _nop_();
- i = 72;
- while (--i);
- }
- /*--------------------------------------
- ;功 能:实现三线单字节低位在前串口通信函数适用于WT588D
- ;入 参:无
- ;出 参:0 返回主函数
- ;-------------------------------------*/
- /*************三线串口通信程序***********************/
- Send_threelines(unsigned char addr) //三线发码子程序
- {
- unsigned char i;
- RST=0;
- Delay1ms(5);
- RST=1;
- Delay1ms(20); /* 复位拉高20ms*/
- CS=0;
- Delay1ms(5); /* 片选拉低5ms */
- for(i=0;i<8;i++)
- {
- SCL=0;
- if(addr & 1)SDA=1;
- else SDA=0;
- addr>>=1;
- Delay150us(); /* 150us */
- SCL=1;
- Delay150us();
- }
- CS=1;
- Delay1ms(30);
- }
- /***************************************************/
- /***********语音数据转换****************************/
- sound_dat_cov(uchar num,uchar dat,uchar *buf) //窗口号,窗口数值 播放缓存
- {
- uchar n=0;
- *(buf+n)=10; //播放'请'
- n++;
- *(buf+n)=dat/100; //播放数值
- n++;
- *(buf+n)=dat%100/10; //播放数值
- n++;
- *(buf+n)=dat%10; //播放数值
- n++;
- *(buf+n)=11; //播放'号到'
- n++;
- *(buf+n)=num; //播放数值
- n++;
- *(buf+n)=12; //播放'号窗口'
- }
- /***************************************************/
- /***********语音播报数据****************************/
- void play_data(void)
- {
- if(busy) //不播放时为1,播放时为0
- {
- if(play_cnt<play_end_cnt)
- {
- if(play_cnt==0)
- {
- if(NO1_sta==1||NO2_sta==1||NO3_sta==1)
- {
- if(beep_flag==0&&beep_end_flag==0) //蜂鸣标志
- {
- beep_flag=1;
- beep_end_cnt=2;
- }
- }
- }
- if(beep_end_flag==1)
- {
- switch(play_part_sta)
- {
- case 0:
- if(NO1_sta==1)
- {
- Send_threelines(sound_buf1[play_cnt]); //播放语音
- play_cnt++;
- }
- else
- play_cnt=7;
- break;
- case 1:
- if(NO2_sta==1)
- {
- Send_threelines(sound_buf2[play_cnt]); //播放语音
- play_cnt++;
- }
- else
- play_cnt=7;
- break;
- case 2:
- if(NO3_sta==1)
- {
- Send_threelines(sound_buf3[play_cnt]); //播放语音
- play_cnt++;
- }
- else
- play_cnt=7;
- break;
- }
- }
- }
- else //一段语音播放完毕
- {
- beep_end_flag=0;
- //播放切换
- play_part_sta++; //0为一号窗口,1为二号窗口,3为三号窗口
- if(play_part_sta>=3)
- {
- play_part_sta=0;
- }
- if(play_part_sta==0)
- {
- if(NO1_sta==1&&NO1_number!=0)
- {
- play_cnt=0;
- }
- else play_part_sta++;
- }
- if(play_part_sta==1)
- {
- if(NO2_sta==1&&NO2_number!=0)
- {
- play_cnt=0;
- }
- else play_part_sta++;
- }
- if(play_part_sta==2)
- {
- if(NO3_sta==1&&NO3_number!=0)
- {
- play_cnt=0;
- }
- }
- }
- }
- }
- /****************************************************/
- /**************按键扫描程序********************************/
- void key_check(void)
- {
- //一号窗
- if(call_key1==0) //呼叫键
- {
- Delay1ms(80);
- if(call_key1==0)
- {
- send_buf[1]=1; //发送缓存 格式 0xa5(起始位) 机器号(1~3) 呼叫号码(1~255) 0x5a(结束位)
- uart_T_flag=1; //串口数据发送标志
- while(!call_key1); //等待按键释放
- }
- }
- else if(recall_key1==0) //重复呼叫键
- {
- Delay1ms(100);
- if(recall_key1==0)
- {
- if(NO1_number!=0)
- NO1_sta=1; //一号窗状态 0暂停呼叫,1开始呼叫
- }
- }
- else if(mute_key1==0) //消音键
- {
- Delay1ms(100);
- if(mute_key1==0)
- {
- NO1_sta=0; //一号窗状态 0暂停呼叫,1开始呼叫
- }
- }
- else if(stop_key1==0) //暂停键
- {
- Delay1ms(100);
- if(stop_key1==0)
- {
- NO1_sta=0; //一号窗状态 0暂停呼叫,1开始呼叫
- NO1_number=0;
- LCD1602_Print(0,1,"---");
- }
- }
- //二号窗
- if(call_key2==0) //呼叫键
- {
- Delay1ms(80);
- if(call_key2==0)
- {
- send_buf[1]=2; //发送缓存 格式 0xa5(起始位) 机器号(1~3) 呼叫号码(1~255) 0x5a(结束位)
- uart_T_flag=1; //串口数据发送标志
- while(!call_key2); //等待按键释放
- }
- }
- else if(recall_key2==0) //重复呼叫键
- {
- Delay1ms(100);
- if(recall_key2==0)
- {
- if(NO2_number!=0)
- NO2_sta=1; //一号窗状态 0暂停呼叫,1开始呼叫
- }
- }
- else if(mute_key2==0) //消音键
- {
- Delay1ms(100);
- if(mute_key2==0)
- {
- NO2_sta=0; //一号窗状态 0暂停呼叫,1开始呼叫
- }
- }
- else if(stop_key2==0) //暂停键
- {
- Delay1ms(100);
- if(stop_key2==0)
- {
- NO2_sta=0; //一号窗状态 0暂停呼叫,1开始呼叫
- NO2_number=0;
- LCD1602_Print(6,1,"---");
- }
- }
- //三号窗
- if(call_key3==0) //呼叫键
- {
- Delay1ms(80);
- if(call_key3==0)
- {
- send_buf[1]=3; //发送缓存 格式 0xa5(起始位) 机器号(1~3) 呼叫号码(1~255) 0x5a(结束位)
- uart_T_flag=1; //串口数据发送标志
- while(!call_key3); //等待按键释放
- }
- }
- else if(recall_key3==0) //重复呼叫键
- {
- Delay1ms(100);
- if(recall_key3==0)
- {
- if(NO3_number!=0)
- NO3_sta=1; //一号窗状态 0暂停呼叫,1开始呼叫
- }
- }
- else if(mute_key3==0) //消音键
- {
- Delay1ms(100);
- if(mute_key3==0)
- {
- NO3_sta=0; //一号窗状态 0暂停呼叫,1开始呼叫
- }
- }
- else if(stop_key3==0) //暂停键
- {
- Delay1ms(100);
- if(stop_key3==0)
- {
- NO3_sta=0; //一号窗状态 0暂停呼叫,1开始呼叫
- NO3_number=0;
- LCD1602_Print(12,1,"---");
- }
- }
- }
- /**********************************************************/
- /**************主程序**************************************/
- void main(void)
- {
- LCD1602_init(); //初始化液晶
- LCD1602_Print(0,0,"NO.1 NO.2 NO.3");
- LCD1602_Print(0,1,"--- --- --- ");
- serial_init(); //串口初始化程序
- TMOD=0x21; //设置定时器0为16位模式
- TL0 = 0x00; //设置定时初值 20ms 11.0592MHz
- TH0 = 0xB8; //设置定时初值
- TR0=1;
- ET0=1;
- EA=1;
- while(1)
- {
- key_check(); //按键扫描程序
- if(uart_R_flag==1)//串口数据接收完毕标志
- {
- switch(receive[1]) //判断机器号
- {
- case 1:
- NO1_number=receive[2]; //窗口一号码
- if(receive[2]!=0)
- {
- GotoXY(0,1);
- dis_3byte(NO1_number);
- NO1_sta=1; //一号窗状态 0暂停呼叫,1开始呼叫
- //语音数据转换
- sound_dat_cov(1,NO1_number,sound_buf1); //窗口号,窗口数值 播放缓存
- }
- break;
- case 2:
- NO2_number=receive[2]; //窗口二号码
- if(receive[2]!=0)
- {
- GotoXY(6,1);
- dis_3byte(NO2_number);
- NO2_sta=1; //一号窗状态 0暂停呼叫,1开始呼叫
- //语音数据转换
- sound_dat_cov(2,NO2_number,sound_buf2); //窗口号,窗口数值 播放缓存
- }
- break;
- case 3:
- NO3_number=receive[2]; //窗口三号码
- if(receive[2]!=0)
- {
- GotoXY(12,1);
- dis_3byte(NO3_number);
- NO3_sta=1; //一号窗状态 0暂停呼叫,1开始呼叫
- //语音数据转换
- sound_dat_cov(3,NO3_number,sound_buf3); //窗口号,窗口数值 播放缓存
- }
- break;
- }
- uart_R_flag=0; //串口数据接收完毕标志
- }
- if(uart_T_flag==1) //串口数据发送标志
- {
- send_buf[0]=0xa5; //发送缓存 格式 0xa5(起始位) 机器号(1~3) 指令(0x01取号) 0x5a(结束位)
- send_buf[2]=0x01; //发送缓存 格式 0xa5(起始位) 机器号(1~3) 指令(0x01取号) 0x5a(结束位)
- send_buf[3]=0x5a;
- send_uart_dat(send_buf[0]); //发送数据
- send_uart_dat(send_buf[1]); //发送数据
- send_uart_dat(send_buf[2]); //发送数据
- send_uart_dat(send_buf[3]); //发送数据
- uart_T_flag=0; //串口数据发送标志
- }
- //语音播报
- play_data(); //语音播报数据
- }
- }
- /*************************************************************************
- *工程名称: 排队叫号系统----取号模块程序 *
- *单片机型号:STC89C52RC *
- *晶振频率:11.0592MHz *
- *功能描述:按下取号键,开始取号 *
- *作者:新兴光电 *
- *日期:2016-03-01 *
- *************************************************************************/
- #include<reg51.h>
- #include <intrins.h>
- #include "LCD1602.h"
- #define uchar unsigned char
- #define uint unsigned int
- #define FOSC 11059200L //系统晶振频率
- #define BAUD 9600 //串口波特率
- #define SMOD 1 //为1,加倍波特率计算
- #if SMOD
- #define TC_VAL (256-FOSC/16/12/BAUD)
- //#else #define TC_VAL (256-FOSC/32/12/BAUD)
- #endif
- /**********端口定义********************************/
- sbit get_key=P2^0; //取号键
- sbit clear_key=P2^1; //清0键
- /**************************************************/
- /***********寄存器定义*****************************/
- uchar dis_buf[4];
- //以下为串口用到的寄存器
- bit uart_R_flag=0; //串口接收完毕标志
- bit busy=0; //串口忙检测
- uchar receive[4]; //数据接收格式 0xa5(起始位) 机器号(1~3) 指令(0x01取号) 0x5a(结束位)
- uchar send_buf[4]; //发送缓存 格式 0xa5(起始位) 机器号(1~3) 呼叫号码(1~255) 0x5a(结束位)
- uchar rec_cnt=0;
- //呼叫取号相关寄存器
- uchar get_cnt=0; //取号计数
- uchar call_cnt=0; //呼叫计数
- /**************************************************/
- /***************延时程序***************************/
- void Delay1ms(uint t) //1ms延时程序
- {
- uchar j;
- while(t--)
- {
- for(j=0;j<125;j++)
- { ; }
- }
- }
- /**************************************************/
- /**********转换显示*********************************/
- void cov_dis(uchar dis_dat)
- {
- dis_buf[0]=dis_dat/100+0x30;
- dis_buf[1]=dis_dat%100/10+0x30;
- dis_buf[2]=dis_dat%100%10+0x30;
- dis_buf[3]='\0';
- }
- /***************************************************/
- /*************串口初始化程序***********************/
- void serial_init(void)
- {
- TMOD=0x21; //定时器1设为8位自动重装
- SCON=0x50; //8位数据串口,波特率可变 无校验位
- TH1=TC_VAL; //定时初始值
- TL1=TH1;
- PCON=0x80;
- ES = 1; //串口中断充许
- EA = 1; //总中断允许
- TR1=1;
- }
- /**************************************************/
- /***********串口中断服务程序*********************/
- void serial() interrupt 4
- {
- if (RI)
- {
- RI = 0; //串口接收中断完毕标志清0
- //uart_buf=SBUF; //接收数据
- // call_cnt=SBUF; //接收数据 获得叫号数
- receive[rec_cnt]=SBUF; //接收数据
- rec_cnt++;
- if(receive[0]==0xa5) //判断起始位
- {
- if(receive[rec_cnt-1]==0x5a&&rec_cnt==4) //数据接收完毕
- {
- uart_R_flag=1; //串口接收完毕标志
- send_buf[1]=receive[1]; //获取机器号
- }
- }
- else rec_cnt=0;
- if(rec_cnt>=4)
- rec_cnt=0;
- }
- if (TI)
- {
- TI = 0; //串口发送中断完毕标志清0
- busy = 0; //串口忙标志清0
- }
- }
- /***************************************************/
- /*************串口发送一字节数据程序****************/
- void send_uart_dat(uchar dat)
- {
- while (busy); //忙检测标志 等后上一字节数据发送完毕
- ACC = dat; //Calculate the even parity bit P (PSW.0)
- busy = 1;
- SBUF = ACC; //发送数据至串口发送缓冲寄存器
- }
- /***************************************************/
- /*************串口发送字符串数据程序****************
- void send_uart_stringdat(uchar *s)
- {
- while (*s) //检查数据是否结束
- {
- send_uart_dat(*s++); //发送字符串
- }
- }
- /***************************************************/
- /********串口发送字符串数据程序*********************
- void send_uart_stringdat(uchar *send_dat)
- {
- do
- {
- send_uart_dat(*send_dat); //发送字符
- send_dat++;
- }while(*send_dat!='\0'); //检查数据是否结束
- }
- /***************************************************/
- /**************主程序*******************************/
- void main(void)
- {
- serial_init(); //串口初始化程序
- LCD1602_init(); //LCD1602初始化程序
- GotoXY(0,0);
- Print(" number: "); //显示英文”排号系统“
- GotoXY(0,1);
- Print(" Waiting: ");
- get_cnt=0; //号码计数
- call_cnt=0; //排队号
- while(1)
- {
- if(get_key==0) //取号键
- {
- Delay1ms(100);
- if(get_key==0)
- {
- if(get_cnt<255)
- {
- get_cnt++; //取号计数
- }
- else
- {
- get_cnt=255;
- }
- }
- }
- if(clear_key==0) //清0键
- {
- Delay1ms(100);
- if(clear_key==0)
- {
- get_cnt=0;
- call_cnt=0;
- while(!clear_key); //等待按键释放
- }
- }
- if(uart_R_flag==1) //串口接收完毕标志
- {
- if(receive[2]==0x01) //取号指令
- {
- send_buf[0]=0xa5; //发送缓存 格式 0xa5(起始位) 机器号(1~3) 呼叫号码(1~255) 0x5a(结束位)
- send_buf[3]=0x5a;
- call_cnt++;
- if(get_cnt!=0)
- {
- if(call_cnt<=get_cnt)
- send_buf[2]=call_cnt; //排队号 有人等候
- else
- {
- call_cnt=call_cnt-1;
- send_buf[2]=0; //排队号 无人等候,
- }
- }
- else
- {
- send_buf[2]=0;
- call_cnt=0;
- }
- send_uart_dat(send_buf[0]); //发送数据
- send_uart_dat(send_buf[1]); //发送数据
- send_uart_dat(send_buf[2]); //发送数据
- send_uart_dat(send_buf[3]); //发送数据
- }
- uart_R_flag=0;
- }
- cov_dis(get_cnt);
- LCD1602_Print(10,0,dis_buf); //显示取号数
- if(get_cnt!=call_cnt)
- {
- cov_dis(get_cnt-call_cnt);
- LCD1602_Print(11,1,dis_buf); //显示等候人数
- }
- else LCD1602_Print(11,1,"000"); //显示等候人数
-
-
- }
- }
- /***************************************************/
复制代码
|
-
-
源程序.rar
427.69 KB, 下载次数: 114, 下载积分: 黑币 -5
评分
-
查看全部评分
|