Browse Source

完成手机app设置部分

master
htujun 3 years ago
parent
commit
5dbb9e174e
  1. 180
      IRIN.LST
  2. BIN
      IRIN.OBJ
  3. 93
      IRIN.c
  4. 6
      i2c.LST
  5. BIN
      i2c.OBJ
  6. 4
      i2c.h
  7. 220
      lcd.LST
  8. BIN
      lcd.OBJ
  9. 172
      lcd.c
  10. 52
      lcd.h
  11. 390
      main.LST
  12. BIN
      main.OBJ
  13. 118
      main.c
  14. BIN
      pro
  15. 1319
      pro.M51
  16. 4
      pro.build_log.htm
  17. 650
      pro.hex
  18. 228
      pro.uvgui.QY
  19. 4
      pro.uvopt
  20. 116
      pwm.LST
  21. BIN
      pwm.OBJ
  22. 32
      pwm.c
  23. 27
      pwm.h

180
IRIN.LST

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
C51 COMPILER V9.56.0.0 IRIN 04/08/2022 03:09:39 PAGE 1
C51 COMPILER V9.56.0.0 IRIN 04/09/2022 17:31:01 PAGE 1
C51 COMPILER V9.56.0.0, COMPILATION OF MODULE IRIN
@ -11,15 +11,15 @@ line level source @@ -11,15 +11,15 @@ line level source
2 #include "i2c.h"
3
4 uint mileage = 0;
5
6 uint count=0;
7
8 uchar ms=0;
9 uint speed=0;
10 uint r_s=0;
11
12 extern uint model;
13 extern uchar set;
5 uint count=0;
6 uchar ms=0;
7 uint speed=0;
8 uint r_s=0;
9
10 extern uchar play;
11 extern uint Seep_model;
12 extern struct UserInfo usr;
13 extern uchar model;
14
15 void delay11(int i)
16 {
@ -40,85 +40,97 @@ line level source @@ -40,85 +40,97 @@ line level source
31
32 void display()
33 {
34 1 LcdSetCursor(0,0);
35 1 LcdShowStr(0,0,"");
36 1 Lcd1602_Write_Data(0x30+speed/100%10);
37 1 Lcd1602_Write_Data(0x30+speed/10%10);
38 1 Lcd1602_Write_Data(0x30+speed%10);
39 1 LcdShowStr(3,0,"KM/h ");
40 1
41 1 LcdShowStr(8,0,"");
42 1 Lcd1602_Write_Data(0x30+mileage/100%10);
43 1 Lcd1602_Write_Data(0x30+mileage/10%10);
44 1 Lcd1602_Write_Data(0x30+mileage%10);
45 1 LcdShowStr(11,0,"m ");
46 1
47 1 if(model == 0) LcdShowStr(13,0," ");
48 1 else if(model == 1) LcdShowStr(13, 0, "L");
49 1 else if(model == 2) LcdShowStr(13, 0, "M");
50 1 else LcdShowStr(13, 0, "H");
51 1 }
52
53
54 void Key_scan(){
55 1 if(k1==0)
C51 COMPILER V9.56.0.0 IRIN 04/08/2022 03:09:39 PAGE 2
34 1 // 显示速度
35 1 LcdWriteCom(0x80 + 2);
36 1 LcdWriteData(0x30+speed/100%10);
37 1 LcdWriteData(0x30+speed/10%10);
38 1 LcdWriteData(0x30+speed%10);
39 1
40 1 // 显示里程
41 1 LcdWriteCom(0x80 + 8);
42 1 LcdWriteData(0x30+mileage/1000%10);
43 1 LcdWriteData(0x30+mileage/100%10);
44 1 LcdWriteData(0x30+mileage/10%10);
45 1 LcdWriteData(0x30+mileage%10);
46 1 LcdWriteData('m');
47 1
48 1 LcdWriteCom(0x80 + 14);
49 1 if(Seep_model == 0) LcdWriteData('N');
50 1 else if(Seep_model == 1) LcdWriteData('L');
51 1 else if(Seep_model == 2) LcdWriteData('M');
52 1 else if(Seep_model == 3) LcdWriteData('H');
53 1
54 1 // 显示目标里程
55 1 LcdWriteCom(0x80 + 0x40);
C51 COMPILER V9.56.0.0 IRIN 04/09/2022 17:31:01 PAGE 2
56 1 {
57 2 delay11(1000); //Ïû¶¶´¦Àí
58 2 if(k1==0){
59 3 model++;
60 3 if(model >= 4) model = 0;
61 3 }
62 2 while(!k1);
63 2 }
64 1
65 1 if(k2==0)
66 1 {
67 2 delay11(1000); //Ïû¶¶´¦Àí
68 2 if(k2==0){
69 3 set = 1;
70 3 }
71 2 while(!k2);
72 2 }
73 1
74 1 }
75
76 void time0() interrupt 1
77 {
78 1 static int time = 0;
79 1 TH0=0XFc;
80 1 TL0=0X18;
81 1 time++;
82 1 pwm_out_right_moto();
83 1 if(time >= 500){
84 2 EX1=0;
85 2 time = 0;
86 2 r_s=count;
87 2 count=0;
88 2 EX1=1;
89 2 speed=speed*0.5+(r_s*6)*0.5;
90 2 speed=(0.15*speed);
91 2 mileage = mileage+(r_s*2.5/20);
92 2 }
93 1 }
94
95 void int1() interrupt 2
96 {
97 1 count++;
98 1 }
99
100
101
102
56 1 LcdWriteData(0x30+usr.target_mileage/1000%10);
57 1 LcdWriteData(0x30+usr.target_mileage/100%10);
58 1 LcdWriteData(0x30+usr.target_mileage/10%10);
59 1 LcdWriteData(0x30+usr.target_mileage%10);
60 1 LcdWriteData('m');
61 1
62 1 LcdWriteCom(0x80 + 0x40 + 8);
63 1 LcdWriteData(0x30+usr.Remaining_mileage/1000%10);
64 1 LcdWriteData(0x30+usr.Remaining_mileage/100%10);
65 1 LcdWriteData(0x30+usr.Remaining_mileage/10%10);
66 1 LcdWriteData(0x30+usr.Remaining_mileage%10);
67 1 LcdWriteData('m');
68 1
69 1 LcdWriteCom(0x80 + 0x40 + 14);
70 1 if(model == 0) LcdWriteData('D');
71 1 else LcdWriteData('S');
72 1 }
73
74 void Key_scan(){
75 1 if(k1==0){
76 2 delay11(1000);
77 2 if(k1==0){
78 3 Seep_model++;
79 3 if(Seep_model >= 4) Seep_model = 0;
80 3 }
81 2 while(!k1);
82 2 }
83 1 }
84
85 void time0() interrupt 1
86 {
87 1 static int time = 0;
88 1 TH0=0XFc;
89 1 TL0=0X18;
90 1 time++;
91 1 pwm_out_right_moto();
92 1 if(time >= 500){
93 2 EX1=0;
94 2 time = 0;
95 2 r_s = count * 3 / 20; // 500ms计算一次 求每秒钟的圈数,珊格数为20 r_s = count * 2 / 2
-0
96 2 speed= (r_s * 6) * 2;
97 2 mileage = mileage + (count / 20 * 3);
98 2 if(mileage > 9999) mileage = 9999;
99 2 count=0;
100 2 EX1 = 1;
101 2 }
102 1 }
103
104
105
104 void int1() interrupt 2
105 {
106 1 count++;
107 1 }
108
109
110
111
112
113
114
C51 COMPILER V9.56.0.0 IRIN 04/09/2022 17:31:01 PAGE 3
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 623 ----
CONSTANT SIZE = 26 ----
CODE SIZE = 712 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 11 ----

BIN
IRIN.OBJ

Binary file not shown.

93
IRIN.c

@ -2,15 +2,15 @@ @@ -2,15 +2,15 @@
#include "i2c.h"
uint mileage = 0;
uint count=0;
uchar ms=0;
uint speed=0;
uint r_s=0;
extern uint model;
extern uchar set;
extern uchar play;
extern uint Seep_model;
extern struct UserInfo usr;
extern uchar model;
void delay11(int i)
{
@ -31,46 +31,55 @@ void IRIN_Init(void) @@ -31,46 +31,55 @@ void IRIN_Init(void)
void display()
{
LcdSetCursor(0,0);
LcdShowStr(0,0,"");
Lcd1602_Write_Data(0x30+speed/100%10);
Lcd1602_Write_Data(0x30+speed/10%10);
Lcd1602_Write_Data(0x30+speed%10);
LcdShowStr(3,0,"KM/h ");
LcdShowStr(8,0,"");
Lcd1602_Write_Data(0x30+mileage/100%10);
Lcd1602_Write_Data(0x30+mileage/10%10);
Lcd1602_Write_Data(0x30+mileage%10);
LcdShowStr(11,0,"m ");
if(model == 0) LcdShowStr(13,0," ");
else if(model == 1) LcdShowStr(13, 0, "L");
else if(model == 2) LcdShowStr(13, 0, "M");
else LcdShowStr(13, 0, "H");
// 显示速度
LcdWriteCom(0x80 + 2);
LcdWriteData(0x30+speed/100%10);
LcdWriteData(0x30+speed/10%10);
LcdWriteData(0x30+speed%10);
// 显示里程
LcdWriteCom(0x80 + 8);
LcdWriteData(0x30+mileage/1000%10);
LcdWriteData(0x30+mileage/100%10);
LcdWriteData(0x30+mileage/10%10);
LcdWriteData(0x30+mileage%10);
LcdWriteData('m');
LcdWriteCom(0x80 + 14);
if(Seep_model == 0) LcdWriteData('N');
else if(Seep_model == 1) LcdWriteData('L');
else if(Seep_model == 2) LcdWriteData('M');
else if(Seep_model == 3) LcdWriteData('H');
// 显示目标里程
LcdWriteCom(0x80 + 0x40);
LcdWriteData(0x30+usr.target_mileage/1000%10);
LcdWriteData(0x30+usr.target_mileage/100%10);
LcdWriteData(0x30+usr.target_mileage/10%10);
LcdWriteData(0x30+usr.target_mileage%10);
LcdWriteData('m');
LcdWriteCom(0x80 + 0x40 + 8);
LcdWriteData(0x30+usr.Remaining_mileage/1000%10);
LcdWriteData(0x30+usr.Remaining_mileage/100%10);
LcdWriteData(0x30+usr.Remaining_mileage/10%10);
LcdWriteData(0x30+usr.Remaining_mileage%10);
LcdWriteData('m');
LcdWriteCom(0x80 + 0x40 + 14);
if(model == 0) LcdWriteData('D');
else LcdWriteData('S');
}
void Key_scan(){
if(k1==0)
{
delay11(1000); //Ïû¶¶´¦Àí
if(k1==0){
delay11(1000);
if(k1==0){
model++;
if(model >= 4) model = 0;
Seep_model++;
if(Seep_model >= 4) Seep_model = 0;
}
while(!k1);
}
if(k2==0)
{
delay11(1000); //Ïû¶¶´¦Àí
if(k2==0){
set = 1;
}
while(!k2);
}
}
void time0() interrupt 1
@ -83,12 +92,12 @@ void time0() interrupt 1 @@ -83,12 +92,12 @@ void time0() interrupt 1
if(time >= 500){
EX1=0;
time = 0;
r_s=count;
r_s = count * 3 / 20; // 500ms计算一次 求每秒钟的圈数,珊格数为20 r_s = count * 2 / 20
speed= (r_s * 6) * 2;
mileage = mileage + (count / 20 * 3);
if(mileage > 9999) mileage = 9999;
count=0;
EX1=1;
speed=speed*0.5+(r_s*6)*0.5;
speed=(0.15*speed);
mileage = mileage+(r_s*2.5/20);
EX1 = 1;
}
}

6
i2c.LST

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
C51 COMPILER V9.56.0.0 I2C 04/08/2022 02:58:55 PAGE 1
C51 COMPILER V9.56.0.0 I2C 04/09/2022 14:48:34 PAGE 1
C51 COMPILER V9.56.0.0, COMPILATION OF MODULE I2C
@ -62,7 +62,7 @@ line level source @@ -62,7 +62,7 @@ line level source
53 /*******************************************************************************
54 * 函数名 : I2cSendByte(unsigned char dat)
55 * 函数功能 : 通过I2C发送一个字节。在SCL时钟信号高电平期间,保持发送信号SDA保持稳定
C51 COMPILER V9.56.0.0 I2C 04/08/2022 02:58:55 PAGE 2
C51 COMPILER V9.56.0.0 I2C 04/09/2022 14:48:34 PAGE 2
56 * 输入 : num
57 * 输出 : 0或1。发送成功返回1,发送失败返回0
@ -126,7 +126,7 @@ line level source @@ -126,7 +126,7 @@ line level source
115 1 }
116
117
C51 COMPILER V9.56.0.0 I2C 04/08/2022 02:58:55 PAGE 3
C51 COMPILER V9.56.0.0 I2C 04/09/2022 14:48:34 PAGE 3
118 /*******************************************************************************
119 * 函数名 : void At24c02Write(unsigned char addr,unsigned char dat)

BIN
i2c.OBJ

Binary file not shown.

4
i2c.h

@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
#include <reg51.h>
sbit SCL=P0^1;
sbit SDA=P0^0;
sbit SCL=P1^1;
sbit SDA=P1^0;
void I2cStart();
void I2cStop();

220
lcd.LST

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
C51 COMPILER V9.56.0.0 LCD 04/08/2022 02:58:55 PAGE 1
C51 COMPILER V9.56.0.0 LCD 04/09/2022 15:45:29 PAGE 1
C51 COMPILER V9.56.0.0, COMPILATION OF MODULE LCD
@ -7,92 +7,152 @@ COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE lcd.c OPTIMIZE(8,SPEED) BROWSE D @@ -7,92 +7,152 @@ COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE lcd.c OPTIMIZE(8,SPEED) BROWSE D
line level source
1 #include "lcd.h"
1 #include"lcd.h"
2
3
4 void Read_Busy() //忙检测函数,判断bit7是0,允许执行;1禁止
5 {
6 1 unsigned char sta; //
7 1 LCD1602_DB = 0xff;
8 1 LCD1602_RS = 0;
9 1 LCD1602_RW = 1;
10 1 do
11 1 {
12 2 LCD1602_EN = 1;
13 2 sta = LCD1602_DB;
14 2 LCD1602_EN = 0; //使能,用完就拉低,释放总线
15 2 }while(sta & 0x80);
16 1 }
17
18 void Lcd1602_Write_Cmd(unsigned char cmd) //写命令
19 {
20 1 Read_Busy();
21 1 LCD1602_RS = 0;
22 1 LCD1602_RW = 0;
23 1 LCD1602_DB = cmd;
24 1 LCD1602_EN = 1;
25 1 LCD1602_EN = 0;
26 1 }
27
28 void Lcd1602_Write_Data(unsigned char dat) //写数据
29 {
30 1 Read_Busy();
31 1 LCD1602_RS = 1;
32 1 LCD1602_RW = 0;
33 1 LCD1602_DB = dat;
34 1 LCD1602_EN = 1;
35 1 LCD1602_EN = 0;
36 1 }
37
38 void LcdSetCursor(unsigned char x,unsigned char y) //坐标显示
39 {
40 1 unsigned char addr;
41 1 if(y == 0)
42 1 addr = 0x00 + x;
43 1 else
44 1 addr = 0x40 + x;
45 1
46 1 Lcd1602_Write_Cmd(addr|0x80);
47 1 }
48
49 //按指定位置显示一个字符
50 void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData)
51 {
52 1 Y &= 0x1;
53 1 X &= 0xF; //限制X不能大于15,Y不能大于1
54 1 if (Y) X |= 0x40; //当要显示第二行时地址码+0x40;
55 1 X |= 0x80; //算出指令码
C51 COMPILER V9.56.0.0 LCD 04/08/2022 02:58:55 PAGE 2
56 1 Lcd1602_Write_Cmd(X); //发命令字
57 1 Lcd1602_Write_Data(DData); //发数据
58 1 }
59
60
61 void LcdShowStr(unsigned char x,unsigned char y,unsigned char *str) //显示字符串
62 {
63 1 LcdSetCursor(x,y); //当前字符的坐标
64 1 while(*str != '\0')
65 1 {
66 2 Lcd1602_Write_Data(*str++);
67 2 }
68 1 }
69
70 void InitLcd1602() //1602初始化
71 {
72 1 Lcd1602_Write_Cmd(0x38); //打开,5*8,8位数据
73 1 Lcd1602_Write_Cmd(0x0c);
74 1 Lcd1602_Write_Cmd(0x06);
75 1 Lcd1602_Write_Cmd(0x01); //清屏
76 1 }
3 /*******************************************************************************
4 * 函 数 名 : Lcd1602_Delay1ms
5 * 函数功能 : 延时函数,延时1ms
6 * 输 入 : c
7 * 输 出 : 无
8 * 说 名 : 该函数是在12MHZ晶振下,12分频单片机的延时。
9 *******************************************************************************/
10
11 void Lcd1602_Delay1ms(uint c) //误差 0us
12 {
13 1 uchar a,b;
14 1 for (; c>0; c--)
15 1 {
16 2 for (b=199;b>0;b--)
17 2 {
18 3 for(a=1;a>0;a--);
19 3 }
20 2 }
21 1
22 1 }
23
24 /*******************************************************************************
25 * 函 数 名 : LcdWriteCom
26 * 函数功能 : 向LCD写入一个字节的命令
27 * 输 入 : com
28 * 输 出 : 无
29 *******************************************************************************/
30 #ifndef LCD1602_4PINS //当没有定义这个LCD1602_4PINS时
31 void LcdWriteCom(uchar com) //写入命令
32 {
33 1 LCD1602_E = 0; //使能
34 1 LCD1602_RS = 0; //选择发送命令
35 1 LCD1602_RW = 0; //选择写入
36 1
37 1 LCD1602_DATAPINS = com; //放入命令
38 1 Lcd1602_Delay1ms(1); //等待数据稳定
39 1
40 1 LCD1602_E = 1; //写入时序
41 1 Lcd1602_Delay1ms(5); //保持时间
42 1 LCD1602_E = 0;
43 1 }
44 #else
void LcdWriteCom(uchar com) //写入命令
{
LCD1602_E = 0; //使能清零
LCD1602_RS = 0; //选择写入命令
LCD1602_RW = 0; //选择写入
LCD1602_DATAPINS = com; //由于4位的接线是接到P0口的高四位,所以传送高四位不用改
Lcd1602_Delay1ms(1);
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5);
C51 COMPILER V9.56.0.0 LCD 04/09/2022 15:45:29 PAGE 2
LCD1602_E = 0;
// Lcd1602_Delay1ms(1);
LCD1602_DATAPINS = com << 4; //发送低四位
Lcd1602_Delay1ms(1);
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5);
LCD1602_E = 0;
}
#endif
67 /*******************************************************************************
68 * 函 数 名 : LcdWriteData
69 * 函数功能 : 向LCD写入一个字节的数据
70 * 输 入 : dat
71 * 输 出 : 无
72 *******************************************************************************/
73 #ifndef LCD1602_4PINS
74 void LcdWriteData(uchar dat) //写入数据
75 {
76 1 LCD1602_E = 0; //使能清零
77 1 LCD1602_RS = 1; //选择输入数据
78 1 LCD1602_RW = 0; //选择写入
79 1
80 1 LCD1602_DATAPINS = dat; //写入数据
81 1 Lcd1602_Delay1ms(1);
82 1
83 1 LCD1602_E = 1; //写入时序
84 1 Lcd1602_Delay1ms(5); //保持时间
85 1 LCD1602_E = 0;
86 1 }
87 #else
void LcdWriteData(uchar dat) //写入数据
{
LCD1602_E = 0; //使能清零
LCD1602_RS = 1; //选择写入数据
LCD1602_RW = 0; //选择写入
LCD1602_DATAPINS = dat; //由于4位的接线是接到P0口的高四位,所以传送高四位不用改
Lcd1602_Delay1ms(1);
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5);
LCD1602_E = 0;
LCD1602_DATAPINS = dat << 4; //写入低四位
Lcd1602_Delay1ms(1);
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5);
LCD1602_E = 0;
}
#endif
109 /*******************************************************************************
110 * 函 数 名 : LcdInit()
111 * 函数功能 : 初始化LCD屏
112 * 输 入 : 无
113 * 输 出 : 无
114 *******************************************************************************/
115 #ifndef LCD1602_4PINS
116 void LcdInit() //LCD初始化子程序
117 {
C51 COMPILER V9.56.0.0 LCD 04/09/2022 15:45:29 PAGE 3
118 1 LcdWriteCom(0x38); //开显示
119 1 LcdWriteCom(0x0c); //开显示不显示光标
120 1 LcdWriteCom(0x06); //写一个指针加1
121 1 LcdWriteCom(0x01); //清屏
122 1 LcdWriteCom(0x80); //设置数据指针起点
123 1 }
124 #else
void LcdInit() //LCD初始化子程序
{
LcdWriteCom(0x32); //将8位总线转为4位总线
LcdWriteCom(0x28); //在四位线下的初始化
LcdWriteCom(0x0c); //开显示不显示光标
LcdWriteCom(0x06); //写一个指针加1
LcdWriteCom(0x01); //清屏
LcdWriteCom(0x80); //设置数据指针起点
}
#endif
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 157 ----
CODE SIZE = 87 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 3
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.

BIN
lcd.OBJ

Binary file not shown.

172
lcd.c

@ -1,76 +1,134 @@ @@ -1,76 +1,134 @@
#include "lcd.h"
#include"lcd.h"
/*******************************************************************************
* : Lcd1602_Delay1ms
* : 1ms
* : c
* :
* : 12MHZ晶振下12
*******************************************************************************/
void Read_Busy() //忙检测函数,判断bit7是0,允许执行;1禁止
void Lcd1602_Delay1ms(uint c) //误差 0us
{
unsigned char sta; //
LCD1602_DB = 0xff;
LCD1602_RS = 0;
LCD1602_RW = 1;
do
{
LCD1602_EN = 1;
sta = LCD1602_DB;
LCD1602_EN = 0; //使能,用完就拉低,释放总线
}while(sta & 0x80);
}
uchar a,b;
for (; c>0; c--)
{
for (b=199;b>0;b--)
{
for(a=1;a>0;a--);
}
}
void Lcd1602_Write_Cmd(unsigned char cmd) //写命令
{
Read_Busy();
LCD1602_RS = 0;
LCD1602_RW = 0;
LCD1602_DB = cmd;
LCD1602_EN = 1;
LCD1602_EN = 0;
}
void Lcd1602_Write_Data(unsigned char dat) //写数据
/*******************************************************************************
* : LcdWriteCom
* : LCD写入一个字节的命令
* : com
* :
*******************************************************************************/
#ifndef LCD1602_4PINS //当没有定义这个LCD1602_4PINS时
void LcdWriteCom(uchar com) //写入命令
{
Read_Busy();
LCD1602_RS = 1;
LCD1602_RW = 0;
LCD1602_DB = dat;
LCD1602_EN = 1;
LCD1602_EN = 0;
}
LCD1602_E = 0; //使能
LCD1602_RS = 0; //选择发送命令
LCD1602_RW = 0; //选择写入
void LcdSetCursor(unsigned char x,unsigned char y) //坐标显示
{
unsigned char addr;
if(y == 0)
addr = 0x00 + x;
else
addr = 0x40 + x;
LCD1602_DATAPINS = com; //放入命令
Lcd1602_Delay1ms(1); //等待数据稳定
Lcd1602_Write_Cmd(addr|0x80);
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5); //保持时间
LCD1602_E = 0;
}
#else
void LcdWriteCom(uchar com) //写入命令
{
LCD1602_E = 0; //使能清零
LCD1602_RS = 0; //选择写入命令
LCD1602_RW = 0; //选择写入
LCD1602_DATAPINS = com; //由于4位的接线是接到P0口的高四位,所以传送高四位不用改
Lcd1602_Delay1ms(1);
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5);
LCD1602_E = 0;
// Lcd1602_Delay1ms(1);
LCD1602_DATAPINS = com << 4; //发送低四位
Lcd1602_Delay1ms(1);
//按指定位置显示一个字符
void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData)
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5);
LCD1602_E = 0;
}
#endif
/*******************************************************************************
* : LcdWriteData
* : LCD写入一个字节的数据
* : dat
* :
*******************************************************************************/
#ifndef LCD1602_4PINS
void LcdWriteData(uchar dat) //写入数据
{
Y &= 0x1;
X &= 0xF; //限制X不能大于15,Y不能大于1
if (Y) X |= 0x40; //当要显示第二行时地址码+0x40;
X |= 0x80; //算出指令码
Lcd1602_Write_Cmd(X); //发命令字
Lcd1602_Write_Data(DData); //发数据
LCD1602_E = 0; //使能清零
LCD1602_RS = 1; //选择输入数据
LCD1602_RW = 0; //选择写入
LCD1602_DATAPINS = dat; //写入数据
Lcd1602_Delay1ms(1);
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5); //保持时间
LCD1602_E = 0;
}
#else
void LcdWriteData(uchar dat) //写入数据
{
LCD1602_E = 0; //使能清零
LCD1602_RS = 1; //选择写入数据
LCD1602_RW = 0; //选择写入
LCD1602_DATAPINS = dat; //由于4位的接线是接到P0口的高四位,所以传送高四位不用改
Lcd1602_Delay1ms(1);
void LcdShowStr(unsigned char x,unsigned char y,unsigned char *str) //显示字符串
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5);
LCD1602_E = 0;
LCD1602_DATAPINS = dat << 4; //写入低四位
Lcd1602_Delay1ms(1);
LCD1602_E = 1; //写入时序
Lcd1602_Delay1ms(5);
LCD1602_E = 0;
}
#endif
/*******************************************************************************
* : LcdInit()
* : LCD屏
* :
* :
*******************************************************************************/
#ifndef LCD1602_4PINS
void LcdInit() //LCD初始化子程序
{
LcdSetCursor(x,y); //当前字符的坐标
while(*str != '\0')
{
Lcd1602_Write_Data(*str++);
}
LcdWriteCom(0x38); //开显示
LcdWriteCom(0x0c); //开显示不显示光标
LcdWriteCom(0x06); //写一个指针加1
LcdWriteCom(0x01); //清屏
LcdWriteCom(0x80); //设置数据指针起点
}
void InitLcd1602() //1602初始化
#else
void LcdInit() //LCD初始化子程序
{
Lcd1602_Write_Cmd(0x38); //打开,5*8,8位数据
Lcd1602_Write_Cmd(0x0c);
Lcd1602_Write_Cmd(0x06);
Lcd1602_Write_Cmd(0x01); //清屏
LcdWriteCom(0x32); //将8位总线转为4位总线
LcdWriteCom(0x28); //在四位线下的初始化
LcdWriteCom(0x0c); //开显示不显示光标
LcdWriteCom(0x06); //写一个指针加1
LcdWriteCom(0x01); //清屏
LcdWriteCom(0x80); //设置数据指针起点
}
#endif

52
lcd.h

@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
#ifndef __LCD_H_
#define __LCD_H_
#ifndef __LCD_H_
#define __LCD_H_
/**********************************
使4
使8
使4
使8
**********************************/
//#define LCD1602_4PINS
/**********************************
**********************************/
#include <reg51.h>
#include<reg51.h>
//---重定义关键词---//
//---重定义关键词---//
#ifndef uchar
#define uchar unsigned char
#endif
@ -21,33 +21,23 @@ @@ -21,33 +21,23 @@
#endif
/**********************************
PIN口定义
PIN口定义
**********************************/
//#define LCD1602_DB P0 //data bus 数据总线
//sbit LCD1602_RS = P2^6;
//sbit LCD1602_RW = P2^5;
//sbit LCD1602_EN = P2^7;
#define LCD1602_DB P2 //data bus 数据总线
sbit LCD1602_RS=P0^7;
sbit LCD1602_RW=P0^6;
sbit LCD1602_EN=P0^5;
#define LCD1602_DATAPINS P2
sbit LCD1602_E=P1^4;
sbit LCD1602_RW=P1^5;
sbit LCD1602_RS=P1^6;
/**********************************
**********************************/
/*在51单片机12MHZ时钟下的延时函数*/
void Lcd1602_Delay1ms(uint c); //误差 0us
void Read_Busy(); //忙检测函数,判断bit7是0,允许执行;1禁止
void Lcd1602_Write_Cmd(unsigned char cmd); //写命令
void Lcd1602_Write_Data(unsigned char dat); //写数据
void LcdSetCursor(unsigned char x,unsigned char y); //坐标显示
void LcdShowStr(unsigned char x,unsigned char y,unsigned char *str); //显示字符串
void InitLcd1602(); //1602初始化
void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData);
/*在51单片机12MHZ时钟下的延时函数*/
void Lcd1602_Delay1ms(uint c); //误差 0us
/*LCD1602写入8位命令子函数*/
void LcdWriteCom(uchar com);
/*LCD1602写入8位数据子函数*/
void LcdWriteData(uchar dat) ;
/*LCD1602初始化子程序*/
void LcdInit();
#endif

