📄 cmenu.lst
字号:
C51 COMPILER V7.20 CMENU 06/20/2005 16:55:55 PAGE 1
C51 COMPILER V7.20, COMPILATION OF MODULE CMENU
OBJECT MODULE PLACED IN cmenu.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE cmenu.c BROWSE DEBUG OBJECTEXTEND
line level source
1 //
2 //--------------------------------------------------------------------
3 //menu control
4 // first, current, history, set
5 //--------------------------------------------------------------------
6 //
7 #include <stdio.h>
8 #include <string.h>
9 #include <INTRINS.h>
10 #include <AT89X52.H>
11 #include <stdlib.h>
12 #include <absacc.h>
13 #include "charger.h"
14 //
15 #define lllssj adinhz[9]
16 #define MAX_madin 7
17 #define MAX_mset 12
18 #define MAX_mhis 17
19
20 #define listsysv 0
21
22 #define setover 6
23 #define setsysv 7
24 #define setdisc 8
25 #define setchar 9
26 #define setclock 10
27 #define settemp 11
28 #define setexit 12
29
30 static unsigned char bdata kstate;
31
32 sbit key_scan=kstate^0;
33 sbit change=kstate^1;//change number
34 sbit key=kstate^2;
35 sbit kflag=kstate^3;//key buffer enmpty while kflag=0
36 sbit waitover=kstate^4;
37 sbit mfirst=kstate^5;
38 sbit exit=kstate^6;
39 sbit testchange=kstate^7;//change test temp.
40 //menu
41 static unsigned char idata maxno;
42 //
43 static unsigned char xdata dstr[21] _at_ 0xDB00;
44 static unsigned char xdata str[10] _at_ 0xDB16;
45
46
47 static void itoa(unsigned char i,unsigned int ad);
48 void keyrst(unsigned char m);
49 static void onchange();
50 //
51 //----------------------------
52 //key state and buffer reset
53
54 static link yesterday;//using to save yesterday data
55 static unsigned char idata menuno,subno;
C51 COMPILER V7.20 CMENU 06/20/2005 16:55:55 PAGE 2
56 //keyboard
57 static unsigned int idata pushlen,uplen;
58
59 void keyrst(unsigned char m)
60 {
61 1 subno=0;
62 1 kstate=0; key_scan=1; kflag=1;
63 1 if(m==0)//exit menu
64 1 {
65 2 kstate=0;
66 2 mfirst=1;//have interrupt not gernerate ,EX0->P3.2 is lowlevel
67 2 pushlen=0;uplen=0;
68 2 menuno=0;//first screen
69 2 clear();
70 2 }
71 1 RESET_DOG;
72 1 }
73 //-----------------------------------------------------------
74 //change unsigned int to ascii,add unit,change to date format
75 static void itoa(unsigned char i,unsigned int ad)
76 {
77 1 unsigned char data t;
78 1 bit bdata zf;
79 1
80 1 zf=0;
81 1
82 1 if(i==3)//temp K to C
83 1 if(ad>=2730)ad-=2730;
84 1 else if(ad!=0){ad=2730-ad;zf=1;}
85 1
86 1 dstr[0]='\0';
87 1 if(i<4)
88 1 {//change int to string
89 2 if(menuno==0x4&&subno!=settemp)sprintf(str,"%u\x20\0",ad);//set menu,unsigned int
90 2 else{
91 3 t=ad; ad /=0xA; t-=ad*0xA;
92 3 if(zf)sprintf(str,"-%u.%bu\x20\0",ad,t);
93 3 else sprintf(str,"%u.%bu\x20\0",ad,t);
94 3 }
95 2
96 2 if(i==3)
97 2 {
98 3 t=strlen(str);
99 3 if(t&1)
100 3 {
101 4 str[t]=0x20;
102 4 str[t+1]='\0';
103 4 }
104 3 }
105 2 strcat(str,unit[i]);
106 2 }
107 1 else
108 1 {//change to timer format string
109 2 sprintf(dstr,"%b02u/%b02u/%b02u\0",str[0],str[1],str[2]);
110 2 if(i==4)
111 2 {
112 3 dstr[8]=0x20;
113 3 sprintf(&dstr[9],"%b02u:%b02u:%b02u\0",str[3],str[4],str[5]);
114 3 }
115 2 }
116 1 RESET_DOG;
117 1 }
C51 COMPILER V7.20 CMENU 06/20/2005 16:55:55 PAGE 3
118
119 //
120 //----------------------------------------------
121 #define xdcdy adinhz[8]
122 //-------------------------------------------------
123 //general after second interrupt
124 //display battery volatage and timer
125 void firstscr(void)
126 {
127 1 if(_testbit_(mfirst))
128 1 {
129 2 overloadctl();//overload control
130 2
131 2 read12887(str);
132 2 if(!key_scan)
133 2 {
134 3 itoa(4,0);
135 3 text(0x90,dstr);
136 3 }
137 2 //3 save timer,hour:minite:second to testing
138 2 //yymmdd
139 2 today.date[0]=str[0];
140 2 today.date[1]=str[1];
141 2 today.date[2]=str[2];
142 2 if(!key_scan)
143 2 {char data i;
144 3 itoa(0,adin[8]);//
145 3 strcpy(dstr,xdcdy);
146 3 strcat(dstr,str);
147 3 i=strlen(dstr);
148 3 //display control state char if(controlstate!=0&&menuno==0)
149 3 {dstr[i++]=0x20;dstr[i++]=controlstate;dstr[i++]=0x20;dstr[i]=0;}
150 3 text(0x80,dstr);//
151 3 }
152 2 }
153 1 RESET_DOG;
154 1 }
155 //union bitseg mz;
156 //--------------------
157 static void msetsystem(void)
158 {
159 1 code char maxset=MAX_mset;
160 1
161 1 if(subno<0||subno>maxset)subno=maxset;//sub menu loop
162 1 clear();
163 1 text(0x80,sethz[subno]);if(subno==setexit)return;
164 1 if(subno!=setclock)
165 1 {
166 2 itoa(uset[subno],sys[subno]);
167 2 text(0x90,str);
168 2 }
169 1 else
170 1 {
171 2 read12887(str);
172 2 itoa(4,0);
173 2 text(0x90,dstr);
174 2 }
175 1 RESET_DOG;
176 1 }
177 //
178 //--------------------
179 static void mexploderhistory(void)
C51 COMPILER V7.20 CMENU 06/20/2005 16:55:55 PAGE 4
180 {
181 1 code char maxno=MAX_mhis;
182 1
183 1 clear();
184 1 secondline:
185 1 itoa(uhis[subno],yesterday->work[subno]);
186 1 strcpy(dstr,hishz[subno]);
187 1 strcat(dstr,str);
188 1 if(subno&1)
189 1 {
190 2 text(0x90,dstr);
191 2 subno++;
192 2 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -