#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
#include <intrins.h>
uchar code smg_du[]={0x25,0xee,0x37,0xa2,0xe2,0xa1,0x21,0xea,0x20,0xa0,
0x60,0x25,0x39,0x26,0x31,0x71,0xff};
uchar code smg_we[]={0xe0,0xb0,0xd0,0x70};
uchar dis_smg[4] ={0};
sbit smg_we1 = P3^4;
sbit smg_we2 = P3^5;
sbit smg_we3 = P3^6;
sbit smg_we4 = P3^7;
sbit c_send = P3^2;
sbit c_recive = P3^3;
sbit beep = P3^1;
uchar smg_i = 3;
bit flag_300ms ;
long distance;
uint set_d;
uchar flag_csb_juli;
uint flag_time0;
uchar menu_1;
sbit VRST = P2^3;
sbit VBUSY= P2^7;
sbit VSDA = P2^6;
sbit VCS = P2^5;
sbit VSCL = P2^4;
uchar yujing[3];
void delay_1ms(uint q)
{
uint i,j;
for(i=0;i<q;i++)
for(j=0;j<120;j++);
}
uchar key_can;
void key()
{
static uchar key_new;
key_can = 20;
P2 |= 0x07;
if((P2 & 0x07) != 0x06)
{
delay_1ms(1);
if(((P2 & 0x07) != 0x07) && (key_new == 1))
{
key_new = 0;
switch(P2 & 0x07)
{
case 0x05: key_can = 1; break;
case 0x04: key_can = 2; break;
case 0x02: key_can = 3; break;
}
}
}
else
key_new = 1;
}
void key_with()
{
if(key_can == 1)
{
menu_1 ++;
if(menu_1 >= 2)
{
menu_1 = 0;
smg_i = 3;
}
if(menu_1 == 1)
{
smg_i = 4;
}
}
if(menu_1 == 1)
{
if(key_can == 2)
{
set_d ++ ;
if(set_d > 400)
set_d = 400;
}
if(key_can == 3)
{
set_d -- ;
if(set_d <= 1)
set_d = 1;
}
dis_smg[0] = smg_du[set_d % 10];
dis_smg[1] = smg_du[set_d / 10 % 10] ;
dis_smg[2] = smg_du[set_d / 100 % 10] & 0xdf ;
dis_smg[3] = smg_du[10];
}
}
链接:https://pan.baidu.com/s/13mObPBf6W5a1_tBT1_sZ3Q 提取码:06yg
|