390
main.LST

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
C51 COMPILER V9.56.0.0 MAIN 04/08/2022 03:21:37 PAGE 1
C51 COMPILER V9.56.0.0 MAIN 04/09/2022 18:14:52 PAGE 1
C51 COMPILER V9.56.0.0, COMPILATION OF MODULE MAIN
@ -26,220 +26,206 @@ line level source @@ -26,220 +26,206 @@ line level source
17 extern uint mileage;
18 extern uint speed;
19
20 uint model = 0;
20 uint Seep_model = 0;
21
22 extern unsigned char pwm_value;
23
24
25 struct UserInfo{
26 int height;
27 int weight;
28 int target_mileage;
29 int target_speed;
30 };
31
32 uchar set = 0;
24 uchar play = 0;
25
26 // model
27 uchar model = 0;
28
29 struct UserInfo usr;
30
31 uchar Receive;
32 uchar Recive_table[40];
33
34 struct UserInfo usr;
34 bit accept = 0;
35
36 /*****************相关变量**************/
37
38 uchar Receive;
39 uchar Recive_table[40]; //用于接收wifi模块反馈到MCU上的数据
40
41 bit accept = 0;
42
43 void delayms(unsigned int ms)
44 {
45 1 unsigned char i=100,j;
46 1 for(;ms;ms--)
47 1 {
48 2 while(--i)
49 2 {
50 3 j=10;
51 3 while(--j);
52 3 }
53 2 }
54 1 }
55
C51 COMPILER V9.56.0.0 MAIN 04/08/2022 03:21:37 PAGE 2
36 void delayms(unsigned int ms)
37 {
38 1 unsigned char i=100,j;
39 1 for(;ms;ms--)
40 1 {
41 2 while(--i)
42 2 {
43 3 j=10;
44 3 while(--j);
45 3 }
46 2 }
47 1 }
48
49 void Uart_Init()
50 {
51 1 TMOD = 0x20 | 0x01;
52 1 SCON = 0x50;
53 1 TH1 = 0xFD;
54 1 TL1 = TH1;
55 1 PCON = 0x00;
C51 COMPILER V9.56.0.0 MAIN 04/09/2022 18:14:52 PAGE 2
56 void Uart_Init()
57 {
58 1 TMOD = 0x20 | 0x01;
59 1 SCON = 0x50;
60 1 TH1 = 0xFD;
61 1 TL1 = TH1;
62 1 PCON = 0x00;
63 1 EA = 1;
64 1 ES = 1;
65 1 TR1 = 1;
66 1 }
67
68 void us_delay(uchar t)
69 {
70 1 while(t--);
71 1 }
72
73 void Send_Uart(uchar value)
74 {
75 1 ES=0;
76 1 TI=0;
77 1 SBUF=value;
78 1 while(TI==0);
79 1 TI=0;
80 1 ES=1;
81 1 }
82
83 void Bluetooth_Set(uchar *puf)
84 {
85 1 while(*puf!='\0')
86 1 {
87 2 Send_Uart(*puf);
88 2 us_delay(5);
89 2 puf++;
90 2 }
91 1 }
92
93
94 void saveUserInfo(){
95 1 int target = 0;
96 1 target = usr.height >> 8;
97 1 At24c02Write(3, target);
98 1 delayms(2);
99 1 target = (usr.height) & 0x00ff;
100 1 At24c02Write(4, target);
101 1 delayms(2);
102 1 target = (usr.weight) >> 8;
103 1 At24c02Write(5, target);
104 1 delayms(2);
105 1 target = (usr.weight) & 0x00ff;
106 1 At24c02Write(6, target);
107 1 delayms(2);
108 1 }
109
110
111 void Bluetooth_Accept(){
112 1 int target1 = 0, target2 = 0, i = 0;
113 1 if(accept){
114 2 if(strstr(Recive_table, "inquire") != NULL){
115 3 memset(Recive_table, 0, sizeof(Recive_table));
116 3 sprintf(Recive_table, "speed:%d km/h mileage:%d m\r\n",speed, mileage);
117 3 Bluetooth_Set(Recive_table);
C51 COMPILER V9.56.0.0 MAIN 04/08/2022 03:21:37 PAGE 3
56 1 EA = 1;
57 1 ES = 1;
58 1 TR1 = 1;
59 1 }
60
61 void us_delay(uchar t)
62 {
63 1 while(t--);
64 1 }
65
66 void Send_Uart(uchar value)
67 {
68 1 ES=0;
69 1 TI=0;
70 1 SBUF=value;
71 1 while(TI==0);
72 1 TI=0;
73 1 ES=1;
74 1 }
75
76 void Bluetooth_Set(uchar *puf)
77 {
78 1 while(*puf!='\0')
79 1 {
80 2 Send_Uart(*puf);
81 2 us_delay(5);
82 2 puf++;
83 2 }
84 1 }
85
86 // 保存用户的数据
87 void saveUserInfo(){
88 1 int target = 0;
89 1 At24c02Write(3, usr.Seep_model);
90 1 delayms(2);
91 1 target = (usr.target_mileage) >> 8;
92 1 At24c02Write(5, target);
93 1 delayms(2);
94 1 target = (usr.target_mileage) & 0x00ff;
95 1 At24c02Write(6, target);
96 1 delayms(2);
97 1 }
98
99 void Bluetooth_Accept(){
100 1 int target1 = 0, target2 = 0, i = 0;
101 1 if(accept){
102 2 if(strstr(Recive_table, "inquire") != NULL){
103 3 memset(Recive_table, 0, sizeof(Recive_table));
104 3 sprintf(Recive_table, "speed:%d m/min mileage:%d m\r\n",speed, mileage);
105 3 Bluetooth_Set(Recive_table);
106 3 }else if(strstr(Recive_table, "model") != NULL){
107 3 if(model == 0) model = 1;
108 3 else model = 0;
109 3 if(model == 0) Seep_model = 0;
110 3 memset(Recive_table, 0, sizeof(Recive_table));
111 3 sprintf(Recive_table, "Model SET OK\r\n");
112 3 Bluetooth_Set(Recive_table);
113 3 At24c02Write(4, model);
114 3 }else if(strstr(Recive_table, "clear") != NULL){
115 3 // 清空里程
116 3 mileage = 0;
117 3 Bluetooth_Set("reset mileage OK!\r\n");
C51 COMPILER V9.56.0.0 MAIN 04/09/2022 18:14:52 PAGE 3
118 3 }else if(strstr(Recive_table, "set:") != NULL){
119 3 target1 = strstr(Recive_table, "(") - Recive_table;
120 3 target2 = strstr(Recive_table, ",") - Recive_table;
121 3 usr.height = 0;
122 3 for(i = target1 + 1; i < target2; i++){
123 4 usr.height = usr.height * 10 + (*(Recive_table + i) - 0x30);
124 4 }
125 3 Bluetooth_Set(Recive_table);
126 3 target1 = strstr(Recive_table, ",") - Recive_table;
127 3 target2 = strstr(Recive_table, ")") - Recive_table;
128 3 usr.weight = 0;
129 3 for(i = target1 + 1; i < target2; i++){
130 4 usr.weight = usr.weight * 10 + (*(Recive_table + i) - 0x30);
131 4 }
132 3 memset(Recive_table, 0, sizeof(Recive_table));
133 3 sprintf(Recive_table, "SET OK\r\n",usr.height, usr.weight);
134 3 Bluetooth_Set(Recive_table);
135 3
136 3 // 计算
137 3 usr.target_mileage = (usr.weight / usr.height) * (usr.weight / usr.height) / 22 * 3000;
138 3 usr.target_speed = 10 - (usr.weight / usr.height) * (usr.weight / usr.height) / 22 ;
139 3 saveUserInfo();
140 3 }
141 2 memset(Recive_table, 0, sizeof(Recive_table));
142 2 accept = 0;
143 2 }
144 1 }
145
146 void ReadData(){
147 1 mileage = At24c02Read(1) * 255 + At24c02Read(2);
148 1 set = At24c02Read(7);
149 1 if(set){
150 2 usr.height = 0;
151 2 usr.weight = 0;
152 2
153 2 At24c02Write(1, 0);
154 2 delayms(2);
155 2 At24c02Write(2, 0);
156 2 delayms(2);
157 2
158 2 At24c02Write(3, 0);
159 2 delayms(2);
160 2 At24c02Write(4, 0);
161 2 delayms(2);
162 2 At24c02Write(5, 0);
163 2 delayms(2);
164 2 At24c02Write(6, 0);
165 2
166 2 }else{
167 2 usr.height = At24c02Read(3) * 255 + At24c02Read(4);
168 2 usr.weight = At24c02Read(5) * 255 + At24c02Read(6);
169 2 }
170 1 }
171
172
173
174
175
176 void WriteData(){
177 1 int target = mileage >> 8;
178 1 At24c02Write(1, target);
179 1 delayms(2);
C51 COMPILER V9.56.0.0 MAIN 04/08/2022 03:21:37 PAGE 4
118 3 }
119 2 else if(strstr(Recive_table, "speed") != NULL){
120 3 Seep_model++;
121 3 if(Seep_model >= 4) Seep_model = 0;
122 3 usr.Seep_model = Seep_model;
123 3 }
124 2 else if(strstr(Recive_table, "set:") != NULL){
125 3 target1 = strstr(Recive_table, "(") - Recive_table;
126 3 target2 = strstr(Recive_table, ",") - Recive_table;
127 3 usr.Seep_model = 0;
128 3 for(i = target1 + 1; i < target2; i++){
129 4 usr.Seep_model = usr.Seep_model * 10 + (*(Recive_table + i) - 0x30);
130 4 }
131 3 if(usr.Seep_model > 1) usr.Seep_model = 1;
132 3 target1 = strstr(Recive_table, ",") - Recive_table;
133 3 target2 = strstr(Recive_table, ")") - Recive_table;
134 3 usr.target_mileage = 0;
135 3 for(i = target1 + 1; i < target2; i++){
136 4 usr.target_mileage = usr.target_mileage * 10 + (*(Recive_table + i) - 0x30);
137 4 }
138 3
139 3 if(usr.Seep_model > 9999) usr.Seep_model = 9999;
140 3 Bluetooth_Set("User SET OK!\r\n");
141 3 saveUserInfo();
142 3 }
143 2 memset(Recive_table, 0, sizeof(Recive_table));
144 2 accept = 0;
145 2 }
146 1 }
147
148 // 读取数据
149 void ReadData(){
150 1 // 里程
151 1 mileage = At24c02Read(1) * 255 + At24c02Read(2);
152 1
153 1 // 用户的模式
154 1 usr.Seep_model = At24c02Read(3);
155 1
156 1 model = At24c02Read(4);
157 1 // 用户的目标里程
158 1 usr.target_mileage = At24c02Read(5) * 255 + At24c02Read(6);
159 1 }
160
161 // 写入数据
162 void WriteData(){
163 1 int target = mileage >> 8;
164 1 At24c02Write(1, target);
165 1 us_delay(200);
166 1 target = mileage & 0x00ff;
167 1 At24c02Write(2, target);
168 1 us_delay(200);
169 1 }
170
171 // main 函数
172 void main(void)
173 {
174 1 LcdInit();
175 1 IRIN_Init();
176 1 Uart_Init();
177 1 ReadData();
178 1 while(1)
179 1 {
C51 COMPILER V9.56.0.0 MAIN 04/09/2022 18:14:52 PAGE 4
180 1 target = mileage & 0x00ff;
181 1 At24c02Write(2, target);
182 1 delayms(2);
183 1 }
184
185 void main(void)
186 {
187 1 InitLcd1602();
188 1 IRIN_Init();
189 1 Uart_Init();
190 1 ReadData();
191 1 while(1)
192 1 {
193 2 run();
194 2 display();
195 2 Key_scan();
*** WARNING C206 IN LINE 195 OF main.c: 'Key_scan': missing function-prototype
196 2 Bluetooth_Accept();
197 2 WriteData();
198 2 }
199 1 }
200
201 void Uart_Interrupt() interrupt 4
202 {
203 1 static uchar i=0;
204 1 if( accept) return;
205 1 if(RI==1) {
206 2 RI=0;
207 2 Receive=SBUF; //MCU接收wifi模块反馈回来的数据
-
208 2 Recive_table[i]=Receive;
209 2 if((Recive_table[i]=='\r')){
210 3 i=0;
211 3 accept = 1;
212 3 }
213 2 else i++; //遇到换行 重
-新装值
214 2 }
215 1 else TI=0;
216 1 }
180 2 run();
181 2 display();
182 2 Key_scan();
*** WARNING C206 IN LINE 182 OF main.c: 'Key_scan': missing function-prototype
183 2 Bluetooth_Accept();
184 2 WriteData();
185 2 }
186 1 }
187
188 // 串口中断
189 void Uart_Interrupt() interrupt 4
190 {
191 1 static uchar i=0;
192 1 if(accept) return;
193 1 if(RI==1) {
194 2 RI=0;
195 2 Receive=SBUF;
196 2 Recive_table[i]=Receive;
197 2 if((Recive_table[i]=='\r')){
198 3 i=0;
199 3 accept = 1;
200 3 }
201 2 else i++;
202 2 }
203 1 else TI=0;
204 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1000 ----
CONSTANT SIZE = 57 ----
CODE SIZE = 1004 ----
CONSTANT SIZE = 117 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 53 6
DATA SIZE = 52 6
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.

BIN
main.OBJ

Binary file not shown.

118
main.c

@ -17,26 +17,19 @@ typedef unsigned int uint16; @@ -17,26 +17,19 @@ typedef unsigned int uint16;
extern uint mileage;
extern uint speed;
uint model = 0;
uint Seep_model = 0;
extern unsigned char pwm_value;
uchar play = 0;
struct UserInfo{
int height;
int weight;
int target_mileage;
int target_speed;
};
uchar set = 0;
// model
uchar model = 0;
struct UserInfo usr;
/*****************相关变量**************/
uchar Receive;
uchar Recive_table[40]; //用于接收wifi模块反馈到MCU上的数据
uchar Recive_table[40];
bit accept = 0;
@ -90,52 +83,61 @@ void Bluetooth_Set(uchar *puf) @@ -90,52 +83,61 @@ void Bluetooth_Set(uchar *puf)
}
}
// 保存用户的数据
void saveUserInfo(){
int target = 0;
target = usr.height >> 8;
At24c02Write(3, target);
At24c02Write(3, usr.Seep_model);
delayms(2);
target = (usr.height) & 0x00ff;
At24c02Write(4, target);
delayms(2);
target = (usr.weight) >> 8;
target = (usr.target_mileage) >> 8;
At24c02Write(5, target);
delayms(2);
target = (usr.weight) & 0x00ff;
target = (usr.target_mileage) & 0x00ff;
At24c02Write(6, target);
delayms(2);
}
void Bluetooth_Accept(){
int target1 = 0, target2 = 0, i = 0;
if(accept){
if(strstr(Recive_table, "inquire") != NULL){
memset(Recive_table, 0, sizeof(Recive_table));
sprintf(Recive_table, "speed:%d km/h mileage:%d m\r\n",speed, mileage);
sprintf(Recive_table, "speed:%d m/min mileage:%d m\r\n",speed, mileage);
Bluetooth_Set(Recive_table);
}else if(strstr(Recive_table, "set:") != NULL){
}else if(strstr(Recive_table, "model") != NULL){
if(model == 0) model = 1;
else model = 0;
if(model == 0) Seep_model = 0;
memset(Recive_table, 0, sizeof(Recive_table));
sprintf(Recive_table, "Model SET OK\r\n");
Bluetooth_Set(Recive_table);
At24c02Write(4, model);
}else if(strstr(Recive_table, "clear") != NULL){
// 清空里程
mileage = 0;
Bluetooth_Set("reset mileage OK!\r\n");
}
else if(strstr(Recive_table, "speed") != NULL){
Seep_model++;
if(Seep_model >= 4) Seep_model = 0;
usr.Seep_model = Seep_model;
}
else if(strstr(Recive_table, "set:") != NULL){
target1 = strstr(Recive_table, "(") - Recive_table;
target2 = strstr(Recive_table, ",") - Recive_table;
usr.height = 0;
usr.Seep_model = 0;
for(i = target1 + 1; i < target2; i++){
usr.height = usr.height * 10 + (*(Recive_table + i) - 0x30);
usr.Seep_model = usr.Seep_model * 10 + (*(Recive_table + i) - 0x30);
}
Bluetooth_Set(Recive_table);
if(usr.Seep_model > 1) usr.Seep_model = 1;
target1 = strstr(Recive_table, ",") - Recive_table;
target2 = strstr(Recive_table, ")") - Recive_table;
usr.weight = 0;
usr.target_mileage = 0;
for(i = target1 + 1; i < target2; i++){
usr.weight = usr.weight * 10 + (*(Recive_table + i) - 0x30);
usr.target_mileage = usr.target_mileage * 10 + (*(Recive_table + i) - 0x30);
}
memset(Recive_table, 0, sizeof(Recive_table));
sprintf(Recive_table, "SET OK\r\n",usr.height, usr.weight);
Bluetooth_Set(Recive_table);
// 计算
usr.target_mileage = (usr.weight / usr.height) * (usr.weight / usr.height) / 22 * 3000;
usr.target_speed = 10 - (usr.weight / usr.height) * (usr.weight / usr.height) / 22 ;
if(usr.Seep_model > 9999) usr.Seep_model = 9999;
Bluetooth_Set("User SET OK!\r\n");
saveUserInfo();
}
memset(Recive_table, 0, sizeof(Recive_table));
@ -143,48 +145,33 @@ void Bluetooth_Accept(){ @@ -143,48 +145,33 @@ void Bluetooth_Accept(){
}
}
// 读取数据
void ReadData(){
// 里程
mileage = At24c02Read(1) * 255 + At24c02Read(2);
set = At24c02Read(7);
if(set){
usr.height = 0;
usr.weight = 0;
At24c02Write(1, 0);
delayms(2);
At24c02Write(2, 0);
delayms(2);
At24c02Write(3, 0);
delayms(2);
At24c02Write(4, 0);
delayms(2);
At24c02Write(5, 0);
delayms(2);
At24c02Write(6, 0);
}else{
usr.height = At24c02Read(3) * 255 + At24c02Read(4);
usr.weight = At24c02Read(5) * 255 + At24c02Read(6);
}
}
// 用户的模式
usr.Seep_model = At24c02Read(3);
model = At24c02Read(4);
// 用户的目标里程
usr.target_mileage = At24c02Read(5) * 255 + At24c02Read(6);
}
// 写入数据
void WriteData(){
int target = mileage >> 8;
At24c02Write(1, target);
delayms(2);
us_delay(200);
target = mileage & 0x00ff;
At24c02Write(2, target);
delayms(2);
us_delay(200);
}
// main 函数
void main(void)
{
InitLcd1602();
LcdInit();
IRIN_Init();
Uart_Init();
ReadData();
@ -198,19 +185,20 @@ void main(void) @@ -198,19 +185,20 @@ void main(void)
}
}
// 串口中断
void Uart_Interrupt() interrupt 4
{
static uchar i=0;
if( accept) return;
if(accept) return;
if(RI==1) {
RI=0;
Receive=SBUF; //MCU接收wifi模块反馈回来的数据
Receive=SBUF;
Recive_table[i]=Receive;
if((Recive_table[i]=='\r')){
i=0;
accept = 1;
}
else i++; //遇到换行 重新装值
else i++;
}
else TI=0;
}

