📄 main1424.c
字号:
}
}
if(KEY_2==0)
{
DelayM(20);
tpKEY=1;
while(KEY_2==0);
DelayM(20);
if(tpKEY==1)
{
if(setPriceMod==0)
{
dayPrice+=0.1;
ChangeDayPrice();
LCD12864_string(6,1,arr_dayPrice);
}
else if(setPriceMod==1)
{
nightPrice+=0.1;
ChangeNightPrice();
LCD12864_string(6,1,arr_nightPrice);
}
}
tpKEY=0;
}
if(KEY_3==0)
{
DelayM(20);
tpKEY=1;
while(KEY_3==0);
DelayM(20);
if(tpKEY==1)
{
if(setPriceMod==0)
{
dayPrice-=0.1;
ChangeDayPrice();
LCD12864_string(6,1,arr_dayPrice);
}
else if(setPriceMod==1)
{
nightPrice-=0.1;
ChangeNightPrice();
LCD12864_string(6,1,arr_nightPrice);
}
}
tpKEY=0;
}
if(KEY_4==0)
{
DelayM(20);
CLERADISPLAY
return;
while(KEY_4==0);
DelayM(20);
}
}
}
void ShowSetWheel()
{
uchar tpKEY=0;
SetWheelMenu();
ChangeWheelPerimeter();
LCD12864_string(5,1,arr_wheelPerimeter);
while(1)
{
if(KEY_1==0)
{
DelayM(20);
tpKEY=1;
while(KEY_1==0);
DelayM(20);
if(tpKEY==1)
tpKEY=0;
}
if(KEY_2==0)
{
DelayM(20);
tpKEY=1;
while(KEY_2==0);
DelayM(20);
if(tpKEY==1)
{
wheelPerimeter++;
ChangeWheelPerimeter();
LCD12864_string(5,1,arr_wheelPerimeter);
}
tpKEY=0;
}
if(KEY_3==0)
{
DelayM(20);
tpKEY=1;
while(KEY_3==0);
DelayM(20);
if(tpKEY==1)
{
wheelPerimeter--;
ChangeWheelPerimeter();
LCD12864_string(5,1,arr_wheelPerimeter);
}
tpKEY=0;
}
if(KEY_4==0)
{
DelayM(20);
return;
while(KEY_4==0);
DelayM(20);
}
}
}
void ShowList()
{
uchar tpKEY;
ListMenu();
while(1)
{
if(KEY_1==0)
{
DelayM(20);
tpKEY=1;
while(KEY_1==0);
DelayM(20);
if(tpKEY==1)
ShowSetPrice(); //设置价格
}
if(KEY_2==0)
{
DelayM(20);
tpKEY=1;
while(KEY_2==0);
DelayM(20);
if(tpKEY==1)
ShowSetWheel(); //设置轮胎周长
tpKEY=0;
}
/* if(KEY_3==0)
{
DelayM(20);
reSet();
while(KEY_3==0);
DelayM(20);
} */
if(KEY_4==0)
{
DelayM(20);
tpKEY=1;
while(KEY_4==0);
DelayM(20);
if(tpKEY==1)
{
CLERADISPLAY
MainMenu();
tpKEY=0;
return;
}
}
}
}
void Billing()
{
circle=0;
hCircle=0;
isBilling=1; //开始计价
// uchar tpKEY=0;
BillingMenu();
while(1)
{
distance=(float)wheelPerimeter*hCircle/10000+waitDistance;
if(priceMod==0)
{
totalCost=distance*dayPrice;
}
else if(priceMod==1)
{
totalCost=distance*nightPrice;
}
ChangeTotalCost();
ChangeDistance();
BillingData();
if(KEY_2==0)
{
DelayM(20);
tpKEY=1;
while(KEY_2==0);
DelayM(20);
if(tpKEY==1)
{
tpKEY=0;
isBilling=0;
MainMenu();
return;
}
}
}
}
void ReSet()
{}
void SetMod()
{
if(priceMod==0)
{
LCD12864_string(7,4,"夜晚");
priceMod=1;
}
else if(priceMod==1)
{
LCD12864_string(7,4,"白天");
priceMod=0;
}
}
void Inital()
{
TMOD=0x20; //定时器器1 方式2
TH1=TIME1H;
TR1=1; //启动定时器1
ET1=1; //允许定时器1中断
EX1=1; //外部中断允许
IT1=0; //外部中断 0下降沿触发。
//外部中断 1下降沿触发。
EA=1; //CPU开中断
ChangeWheelPerimeter();
ChangeDayPrice();
ChangeNightPrice();
}
void IncHCircle() interrupt 2
{
if(isBilling==1)
{
if(circle==200)
{
//ChangeKCircle();
//LCD12864_string(1,1,arr_kCircle);
hCircle++;
circle=0;
}
circle++;
}
}
void TestWait() interrupt 3 //定时器1中断
{
// if(isBilling==1)
// {
// if(timeMs==10000)
// {timeMs=0;waitDistance++;}
//
// timeMs++;
// }
if(isBilling==1)
{
if(timeMs==0)
{
tpCircle=circle;
}
if(timeMs==10000)
{
if(tpCircle==circle)
{
//if(_testWait>=10) _testWait=10;
//else
_testWait++;
}
if(tpCircle!=circle)
{
_testWait=0;
}
if(_testWait>5)
{
waitTime++;
if(waitTime%300==0) //300 5分钟
waitDistance++;
}
timeMs=0;
}
timeMs++;
}
}
void main()
{
Inital();
Mcu_init();
CLERADISPLAY
MainMenu();
while(1)
{
if(KEY_1==0)
{
DelayM(20);
tpKEY=1;
while(KEY_1==0);
DelayM(20);
if(tpKEY==1)
{
ShowList();
tpKEY=0;
}
}
if(KEY_2==0)
{
DelayM(20);
tpKEY=1;
while(KEY_2==0);
DelayM(20);
if(tpKEY==1)
{
Billing();
tpKEY=0;
}
}
if(KEY_3==0)
{
DelayM(20);
// reSet();
while(KEY_3==0);
DelayM(20);
}
if(KEY_4==0)
{
DelayM(20);
tpKEY=1;
while(KEY_4==0);
DelayM(20);
if(tpKEY==1)
{
SetMod();
tpKEY=0;
}
}
//菜单
//计费 再按停止计费
//复位 ,系统复位(长按)
//白天模式(默认),晚上模式(按)
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -