单片机出租车计价器程序及原理图.docx
- 文档编号:23813576
- 上传时间:2023-05-21
- 格式:DOCX
- 页数:20
- 大小:164.26KB
单片机出租车计价器程序及原理图.docx
《单片机出租车计价器程序及原理图.docx》由会员分享,可在线阅读,更多相关《单片机出租车计价器程序及原理图.docx(20页珍藏版)》请在冰豆网上搜索。
单片机出租车计价器程序及原理图
#include
#include
#defineuintunsignedint
#defineucharunsignedchar
#defineDISPON0x3f//显示开
#defineDISPOFF0x3e//显示关
#defineFIRSTROW0xc0//显示起始行设置11L5L4L3L2L1L0,在0到63行间选择
#defineSETY0xb8//Y方向,8页64行,10111P2P1P0,0到8页选择
#defineSETX0x40//X方向,半屏64列,01C5C4C3C2C1C0,0到63列选择
/*P2+P0口16位编址,有效位是P2.3~P2.0,无关位用“1”表示
P2.0--RS,P2.1--RW,P2.2--CS2,P2.3--CS1
右屏命令和数据读写编址CS2CS1RWRS*/
#defineLLCD_CMD_WRXBYTE[0xf4ff]//0100
#defineLLCD_DAT_WRXBYTE[0xf5ff]//0101
#defineLLCD_CMD_RDXBYTE[0xf6ff]//0110
#defineLLCD_DAT_RDXBYTE[0xf7ff]//0111
/*左屏命令和数据读写编址*/
#defineRLCD_CMD_WRXBYTE[0xf8ff]//1000
#defineRLCD_DAT_WRXBYTE[0xf9ff]//1001
#defineRLCD_CMD_RDXBYTE[0xfaff]//1010
#defineRLCD_DAT_RDXBYTE[0xfbff]//1011
/**********************数据坐标记录**************************
左-路程:
整数部分x=9,y=1,小数部分x=31,y=1
左-路程费用:
整数部分x=9,y=3,小数部分x=31,y=3
总费用:
整数部分-左:
x=45,y=5
路程单价:
x=34,y=7
右-时间:
整数部分x=20,y=1
右-时间费用:
整数部分x=10,y=3,小数部分x=32,y=3
总费用:
小数部分-右:
x=2,y=5
时间单价:
x=44,y=7
*************************************************************/
#defineL_Mile_X_Z9
#defineL_Mile_X_D30
#defineL_Mile_Y1
#defineL_Cost_X_Z9
#defineL_Cost_X_D30
#defineL_Cost_Y3
#defineL_Total_X45
#defineL_Total_Y5
#defineL_Unit_X34
#defineL_Unit_Y7
#defineR_Time_X20
#defineR_Time_Y1
#defineR_Cost_X_Z10
#defineR_Cost_X_D31
#defineR_Cost_Y3
#defineR_Total_X2
#defineR_Total_Y5
#defineR_Unit_X44
#defineR_Unit_Y7
sbitLED=P2^7;
sbitSTART=P1^0;
sbitSTOP=P1^1;
sbitCLEAR=P1^2;
sbitMUINT_UP=P1^4;
sbitMUINT_D=P1^5;
sbitTUINT_UP=P1^6;
sbitTUINT_D=P1^7;
ucharMile_Unit=4,Time_Unit=2;
longtime_cost,time_cost_Z,time_cost_D,time_con_s,time_con_m;
longmile_cost,mile_cost_Z,mile_cost_D,mile_con_m,mile_con_km;
longspeed_con,speed_con_m,speed,speed_flag,cost_flag;
longtotal_z=5,total_d;
codecharshu[10][6]={
0x3E,0x41,0x41,0x41,0x3E,0x00,//0
0x00,0x42,0x7F,0x40,0x00,0x00,//1
0x42,0x61,0x51,0x49,0x46,0x00,//2
0x22,0x41,0x49,0x49,0x36,0x00,//3
0x38,0x24,0x22,0x7F,0x20,0x00,//4
0x27,0x45,0x45,0x45,0x39,0x00,//5
0x3E,0x45,0x45,0x45,0x38,0x00,//6
0x01,0x01,0x79,0x05,0x03,0x00,//7
0x36,0x49,0x49,0x49,0x36,0x00,//8
0x0E,0x51,0x51,0x51,0x3E,0x00,//9
};
/*************************初始化界面*****************************/
codeucharlogo[]=
{
0xFF,0x07,0x03,0xE1,0x11,0x09,0x09,0x09,0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x08,0x09,0x09,0x11,0xE1,0x03,0x07,0xFF,
0xFF,0x07,0x03,0xE1,0x11,0x09,0x09,0x09,0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x08,0x09,0x09,0x11,0xE1,0x03,0x07,0xFF,
0xFE,0x00,0x00,0xFF,0x00,0x7E,0x3C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFE,0x10,0x28,0x44,0x82,0x00,0xF8,0x08,0xF8,0x08,0xF8,0x00,0xFF,0x00,0x00,0xFF,
0xFF,0x00,0x00,0xFF,0x00,0x7E,0x3C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x04,
0xF8,0x04,0xFE,0x00,0xF4,0x00,0xF8,0x08,0xF8,0x08,0xF8,0x00,0xFF,0x00,0x00,0xFE,
0xFE,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x00,0x02,
0x02,0x02,0x02,0x02,0x00,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x02,0x02,
0x02,0x02,0x02,0x00,0x02,0x02,0x02,0x02,0x02,0x00,0x02,0x02,0x02,0x02,0x02,0x00,
0x00,0x00,0x40,0x80,0x00,0x00,0x00,0x80,0x40,0x00,0x00,0x00,0xFF,0x00,0x00,0xFF,
0xFF,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x00,0x02,0x02,0x02,0x02,0x02,0x00,
0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x40,0x80,0x00,0x00,0x00,0x80,0x40,0x00,0x00,0x00,0xFF,0x00,0x00,0xFE,
0xFE,0x00,0x00,0xFF,0x00,0xFC,0x78,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x12,0x12,0x13,0x7E,0x13,0x12,0x12,0x00,0x00,0x00,0xFF,0x00,0x00,0xFF,
0xFF,0x00,0x00,0xFF,0x00,0xFC,0x78,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x12,0x12,0x13,0x7E,0x13,0x12,0x12,0x00,0x00,0x00,0xFF,0x00,0x00,0xFE,
0xFE,0x00,0x00,0x01,0x02,0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x05,0x04,0x05,
0x05,0x05,0x05,0x05,0x04,0x05,0x05,0x05,0x05,0xC5,0x24,0x14,0x14,0x14,0x15,0x15,
0x15,0x15,0x15,0x14,0x15,0x15,0x15,0x15,0x15,0x14,0x15,0x15,0x15,0x15,0x15,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x12,0x11,0x10,0x10,0x1F,
0x1F,0x10,0x10,0x11,0x12,0x14,0x14,0x14,0x14,0x14,0x15,0x15,0x15,0x15,0x15,0x14,
0x15,0x15,0x15,0x15,0x15,0x14,0x15,0x15,0x15,0x15,0x15,0x14,0x14,0x14,0x14,0x15,
0x15,0x15,0x15,0x15,0x14,0x15,0x25,0xC5,0x05,0x05,0x04,0x05,0x05,0x05,0x05,0x05,
0x05,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x02,0x01,0x00,0x00,0xFE,
0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0xFF,0x7E,0x3C,
0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,
0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x49,0x4A,0x4C,
0xF8,0x4C,0x4A,0x49,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,
0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x04,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x05,0x05,0x05,
0x05,0x05,0x04,0x05,0x05,0x05,0x05,0x05,0x04,0x05,0x05,0x05,0x05,0x05,0x04,0xFC,
0xFC,0x04,0x05,0x05,0x05,0x05,0x05,0x04,0x05,0x05,0x05,0x05,0x05,0x04,0x05,0x05,
0x05,0x05,0x05,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
0x05,0x04,0x04,0x04,0x04,0x04,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,
0xFE,0xE0,0xC0,0x80,0x80,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80,0x80,0x9E,0xA0,
0x20,0x9E,0x80,0xBC,0x82,0x82,0xBC,0x80,0x3D,0x80,0x84,0x9E,0xA4,0xA4,0x80,0xB6,
0x36,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x3E,0x41,0x41,0x41,
0x3E,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80,0xC0,0xE0,0xFF,
0xFF,0xE0,0xC0,0x80,0x80,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80,0x80,0x9E,0xA0,
0x20,0x9E,0x80,0xBC,0x82,0x82,0xBC,0x80,0x3D,0x80,0x84,0x9E,0xA4,0xA4,0x80,0xB6,
0x36,0x80,0x80,0x3E,0x41,0x41,0x41,0x3E,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80,0xC0,0xE0,0xFE,
};
/*************************************************************
写命令
*************************************************************/
voidlcd_cmd_wr(ucharcmdcode,ucharright)
{
if(right)
RLCD_CMD_WR=cmdcode;
else
LLCD_CMD_WR=cmdcode;
}
/*************************************************************
写数据
*************************************************************/
voidlcd_data_wr(uchardispdata,ucharright)
{
if(right)
RLCD_DAT_WR=dispdata;
else
LLCD_DAT_WR=dispdata;
}
/*************************************************************
数据清屏
*************************************************************/
voidlcd_clr(void)
{
uchari,j;
for(i=0;i<8;i++)
{
lcd_cmd_wr(SETY+i,0);
lcd_cmd_wr(SETX,0);
lcd_cmd_wr(SETY+i,1);
lcd_cmd_wr(SETX,1);
for(j=0;j<64;j++)
{
lcd_data_wr(0,0);
lcd_data_wr(0,1);
}
}
}
/*************************************************************
写一个数字
*************************************************************/
voidlcd_shu_wr(ucharw,ucharx,uchary,ucharshu_1)
{
uchari;
lcd_cmd_wr(SETY+y,w);
lcd_cmd_wr(SETX+x,w);
for(i=0;i<6;i++)
lcd_data_wr(shu[shu_1][i],w);
}
/*************************************************************
写一个三个数字
*************************************************************/
voidlcd_sanshu_wr(ucharw,ucharx,uchary,uintstr)
{
uintbai,shi,ge;
bai=str/100;
shi=(str%100)/10;
ge=str%10;
lcd_shu_wr(w,x,y,bai);
lcd_shu_wr(w,x+6,y,shi);
lcd_shu_wr(w,x+12,y,ge);
}
/*************************************************************
写一贞128X64点的图片显示
*************************************************************/
voidlcd_bmp_wr(uchar*bmp)
{
uchari,j;
for(i=0;i<8;i++)
{
lcd_cmd_wr(SETY+i,0);
lcd_cmd_wr(SETX,0);
lcd_cmd_wr(SETY+i,1);
lcd_cmd_wr(SETX,1);
for(j=0;j<64;j++)
{
lcd_data_wr(bmp[128*i+j],0);
lcd_data_wr(bmp[128*i+j+64],1);
}
}
}
/*************************************************************
延时函数
*************************************************************/
DelayNms(uinty)
{
uintx;
for(;y>0;y--)
for(x=113;x>0;x--);
}
/*************************************************************
LCD初始化
**************
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 单片机 出租车 计价器 程序 原理图
![提示](https://static.bdocx.com/images/bang_tan.gif)