BIN
pro

Binary file not shown.

1319
pro.M51

File diff suppressed because it is too large Load Diff

4
pro.build_log.htm

@ -24,9 +24,9 @@ Project File Date: 05/31/2019 @@ -24,9 +24,9 @@ Project File Date: 05/31/2019
<h2>Output:</h2>
Build target 'Target 1'
compiling main.c...
main.c(195): warning C206: 'Key_scan': missing function-prototype
main.c(182): warning C206: 'Key_scan': missing function-prototype
linking...
Program Size: data=111.3 xdata=0 code=5315
Program Size: data=102.3 xdata=0 code=3859
creating hex file from "pro"...
"pro" - 0 Error(s), 1 Warning(s).
Build Time Elapsed: 00:00:01

650
pro.hex

@ -1,378 +1,280 @@ @@ -1,378 +1,280 @@
:10119800696E71756972650073706565643A256476
:1011A800206B6D2F68206D696C656167653A2564F1
:1011B800206D0D0A007365743A0028002C00290080
:0911C800534554204F4B0D0A0061
:0C12090002230000014E00C10901220078
:04135E007F027E008C
:101362007C64EF4E60131CEC60087D0A1DED60F694
:0913720080FAEF1F70EC1E80E907
:01137B00224F
:10140700758921759850758DFD858D8BE4F587D28B
:06141700AFD2ACD28E2220
:100AE800696E71756972650073706565643A25642D
:100AF800206D2F6D696E206D696C656167653A259B
:100B080064206D0D0A006D6F64656C004D6F64653F
:100B18006C20534554204F4B0D0A00636C6561727D
:100B2800007265736574206D696C65616765204F37
:100B38004B210D0A007370656564007365743A0093
:100B480028002C0029005573657220534554204F06
:050B58004B210D0A0015
:0F0CC80002230000012600012500C109012200BE
:100E37007C64EF4E60131CEC60087D0A1DED60F6C4
:090E470080FAEF1F70EC1E80E937
:010E5000227F
:100E9B00758921759850758DFD858D8BE4F587D2FD
:060EAB00AFD2ACD28E2292
:07000300AE071FEE70FA22A8
:0E149800C2ACC2998F993099FDC299D2AC2294
:06137C007B007A007926D7
:10138200120525FF60111214987F051200037401E3
:0813920029F9E43AFA80E9228E
:1010DB00E54FFF3395E0FEAD077F031213EE1213BE
:1010EB005E7E00AF50AD077F041213EE12135EE568
:1010FB0051FF3395E0FEAD077F051213EE12135E21
:10110B007E00AF52AD077F061213EE7F027E000208
:02111B0013625D
:100AF900E4F557F558F559F55AF55BF55C20090306
:100B0900020D0D7560FF756111756298FB7A0079A8
:100B190026121059E94A4B60337E007F287D007BFD
:100B2900007A00792612065E7560FF75611175629B
:100B3900A0850A63850B648510658511667B007A3B
:100B49000079261206E612137C020CFC7560FF750B
:100B590061117562BD7B007A007926121059E94A44
:100B69004B7003020CFC7560FF7561117562C27BE5
:100B7900007A007926121059AE02C3E99426F55875
:100B8900EE9400F5577560FF7561117562C47B00BD
:100B99007A007926121059AE02C3E99426F55AEE65
:100BA9009400F559E4F54FF550E5582401F55CE456
:100BB9003557F55BC3E55C955AE5596480F8E55B03
:100BC900648098502A7426255CF8E624D0FBE43426
:100BD900FFFAAE4FAF507C007D0A12057DEF2BF571
:100BE90050EE3AF54F055CE55C7002055B80C51275
:100BF900137C7560FF7561117562C47A00792612DC
:100C09001059AE02C3E99426F558EE9400F55775CC
:100C190060FF7561117562C67B007A007926121032
:100C290059AE02C3E99426F55AEE9400F559E4F554
:100C390051F552E5582401F55CE43557F55BC3E5F8
:100C49005C955AE5596480F8E55B648098502A748C
:100C590026255CF8E624D0FBE434FFFAAE51AF5206
:100C69007C007D0A12057DEF2BF552EE3AF5510510
:100C79005CE55C7002055B80C57E007F287D007B9A
:100C8900007A00792612065E7560FF75611175623A
:100C9900C8854F638550648551658552667B007AA6
:100CA9000079261206E612137CAC4FAD50AE51AF57
:100CB900521205E4AC06AD0712057D7C007D1612C3
:100CC90005E47C0B7DB812057D8E538F54AC4FAD76
:100CD90050AE51AF521205E4AC06AD0712057D7C4A
:100CE900007D161205E4C3740A9FF556E49EF55576
:100CF9001210DB7E007F287D007B007A00792612A6
:040D0900065EC209B7
:010D0D0022C3
:100F17007F011212DCEF75F0FFA4FFAEF0C006C030
:100F2700077F021212DCEFFDD0E02DF511D0E0347F
:100F370000F5107F071212DC8F4EE54E6041E4F595
:100F47004FF550F551F552FD7F011213EE12135E66
:100F5700E4FD7F021213EE12135EE4FD7F0312130A
:100F6700EE12135EE4FD7F041213EE12135EE4FD2E
:100F77007F051213EE12135EE4FD7F060213EE7F68
:100F8700031212DCEF75F0FFA4FFAEF0C006C00736
:100F97007F041212DCEFFDD0E02DF550D0E03400D5
:100FA700F54F7F051212DCEF75F0FFA4FFAEF0C01E
:100FB70006C0077F061212DCEFFDD0E02DF552D0F8
:060FC700E03400F55122A8
:10133F00E5107E00FD7F011213EE12135E7E00AFEB
:0F134F0011AD077F021213EE7F027E00021362C0
:10139A0012141D121431121407120F1712123812D6
:0D13AA000E1C12115E120AF912133F80EFA3
:030023000211D1F6
:0911D100C0E0C0D075D000C000E0
:1011DA00200925309820C29885992574262522F859
:1011EA00A62574262522F8E6B40D07752200D20931
:0811FA00800605228002C29963
:07120200D000D0D0D0E03293
:1014450075A0FFC287D286D285AFA0C285EF20E7FF
:01145500F6A0
:011456002273
:10146900AE07121445C287C2868EA0D285C28522D4
:10147900AE07121445D287C2868EA0D285C28522B4
:10145700ED7004AC078004EF2440FCEC4480FF02ED
:02146700146906
:1013B700AE07AC0353050153060FED600343064028
:0D13C700430680AF06121469AF04021479CA
:101267008B578A588959121457AB57AA58A959123C
:10127700052560130559E5597002055814F912053B
:0812870025FF12147980E22218
:10141D007F381214697F0C1214697F061214697FCC
:04142D00010214693B
:0B121500011500011400011300C10AC4
:10131F00E4FDFCC3ED9FEC9E5015E4FBFA0BBB0004
:0F132F00010ABA07F8BBD0F50DBD00010C80E430
:01133E00228C
:10123800E52445237004F513801DE5246401452346
:1012480070057513028010E5246402452370057546
:0F1258001305800375130A851314C290D29122D7
:1012FE000515A20AB35017E51595145004D2B48003
:10130E0002C2B4E515C394144006E4F51522C2B426
:01131E0022AC
:0514A6001214ABD2811D
:0814AB007F017E02DEFEDFFA84
:0114B3002216
:0F148900D2801214A6C2801214ABC2810214AB1F
:0A14BF00C2801214A6D2800214AB02
:02111D00AD071C
:10111F00E4FBFAEDC4131313540124FF9280ED2561
:10112F00E0FD1214A6C2811214AB0BBB08E5D280EE
:10113F001214ABD28130800F0AEAD394C840F6C2A2
:0E114F00811214AB7F0022C2811214AB7F010B
:01115D00226F
:1012B600E4FDFCD2801214ABD2811214ABEC25E013
:1012C600FCA280E43342041214ABC2811214AB0DAB
:0512D600BD08E5AF04B6
:0112DB0022F0
:1013EE00AC05A9071214897FA012111DAF011211AD
:0913FE001DAF0412111D0214BF01
:0212DC00AC075D
:1012DE001214897FA012111DAF0412111D12148950
:0F12EE007FA112111D1212B6AD071214BFAF056A
:0112FD0022CE
:1013D400004B4D2F6820006D20202020202020204D
:0A13E400200020004C004D004800DE
:1012200002100000020C0000011200020A0000027D
:071230000E0000020800009F
:0B14B400EF1FAC0670011E4C70F6220A
:10143100758921758CFC758A18D2A9D28CD2AFD24C
:04144100AAD28A227F
:100E1C00E4FDFF1214577BFF7A1379D4E4FDFF1223
:100E2C001267AE0AAF0B7C007D6412058F7C007DCF
:100E3C000A12058FED2430FF121479AE0AAF0B7C29
:100E4C00007D0A12058F7C007D0A12058FED24307F
:100E5C00FF121479AE0AAF0B7C007D0A12058FEDE0
:100E6C002430FF1214797BFF7A1379D5E4FD7F03CC
:100E7C001212677BFF7A1379D4E4FD7F0812126794
:100E8C00AE10AF117C007D6412058F7C007D0A12C0
:100E9C00058FED2430FF121479AE10AF117C007D5C
:100EAC000A12058F7C007D0A12058FED2430FF128B
:100EBC001479AE10AF117C007D0A12058FED243031
:100ECC00FF1214797BFF7A1379DBE4FD7F0B12128E
:100EDC0067E524452370087BFF7A1379E68025E5C6
:100EEC00246401452370087BFF7A1379E88015E5AB
:100EFC0024640245237BFF70067A1379EA80057A15
:0B0F0C001379ECE4FD7F0D1212672248
:10115E0020B5237FE87E031214B420B5160524E5CE
:10116E002470020523C39404E52394004005E4F59E
:10117E0023F52430B5FD20B2107FE87E031214B49F
:0A118E0020B203754E0130B2FD22BD
:03000B00020D0ED5
:100D0E00C0E0C0F0C083C082C0D075D000C000C0AB
:0D0D1E0001C002C003C004C005C006C0072C
:100D2B00758CFC758A180509E50970020508121205
:100D3B00FEC3E50994F4E508648094815003020E28
:100D4B0001C2AA750800750900850C0E850D0F757B
:100D5B000C00750D00D2AAAE0EAF0F7C007D0612F3
:100D6B00057DAC06AD07E41202C9E4FBFAF9783F46
:100D7B0012011EC004C005C006C007AC0AAD0BE4CF
:100D8B001202C9E4FBFAF9783F12011ED003D0021C
:100D9B00D001D00012002D1203028E0A8F0BAC0A69
:100DAB00AD0BE41202C97B9A7A997919783E12013C
:100DBB001E1203028E0A8F0BAC0EAD0FE41202C98A
:100DCB00E4FBFA7920784012011EE4FBFA79A07853
:100DDB0041120227C004C005C006C007AC10AD11FC
:100DEB00E41202C9D003D002D001D00012002D12A0
:060DFB0003028E108F11AF
:100E0100D007D006D005D004D003D002D001D00045
:0B0E1100D0D0D082D083D0F0D0E032EF
:0E0ED400C2ACC2998F993099FDC299D2AC225E
:100E83001207D3FF6011120ED47F05120003740101
:080E930029F9E43AFA80E92292
:100C9100E4FEAD517F03120E6A7F027E00120E3711
:100CA100E552FF3395E0FEAD077F05120E6A7F0224
:100CB1007E00120E377E00AF53AD077F06120E6A1B
:070CC1007F027E00020E37E6
:10038200E4F556F557F558F559F55AF55B2009038A
:1003920002060D755FFF75600A7561E8FB7A0079E8
:1003A20028120A66E94A4B60367E007F287D007B70
:1003B200007A007928120889755FFF75600A7561F5
:1003C200F0850A62850B638510648511657B007A6E
:1003D2000079281200827B007A0079280204627573
:1003E2005FFF75600B75610E7B007A007928120A37
:1003F20066E94A4B6048E52570057525018003E4EE
:10040200F525E5257004F523F5247E007F287D007F
:100412007B007A007928120889755FFF75600B7579
:1004220061147B007A0079281200827B007A0079BD
:1004320028120E83AD257F04120E6A0205FC755F39
:10044200FF75600B7561237B007A007928120A66BA
:10045200E94A4B6011E4F510F5117BFF7A0B79291B
:10046200120E830205FC755FFF75600B75613D7BA3
:10047200007A007928120A66E94A4B601F0524E5D2
:100482002470020523C39404E52394004005E4F597
:1004920023F5248523508524510205FC755FFF75E1
:1004A200600B7561437B007A007928120A66E94A7B
:1004B2004B70030205FC755FFF75600B7561487B2D
:1004C200007A007928120A66AE02C3E99428F55729
:1004D200EE9400F556755FFF75600B75614A7B00FF
:1004E2007A007928120A66AE02C3E99428F559EE19
:1004F2009400F558E4F550F551E5572401F55BE415
:100502003556F55AC3E55B9559E5586480F8E55AC6
:10051200648098502A7428255BF8E624D0FBE434E2
:10052200FFFAAE50AF517C007D0A1207ECEF2BF5BB
:1005320051EE3AF550055BE55B70C9055A80C5D3AB
:10054200E5519401E5506480948040067550007531
:100552005101755FFF75600B75614A7B007A007906
:1005620028120A66AE02C3E99428F557EE9400F504
:1005720056755FFF75600B75614C7B007A007928B8
:10058200120A66AE02C3E99428F559EE9400F558B2
:10059200E4F552F553E5572401F55BE43556F55A77
:1005A200C3E55B9559E5586480F8E55A6480985034
:1005B2002A7428255BF8E624D0FBE434FFFAAE5215
:1005C200AF537C007D0A1207ECEF2BF553EE3AF5A0
:1005D20052055BE55B70C9055A80C5D3E551940F9E
:1005E200E550648094A7400675502775510F7BFF34
:1005F2007A0B794E120E83120C917E007F287D00B9
:0B0602007B007A007928120889C209E9
:01060D0022CA
:100BC0007F01120D98EF75F0FFA4FFAEF0C006C0D4
:100BD000077F02120D98EFFDD0E02DF511D0E03423
:100BE00000F5107F03120D987550008F517F04128D
:100BF0000D988F257F05120D98EF75F0FFA4FFAEBD
:100C0000F0C006C0077F06120D98EFFDD0E02DF56D
:080C100053D0E03400F552223C
:100DFB00E5107E00FD7F01120E6A7FC81200037E94
:0F0E0B0000AF11AD077F02120E6A7FC80200030D
:100E1A00120E51120EB1120E9B120BC0120B5D1262
:0D0E2A00060E120D24120382120DFB80EF44
:03002300020C5973
:090C5900C0E0C0D075D000C0005D
:100C6200200925309820C29885992774282522F8D2
:100C7200A62774282522F8E6B40D07752200D209AA
:080C8200800605228002C299E0
:070C8A00D000D0D0D0E03211
:100CFA00C2958FA07F017E00120D0BD2947F057ED4
:010D0A0000E8
:100D0B00D3EF9400EE9400400F7DC77C01DCFEDD39
:080D1B00FAEF1F70EB1E80E8E7
:010D230022AD
:0A0EFB00C294C296120CFAC29422AF
:0A0F0500C294D296120CFAC2942294
:100E51007F38120EFB7F0C120EFB7F06120EFB7FFA
:090E610001120EFB7F80020EFB62
:0B0CD700011500011400011300C10A08
:100DDB00E4FDFCC3ED9FEC9E5015E4FBFA0BBB004E
:0F0DEB00010ABA07F8BBD0F50DBD00010C80E47A
:010DFA0022D6
:100B5D00E525602B855023855124C3E5539511F56B
:100B6D0055E5529510F554C3648094805005E4F515
:100B7D0054F555E5554554700BF523F5248005E4E2
:100B8D00F554F555E52445237004F513801DE52432
:100B9D006401452370057513028010E52464024538
:100BAD002370057513058003751307851314C29201
:030BBD00D29322AE
:100DBA000515A20AB35017E51595145004D2978069
:100DCA0002C297E515C394144006E4F51522C297AA
:010DDA0022F6
:050EE200120EE7D291A1
:080EE7007F017E02DEFEDFFA4E
:010EEF0022E0
:0F0EC500D290120EE2C290120EE7C291020EE717
:0A0F0F00C290120EE2D290020EE72B
:020C1800AD0726
:100C1A00E4FBFAEDC4131313540124FF9290ED255B
:100C2A00E0FD120EE2C291120EE70BBB08E5D2906C
:100C3A00120EE7D29130900F0AEAD394C840F6C256
:0E0C4A0091120EE77F0022C291120EE77F0189
:010C58002279
:100D7200E4FDFCD290120EE7D291120EE7EC25E0D0
:100D8200FCA290E4334204120EE7C291120EE70D68
:050D9200BD08E5AF04FF
:010D97002239
:100E6A00AC05A907120EC57FA0120C18AF01120C0F
:090E7A0018AF04120C18020F0F4E
:020D9800AC07A6
:100D9A00120EC57FA0120C18AF04120C18120EC541
:0F0DAA007FA1120C18120D72AD07120F0FAF05BB
:010DB9002217
:100CE20002100000020C0000011200020A000002C1
:070CF2000E000002080000E3
:0B0EF000EF1FAC0670011E4C70F622D4
:100EB100758921758CFC758A18D2A9D28CD2AFD2D2
:040EC100AAD28A2205
:10060E007F82120EFBAE0AAF0B7C007D641207FEDA
:10061E007C007D0A1207FEED2430FF120F05AE0A94
:10062E00AF0B7C007D0A1207FE7C007D0A1207FECE
:10063E00ED2430FF120F05AE0AAF0B7C007D0A12BF
:10064E0007FEED2430FF120F057F88120EFBAE1051
:10065E00AF117C037DE81207FE7C007D0A1207FEB7
:10066E00ED2430FF120F05AE10AF117C007D641229
:10067E0007FE7C007D0A1207FEED2430FF120F05E7
:10068E00AE10AF117C007D0A1207FE7C007D0A12AF
:10069E0007FEED2430FF120F05AE10AF117C007D6A
:1006AE000A1207FEED2430FF120F057F6D120F05A3
:1006BE007F8E120EFBE524452370047F4E8022E5CB
:1006CE00246401452370047F4C8016E524640245A2
:1006DE002370047F4D800AE5246403452370057F53
:1006EE0048120F057FC0120EFBAE52AF537C037D36
:1006FE00E81208537C007D0A120853ED2430FF12D5
:10070E000F05AE52AF537C007D641208537C007D02
:10071E000A120853ED2430FF120F05AE52AF537C70
:10072E00007D0A1208537C007D0A120853ED243016
:10073E00FF120F05AE52AF537C007D0A120853ED27
:10074E002430FF120F057F6D120F057FC8120EFBAE
:10075E00AE54AF557C037DE81208537C007D0A121F
:10076E000853ED2430FF120F05AE54AF557C007DBB
:10077E00641208537C007D0A120853ED2430FF12D8
:10078E000F05AE54AF557C007D0A1208537C007DD8
:10079E000A120853ED2430FF120F05AE54AF557CEC
:1007AE00007D0A120853ED2430FF120F057F6D12E3
:1007BE000F057FCE120EFBE52570047F4480027F6D
:0507CE0053120F05228B
:100D240020B5237FE87E03120EF020B5160524E5D6
:100D34002470020523C39404E52394004005E4F5DC
:070D440023F52430B5FD2268
:03000B0002092ABD
:10092A00C0E0C0F0C083C082C0D075D000C000C093
:0D093A0001C002C003C004C005C006C00714
:10094700758CFC758A180509E50970020508120DF2
:10095700BAC3E50994F4E50864809481405AC2AAB1
:10096700750800750900AE0CAF0D7C007D031207FA
:10097700EC7D141207FE8E0E8F0F7C007D0C120784
:10098700EC8E0A8F0BAE0CAF0D7D141207FE7C00A8
:100997007D031207ECEF2511F511EE3510F510D395
:1009A700E511940FE5109427400675102775110F70
:0809B700750C00750D00D2AAB9
:1009BF00D007D006D005D004D003D002D001D0008C
:0B09CF00D0D0D082D083D0F0D0E03236
:03001300020016D2
:0D001600C0E0050DE50D7002050CD0E032D4
:1000260002036EE86480F8E933E83360110460F097
:10003600ED33EC337009E8FCE9FDEAFEEBFF220440
:1000460060DED3EB9FEA9EE99DE8C2E78CF0C2F73B
:1000560095F0400CE8CCF8E9CDF9EACEFAEBCFFB07
:1000660012033985D0F05804700320D5B3E8047024
:10007600075002B2D502037892D5EC0460F7E4CCBF
:10008600C0E0C398F8603B94186008400DD0E0FBD0
:10009600020350E4FBFAC9FC8028E830E406E4C910
:1000A600FBE4CAFCE830E305E4C9CACBFCE8540724
:1000B6006010F8C3E913F9EA13FAEB13FBEC13FC2F
:1000C600D8F130F52FC3E49CFCEF9BFFEE9AFEEDD2
:1000D60099FDD0E0FBEF4E4D4C701222DB0302037C
:1000E60075EC2CFCEF33FFEE33FEED33FDED30E720
:1000F600EB020350EF2BFFEE3AFEED39FDD0E0FBAD
:1001060050130BBB0003020378ED13FDEE13FEEF55
:0801160013FFEC13FC0203507F
:10011E00EC4D6011E8497017ED33EC3304600DE4DB
:10012E00FCFFFEFD22E933E8330470F802036E1281
:10013E00033958046009E4CC248150062850090282
:10014E000378284003020375C0E0EB4A7044B9807F
:10015E0006D0E0FB020364EF4E701CBD8008EBFF7F
:10016E00EAFEE9FD80EBE98DF0A4FEE5F002020760
:10017E00E9CDF9EAFEEBFFEF89F0A4FCE5F0CE89BC
:10018E00F0A42EFFE435F0CD89F0A42DFEE435F079
:10019E008067EF4E7005BD80D780C3EF8BF0A4ACA7
:1001AE00F0EE8BF0A42CFCE435F0F8EF8AF0A42CE2
:1001BE00E5F038FCE433CB8DF0A42CFCE5F03BF8F5
:1001CE00EE8AF0A42CFCE5F038F8E433CF89F0A4E5
:1001DE002CFCE5F038CF3400CE89F0A42FFFE5F0EB
:1001EE003EFEE433C98DF0A42EFEE5F039CD8AF043
:1001FE00A42FFFE5F03EFEE43DFD33D0E0FB5007BB
:10020E000BBB000F020378EC2CFCEF33FFEE33FE3A
:06021E00ED33FD02035068
:10022400020378EC5D046005E85904700302036E70
:10023400120339580460F6EC4860F2EC7004FDFED9
:10024400FF22C860DB2481C85009C39860025006AD
:100254000203759850CAF582E9294B4A7005AB82AE
:1002640002036475F0007C1A7880C3EF9BEE9AED6C
:1002740099400DC3EF9BFFEE9AFEED99FDE842F025
:10028400DC23ACF0D0E0FFD0E0FED0E0FDAB822078
:10029400E7101BEB60BAEC2CFCEF33FFEE33FEED02
:1002A40033FD020350E803F830E705C0F075F000B1
:1002B400EF2FFFEE33FEED33FD40B830E7C280AAE6
:1002C40075F020800E75F010800575F0087D007EB5
:1002D400007F003392D530D50312061AEC33401058
:1002E400EF33FFEE33FEED33FDEC33FCD5F0ED22BE
:0E02F400E5F0247EA2D513CC92E7CDCEFF22FA
:10030200EDD2E7CD33EC3392D524814006E4FFFEF3
:10031200FDFC22FCE4CFCECDCC24E0501174FF8052
:10032200EDC3CC13CCCD13CDCE13CECF13CF0470EF
:07033200F030D5DE02061ACF
:10068A00E5742460F8E6057422785D300702786024
:10069A00E475F0011206280205252000EB7F2ED210
:1006AA00008018EF540F2490D43440D4FF30040B48
:1006BA00EF24BFB41A0050032461FFE575600215E8
:1006CA00750578E5787002057730070D785DE47571
:1006DA00F001120628EF02056B02128F7403D2078B
:1006EA008003E4C207F5748B5D8A5E895FE4F57561
:1006FA00F577F578E57560077F201206C580F575F0
:10070A0076FFC201C200C202C203C205C206C20803
:10071A00120693FF700D3007057F001206D6AF78D8
:10072A00AE7722B4255FC2D5C204120693FF24D045
:10073A00B40A00501A75F00A787530D50508B6FF64
:10074A000106C6A426F620D5047002D20380D92455
:10075A00CFB41A00EF5004C2E5D2040209C3D20191
:10076A0080C6D20080C0D20280BCD2D580BAD2055F
:10077A0080B47F201206C52002077401B5750040B7
:10078A00F112068AFF1206C50206FED208D20680B8
:10079A009512068AFB12068AFA12068AF94A4B70E1
:1007AA000679BA7A0A7BFF20022EE575602A7E0056
:1007BA008E8275830012053E60060EEE657670F035
:1007CA00C2D5EBC0E0EAC0E0E9C0E0EE120A23D0ED
:1007DA00E0F9D0E0FAD0E0FB120525FF60AAEBC0F1
:1007EA00E0EAC0E0E9C0E01206C5D0E02401F9D091
:1007FA00E03400FAD0E0FBE5760460DCD576D980F7
:10080A0087D20280A2120A0660F7E5767001041206
:10081A000383A976600DE576600914F576120AADB0
:10082A00EF60F3EA30E702F404C3995077EAF4255B
:10083A00760430E701E404F576800D120A0660C1F9
:10084A00EA05762576120383EA7873F630E701E43F
:10085A00257604D5760420050114120A23E4C0E0A3
:10086A00120AAD7873E6601320E70714F61206AD94
:10087A00802204F6D0E014C0E07F001206ADE576CF
:10088A0060071206A41576800B3005031206A4D061
:10089A00E00206FED0E00480C5120A0660A0E576F2
:1008AA00041203837873EAF6E576200502600104F0
:0508BA002404120A23D2
:1008BF0074FF04C0E0120AAD1206ADE57620050202
:1008CF0060031206A4D0E0B576E87F451206B7782C
:1008DF0073E67F2B30E7047F2DF404C0E01206C5CA
:1008EF00D0E075F00A84C0F01206AED0E01206AE6A
:1008FF000206FE791080027908C206C2088008D26B
:10090F00D5790A8004790AC2D5E576047002F576A6
:10091F00E4FAFDFEFF12068AFC7B08200113120683
:10092F008AFD7B1030000A12068AFE12068AFF7BB0
:10093F0020EC3382D592D55013C3E43000069FFFCD
:10094F00E49EFEE42001039DFDE49CFCE4CBF8C291
:10095F0001EC700CCFCECDCCE824F8F870F38017F3
:10096F00C3EF33FFEE33FEED33FDEC33FCEB33FB24
:10097F00994002FB0FD8E9EB300105F8D0E0C448ED
:10098F00B201C0E00AEC4D4E4F78207B0070C2EAF6
:10099F00B5760040BCC0E0120A25D0F0D0E02001AF
:1009AF0004C4C0E0C4B201C0F01206AED0F0D5F05E
:1009BF00EB0206FE120638079B53090258076C4CD0
:1009CF0007684209064F090E44090E49078143097A
:1009DF00145508454608A345080F470ADA50077013
:1009EF002D07742E07972B0778230795200AC32A04
:1009FF000730480000078FE576B4FF0375760612BF
:100A0F00068AFC12068AFD12068AFE12068AFF78F3
:100A1F006C0203B2790AA2D5200314300509B9106C
:100A2F00020404B9080104A2D520060250010420D3
:100A3F0002689202B575005034C0E07F2030031970
:100A4F007F30A20272067205500F120A7CC202C2D8
:100A5F0006C205C2087F30800F300503E9C0E012DF
:100A6F0006C5300503D0E0F9D0E0B575CC300517D9
:100A7F007F30B9100C1206C57F583004077F78807D
:100A8F0003B908031206C53002057F2D0206C57F84
:100A9F00202008F87F2B2006F322920280CF7F00C0
:100AAF00B407005005246CF8E6FF22286E756C6CB5
:100ABF002900D20112068A3001F8C201787530D5AB
:100ACF000108F60207302D5043495812068A2403B5
:100ADF00B405004001E4900AD5931206B6743A1299
:0A0AEF0006B6D20375750402090271
:10033900E9D2E7C933E833F892D5EDD2E7CD33EC0A
:0703490033FC5002B2D52283
:10035000EC30E7100FBF000C0EBE00080DBD00040E
:100360000BEB6014A2D5EB13FCED92E7FD2274FFBA
:10037000FCFDFEFF22E480F8A2D574FF13FC7D8013
:03038000E480EF27
:10038300F920E72824F950037907E4F42402FB1841
:10039300DBFDE624FB5014E9600DE4F618E604F6F1
:0F03A300B40A08E4F6D9F57401F60A22C2D5228D
:1003B200ED33EC3392D5FA602AB4FF33EDC2E77B1A
:1003C200FF60067A0379D7E4227A0379E020D50424
:1003D2007A0379DB224E614E002B494E46002D49AD
:1003E2004E4600E47A08F608DAFC7B00740722E83D
:1003F200C0E0ECC0E0EDC0E0EEC0E0EFC0E0EA75C6
:10040200F010A4CAABF075F04DA42BFBE435F0FC60
:10041200EA2410FAEB34C5FBEC34D9FCEDC2E7FF59
:1004220075F056A4F42411C5F0F434C58FF0A42A53
:10043200E5F03BE43CF620E7141204E5D0E0FFD0FF
:10044200E0FED0E0FDD0E0FC1202278014F404129A
:1004520004E5D0E0FFD0E0FED0E0FDD0E0FC1201E8
:100462001ED0E0F8E6FAEDD2E7CD33EC332482FB7E
:10047200E4C3CF33CFCE33CECD33CD33DBF37B07E3
:1004820075F00A846004F6081B0AE5F0F6088FF09E
:10049200740AA4FFACF08EF0740AA42CFEACF050E7
:1004A200010C8DF0740AA42CFDE435F0F608DBDEB5
:0304B200740722AA
:1004B5003F8000004120000042C80000447A00004F
:1004C500461C400047C35000497424004B189680D1
:1004D5004CBEBC205A0E1BCA6753C21C749DC5AEC8
:1004E500FB60065407601C2323120513EB54386088
:1004F500091204FF12050E12011EECF8EDF9EEFAD1
:10050500EFCB22EB12050E80F1543803241C900426
:10051500B5FE93FC0EEE93FD0EEE930ECE93FF22E9
:03000000020FCD1F
:0C0FCD00787FE4F6D8FD758178021014DE
:10052500BB010689828A83E0225002E722BBFE02D4
:09053500E32289828A83E4932207
:10053E00BB010CE58229F582E5833AF583E0225072
:10054E0006E92582F8E622BBFE06E92582F8E222BC
:0D055E00E58229F582E5833AF583E49322D6
:10056B00BB010689828A83F0225002F722BBFE016F
:02057B00F32269
:10057D00EF8DF0A4A8F0CF8CF0A428CE8DF0A42E92
:02058D00FE224C
:10058F00BC000BBE0029EF8DF084FFADF022E4CC50
:10059F00F875F008EF2FFFEE33FEEC33FCEE9DEC19
:1005AF00984005FCEE9DFE0FD5F0E9E4CEFD22ED5F
:1005BF00F8F5F0EE8420D21CFEADF075F008EF2FA9
:1005CF00FFED33FD4007985006D5F0F222C398FD9A
:0505DF000FD5F0EA2237
:1005E400C2D5EC30E709B2D5E4C39DFDE49CFCEE32
:1005F40030E715B2D5E4C39FFFE49EFE12058FC316
:10060400E49DFDE49CFC800312058F30D507C3E410
:060614009FFFE49EFE22A0
:0E061A00C3E49FFFE49EFEE49DFDE49CFC22F1
:10062800FAE6FB0808E6F925F0F618E6CA3AF622D3
:10063800D083D082F8E4937012740193700DA3A351
:1006480093F8740193F5828883E473740293686065
:06065800EFA3A3A380DF65
:10128F00EFB40A07740D12129A740A309811A899C4
:10129F00B8130CC2983098FDA899C298B811F630BF
:0712AF0099FDC299F5992297
:101059008B5D8A5E895FAB60AA61A9621205256012
:1010690063AB5DAA5EA95F120525605F8560638534
:1010790061648562658B668A678968AB63AA64A9BE
:1010890065120525FF6023AB66AA67A968120525C5
:101099006F7017042565F565E43564F564740125F9
:1010A90068F568E43567F56780D1AB63AA64A9651B
:1010B9001205257002800D7401255FF55FE4355E28
:1010C900F55E809DAB5DAA5EA95F227B007A0079FF
:0210D9000022F3
:10065E00EF4E6012EF60010EEDBB010B89828A83B3
:10066E00F0A3DFFCDEFA2289F05007F709DFFCA9C0
:0C067E00F022BBFEFCF309DFFCA9F02217
:100FD90002139AE493A3F8E493A34003F68001F281
:100FE90008DFF48029E493A3F85407240CC8C33319
:100FF900C4540F4420C8834004F456800146F6DFE8
:10100900E4800B0102040810204080901209E47E5C
:10101900019360BCA3FF543F30E509541FFEE493DC
:10102900A360010ECF54C025E060A840B8E493A3A3
:10103900FAE493A3F8E493A3C8C582C8CAC583CACE
:10104900F0A3C8C582C8CAC583CADFE9DEE780BE86
:0112370000B6
:030000000209DA18
:0C09DA00787FE4F6D8FD75816F020A21D9
:1007D300BB010689828A83E0225002E722BBFE0224
:0907E300E32289828A83E4932257
:1007EC00EF8DF0A4A8F0CF8CF0A428CE8DF0A42E21
:0207FC00FE22DB
:1007FE00BC000BBE0029EF8DF084FFADF022E4CCDF
:10080E00F875F008EF2FFFEE33FEEC33FCEE9DECA7
:10081E00984005FCEE9DFE0FD5F0E9E4CEFD22EDED
:10082E00F8F5F0EE8420D21CFEADF075F008EF2F37
:10083E00FFED33FD4007985006D5F0F222C398FD28
:05084E000FD5F0EA22C5
:10085300C2D5EC30E709B2D5E4C39DFDE49CFCEEC0
:1008630030E715B2D5E4C39FFFE49EFE1207FEC333
:10087300E49DFDE49CFC80031207FE30D507C3E42E
:060883009FFFE49EFE222F
:10002600E56B245FF8E6056B22785C300702785FA3
:10003600E475F0011208F40207D32000EB7F2ED2FC
:10004600008018EF540F2490D43440D4FF30040BB2
:10005600EF24BFB41A0050032461FFE56C6002155B
:100066006C056FE56F7002056E30070D785CE47500
:10007600F0011208F4EF0208E2020D4B7403D207F6
:100086008003E4C207F56B8B5C8A5D895EE4F56CE0
:10009600F56EF56FE56C60077F2012006180F575DF
:1000A6006DFFC201C200C202C203C205C206C20877
:1000B60012002FFF700D3007057F00120072AF6F20
:1000C600AE6E22B4255FC2D5C20412002FFF24D023
:1000D600B40A00501A75F00A786C30D50508B6FFD8
:1000E6000106C6A426F620D5047002D20380D924C0
:1000F600CFB41A00EF5004C2E5D204020272D20154
:1001060080C6D20080C0D20280BCD2D580BAD205C9
:1001160080B47F201200612002077401B56C004094
:10012600F1120026FF12006102009AD208D2068060
:1001360095120026FB120026FA120026F94A4B7089
:100146000679437A037BFF20022EE56C602A7E0047
:100156008E827583001208B560060EEE656D70F02E
:10016600C2D5EBC0E0EAC0E0E9C0E0EE1202B9D0C9
:10017600E0F9D0E0FAD0E0FB1207D3FF60AAEBC0AB
:10018600E0EAC0E0E9C0E0120061D0E02401F9D065
:10019600E03400FAD0E0FBE56D0460DCD56DD98073
:1001A600877BFF7A0279B5D202809C79108002792A
:1001B60008C206C2088008D2D5790A8004790AC224
:1001C600D5E56D047002F56DE4FAFDFEFF1200261A
:1001D600FC7B08200113120026FD7B1030000A125A
:1001E6000026FE120026FF7B20EC3382D592D550E6
:1001F60013C3E43000069FFFE49EFEE42001039D46
:10020600FDE49CFCE4CBF8C201EC700CCFCECDCC67
:10021600E824F8F870F38017C3EF33FFEE33FEEDF2
:1002260033FDEC33FCEB33FB994002FB0FD8E9EBD3
:10023600300105F8D0E0C448B201C0E00AEC4D4EEA
:100246004F78207B0070C2EAB56D0040BCC0E0125A
:1002560002BBD0F0D0E0200104C4C0E0C4B201C0AB
:10026600F012004AD0F0D5F0EB02009A1209040110
:10027600375301B15801084C01044201B54F01BD85
:0F0286004401BD49011D4301C35501A74601A70E
:100295004501A747036350010C2D01102E01332B97
:1002A500011423013120034C2A00CC480000012B06
:1002B5003F3F3F00790AA2D5200314300509B91044
:1002C500020404B9080104A2D52006025001042045
:1002D50002689202B56C005034C0E07F20300319EB
:1002E5007F30A20272067205500F120312C202C2BB
:1002F50006C205C2087F30800F300503E9C0E01251
:100305000061300503D0E0F9D0E0B56CCC300517BD
:100315007F30B9100C1200617F583004077F788058
:1003250003B908031200613002057F2D0200617FC9
:10033500202008F87F2B2006F322920280CF286E1A
:10034500756C6C2900D2011200263001F8C20178C3
:100355006C30D50108F60200CC2D504349581200E7
:10036500262403B405004001E490035E9312005275
:0D037500743A120052D203756C040201B1FB
:100A66008B5C8A5D895EAB5FAA60A9611207D36061
:100A760063AB5CAA5DA95E1207D3605F855F628582
:100A860060638561648B658A668967AB62AA63A9C0
:100A9600641207D3FF6023AB65AA66A9671207D362
:100AA6006F7017042564F564E43563F563740125F6
:100AB60067F567E43566F56680D1AB62AA63A9641B
:100AC6001207D37002800D7401255EF55EE4355D74
:100AD600F55D809DAB5CAA5DA95E227B007A0079FC
:020AE6000022EC
:10088900EF4E6012EF60010EEDBB010B89828A8386
:10089900F0A3DFFCDEFA2289F05007F709DFFCA993
:0C08A900F022BBFEFCF309DFFCA9F022EA
:1009E600020E1AE493A3F8E493A34003F68001F2FF
:1009F60008DFF48029E493A3F85407240CC8C33312
:100A0600C4540F4420C8834004F456800146F6DFE0
:100A1600E4800B0102040810204080900CC8E47E9C
:100A2600019360BCA3FF543F30E509541FFEE493D5
:100A3600A360010ECF54C025E060A840B8E493A39C
:100A4600FAE493A3F8E493A3C8C582C8CAC583CAC7
:100A5600F0A3C8C582C8CAC583CADFE9DEE780BE7F
:010CF90000FA
:1008B500BB010CE58229F582E5833AF583E02250F8
:1008C50006E92582F8E622BBFE06E92582F8E22242
:0D08D500E58229F582E5833AF583E493225C
:1008E200BB010689828A83F0225002F722BBFE01F5
:0208F200F322EF
:1008F400FAE6FB0808E6F925F0F618E6CA3AF62205
:10090400D083D082F8E4937012740193700DA3A382
:1009140093F8740193F5828883E473740293686096
:06092400EFA3A3A380DF96
:100D4B00EFB40A07740D120D56740A309811A89956
:100D5B00B8130CC2983098FDA899C298B811F63008
:070D6B0099FDC299F59922E0
:00000001FF

228
pro.uvgui.QY

File diff suppressed because one or more lines are too long

4
pro.uvopt

@ -203,7 +203,7 @@ @@ -203,7 +203,7 @@
<GroupNumber>1</GroupNumber>
<FileNumber>2</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\lcd.c</PathWithFileName>
@ -227,7 +227,7 @@ @@ -227,7 +227,7 @@
<GroupNumber>1</GroupNumber>
<FileNumber>4</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\i2c.c</PathWithFileName>

116
pwm.LST

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
C51 COMPILER V9.56.0.0 PWM 04/08/2022 03:07:52 PAGE 1
C51 COMPILER V9.56.0.0 PWM 04/09/2022 17:15:06 PAGE 1
C51 COMPILER V9.56.0.0, COMPILATION OF MODULE PWM
@ -8,62 +8,74 @@ COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE pwm.c OPTIMIZE(8,SPEED) BROWSE D @@ -8,62 +8,74 @@ COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE pwm.c OPTIMIZE(8,SPEED) BROWSE D
line level source
1 #include "pwm.h"
2
3 unsigned char pwm_val_right =0;
4 unsigned char push_val_right=0;
5
2 #include <math.h>
3
4 unsigned char pwm_val_right =0;
5 unsigned char push_val_right=0;
6 unsigned char pwm_value=0;
7
8 extern uint model;
9
10 bit Right_moto_stop = 0;
11
12 void delay(unsigned int k)
13 {
14 1 unsigned int x,y;
15 1 for(x=0;x<k;x++)
16 1 for(y=0;y<2000;y++);
17 1 }
18
19 void run(void)
20 {
21 1 if(model == 0) pwm_value = 0;
22 1 else if(model == 1) pwm_value = 2;
23 1 else if(model == 2) pwm_value = 5;
24 1 else pwm_value = 10;
25 1 push_val_right=pwm_value;
26 1 Right_moto_back;
27 1 }
28
29 void pwm_out_right_moto(void)
30 {
31 1 pwm_val_right++;
32 1 if(~Right_moto_stop){
33 2 if(pwm_val_right <= push_val_right)
34 2 {
35 3 Right_moto_pwm=1;
36 3 }
37 2 else
38 2 {
39 3 Right_moto_pwm=0;
40 3 }
41 2 if(pwm_val_right>=20) pwm_val_right=0;
42 2 }
43 1 else{
44 2 Right_moto_pwm=0;
45 2 }
46 1 }
47
48
49
50
51
8 extern uint Seep_model;
9 extern struct UserInfo usr;
10 extern uchar model;
11 extern uint mileage;
12
13 bit Right_moto_stop = 0;
14
15 void delay(unsigned int k)
16 {
17 1 unsigned int x,y;
18 1 for(x=0;x<k;x++)
19 1 for(y=0;y<2000;y++);
20 1 }
21
22 void run(void)
23 {
24 1 if(model){
25 2 Seep_model = usr.Seep_model;
26 2 usr.Remaining_mileage = usr.target_mileage - mileage;
27 2 if(usr.Remaining_mileage < 0) usr.Remaining_mileage = 0;
28 2 if(usr.Remaining_mileage == 0) Seep_model = 0;
29 2 }else{
30 2 usr.Remaining_mileage = 0;
31 2 }
32 1
33 1
34 1 if(Seep_model == 0) pwm_value = 0;
35 1 else if(Seep_model == 1) pwm_value = 2;
36 1 else if(Seep_model == 2) pwm_value = 5;
37 1 else pwm_value = 7;
38 1 push_val_right=pwm_value;
39 1 Right_moto_back;
40 1 }
41
42 void pwm_out_right_moto(void)
43 {
44 1 pwm_val_right++;
45 1 if(~Right_moto_stop){
46 2 if(pwm_val_right <= push_val_right)
47 2 {
48 3 Right_moto_pwm=1;
49 3 }
50 2 else{
51 3 Right_moto_pwm=0;
52 3 }
53 2 if(pwm_val_right>=20) pwm_val_right=0;
54 2 }
55 1 else{
C51 COMPILER V9.56.0.0 PWM 04/09/2022 17:15:06 PAGE 2
56 2 Right_moto_pwm=0;
57 2 }
58 1 }
59
60
61
62
63
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 112 ----
C51 COMPILER V9.56.0.0 PWM 04/08/2022 03:07:52 PAGE 2
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 164 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----

BIN
pwm.OBJ

Binary file not shown.

32
pwm.c

@ -1,11 +1,14 @@ @@ -1,11 +1,14 @@
#include "pwm.h"
#include <math.h>
unsigned char pwm_val_right =0;
unsigned char push_val_right=0;
unsigned char pwm_value=0;
extern uint model;
extern uint Seep_model;
extern struct UserInfo usr;
extern uchar model;
extern uint mileage;
bit Right_moto_stop = 0;
@ -18,10 +21,20 @@ void delay(unsigned int k) @@ -18,10 +21,20 @@ void delay(unsigned int k)
void run(void)
{
if(model == 0) pwm_value = 0;
else if(model == 1) pwm_value = 2;
else if(model == 2) pwm_value = 5;
else pwm_value = 10;
if(model){
Seep_model = usr.Seep_model;
usr.Remaining_mileage = usr.target_mileage - mileage;
if(usr.Remaining_mileage < 0) usr.Remaining_mileage = 0;
if(usr.Remaining_mileage == 0) Seep_model = 0;
}else{
usr.Remaining_mileage = 0;
}
if(Seep_model == 0) pwm_value = 0;
else if(Seep_model == 1) pwm_value = 2;
else if(Seep_model == 2) pwm_value = 5;
else pwm_value = 7;
push_val_right=pwm_value;
Right_moto_back;
}
@ -32,16 +45,15 @@ void pwm_out_right_moto(void) @@ -32,16 +45,15 @@ void pwm_out_right_moto(void)
if(~Right_moto_stop){
if(pwm_val_right <= push_val_right)
{
Right_moto_pwm=1;
Right_moto_pwm=1;
}
else
{
else{
Right_moto_pwm=0;
}
if(pwm_val_right>=20) pwm_val_right=0;
}
else{
Right_moto_pwm=0;
Right_moto_pwm=0;
}
}

27
pwm.h

@ -1,29 +1,32 @@ @@ -1,29 +1,32 @@
#ifndef _PWM_H
#define _PWM_H
#include <reg51.h>
#include "IRIN.h"
void delay(unsigned int k);
void run(void);
void backrun(void);
void leftrun(void);
void rightrun(void);
void run(void);
void backrun(void);
void leftrun(void);
void rightrun(void);
void pwm_out_left_moto(void);
void pwm_out_right_moto(void);
sbit IN1=P1^2;
sbit IN2=P1^3;
//定义小车驱动模块输入IO口
sbit IN1=P1^0;
sbit IN2=P1^1;
sbit EN1=P3^4;
sbit Right_moto_pwm=P3^4; //PWM信号端
sbit Right_moto_pwm=P1^7;
#define Right_moto_go {IN1=1,IN2=0;}
#define Right_moto_back {IN1=0,IN2=1;}
#define Right_moto_Stop {EN1=0; }
#define Right_moto_go {IN1=1,IN2=0;} //右边电机向前走
#define Right_moto_back {IN1=0,IN2=1;} //右边电机向后走
#define Right_moto_Stop {EN1=0;} //右边电机停转
struct UserInfo{
int Seep_model;
int target_mileage;
int Remaining_mileage;
};
#endif
Loading…
Cancel
Save