📄 display.lst
字号:
C51 COMPILER V7.07 DISPLAY 11/25/2005 20:22:00 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE DISPLAY
OBJECT MODULE PLACED IN display.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE display.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*
2 * Copyright(c)2005 - 2009 danise .China
3 * All rights reserved.
4 * Redistribution and use in source and bianry forms
5 * with or without modification ,are permitted provided
6 * that following conditions are met:
7 *
8 * 1.Redistrubution of source code must retain the
9 * above copyright notice,this list of conditions and
10 * following disclaimer.
11 *
12 * 2.Redistributions in binary form must reproduce the
13 * above copyright notice,this list of conditions and
14 * following disclaimer in the documentation and /or other
15 * materials provided with the distribution.
16 *
17 * Alternately, this acknowledgment may appear in the software
18 * itself,if and wherever such third-party acknowledgements
19 * normally appear.
20 *
21 * This software is designed for key board and led display.
22 *
23
24 */
25 #include "./include/display.h"
26 #include "intrins.h"
27
28 #include "./include/global.h"
29 #include "./include/system.h"
30
31
32 /**>
33 * display code tables
34 */
35 UINT8 code clrbuf[LED_MAX_NUM]={ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
36 /*
37 ledcheck table "1. 2. 3. 4. 5. 6. 7. 8. 9. - 2.0"
38 */
39 UINT8 code scrchktab[]=
40 {0xa,0xa,0xa,0xa,0xa,0xa,0xa,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,
41 0xa,0xa,0x2,0xc,0xd,0xa,0xa,0xa,0xa,0xa,0xa,0xa,0xa,0xa};
42 /* version 2.0*/
43
44
45 UINT8 code R_ledtable[]={0xa,0xeb,0x4c,0xc8,0xa9,0x98,0x18,0xcb,0x8,0x89,
46 /*0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,8 , 9*/
47 0x9,0x1e,0x1c,0x1d,0x29,0xff,0xff,0xff,0xfb
48 /* A , c , e/ , f , h , [] , [], [] , - */
49
50 };
51 UINT8 code R_dot_ledtable[]={0x2,0xe3,0x44,0xc0,0xa1,0x90,0x10,0xc3,0x0,0x81
52 /* 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 */
53 ,0xff,0xfb,0x2,0xeb
54 /*[] - 0. 1*/
55 };
C51 COMPILER V7.07 DISPLAY 11/25/2005 20:22:00 PAGE 2
56 UINT8 code L_ledtable[]={0x48,0xeb,0x8c,0x89,0x2b,0x19,0x18,0xcb,0x8,0xb,
57 /* 0 , 1 ,2 ,3 , 4 , 5 , 6 , 7 , 8 , 9 */
58 0xa,0x5c,0x1c,0x1e,0x2a,0xff,0xff,0xff,0xbf};
59 /*A , c , e , f , h , [], [] [] - */
60
61 UINT8 code L_dot_ledtable[]={0x40,0xe3,0x84,0x81,0x23,0x11,0x10,0xc3,0x0,0x3,0xff,0xbf,0x40,0xeb};
62 /* 0. , 1. , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 [] - 0. 1*/
63 /* a structure for leds display */
64 STR_LEDBCDCODE LedsShowStr;
65 /* screen save table */
66 UINT8 scrsavebuf[]={0,0,0,0,0,0,0,14,0,0,0,0,17,17,17,17,17,17,17,17};
67 UINT8 scrindex = 0;
68 UINT8 scrflag =0; /* screen save flag */
69 /**/
70
71
72 /****
73 * show one byte figure ,it will be called by "LedMultiByteDisplay"
74 */
75 void LedOneByteDisplay( UINT8 dat, UINT8 position )
76 {
77 1 UINT8 data temp = 0x0;
78 1 UINT8 i;
79 1
80 1 if( position == POSITION_UP ){
81 2 UPLED_CLK = 0;
82 2 for(i=0;i<8;i++)
83 2 {
84 3 temp = dat & 0x01;
85 3 dat= dat >> 1 ;
86 3 if( 0x0 == temp )
87 3 UPLED_DATA = 0;
88 3 else
89 3 UPLED_DATA = 1;
90 3
91 3 UPLED_CLK = 1;
92 3 _nop_();
93 3 UPLED_CLK = 0;
94 3 }
95 2
96 2 }
97 1 else
98 1 if( position == POSITION_DOWN ){
99 2 DOWNLED_CLK = 0;
100 2 for(i=0;i<8;i++)
101 2 {
102 3 temp = dat & 0x01;
103 3 dat=dat >> 1 ;
104 3 if( 0x0 == temp )
105 3 DOWNLED_DATA = 0;
106 3
107 3 else
108 3 DOWNLED_DATA = 1;
109 3
110 3 DOWNLED_CLK = 1;
111 3 _nop_();
112 3 DOWNLED_CLK = 0;
113 3 }
114 2
115 2
116 2
117 2 }
C51 COMPILER V7.07 DISPLAY 11/25/2005 20:22:00 PAGE 3
118 1 }
119 /**
120 buf is a arrary filled with led display code.
121 this function just show the led display code directly ,
122 never do other thing
123 */
124 void LedMultiByteDisplay( UINT8 * buf ,UINT8 position ) reentrant
125 {
126 1 UINT8 data i;
127 1 for(i=0;i<LED_MAX_NUM;i++)
128 1 {
129 2 LedOneByteDisplay(*buf ++ ,position );
130 2 }
131 1
132 1 }
133 /*
134 clear up leds
135 */
136 void ClearUpLeds(void)
137 {
138 1 LedMultiByteDisplay(clrbuf, POSITION_UP );
139 1 }
140 /*
141 clear down leds
142 */
143 void ClearDownLeds(void)
144 {
145 1 LedMultiByteDisplay(clrbuf, POSITION_DOWN );
146 1 }
147
148 /*
149
150 */
151 void CkeckLights( void )
152 {
153 1 UINT8 T = 0x01;
154 1 UINT8 i;
155 1 for(i=0;i<=LIGHTS_MAX_NUM;i++)
156 1 {
157 2 SparkLights( T );
158 2 T <<= 1;
159 2 wait( 10 );
160 2 }
161 1
162 1 }
163 /*****************************************************************\
164 *check leds when starting system
165 *
166 \*****************************************************************/
167 void CheckLeds( void )
168 {
169 1
170 1 UINT8 ledshowcode[LED_MAX_NUM];
171 1 UINT8 i;
172 1 LedsShowStr.isdot = 0;
173 1 LedsShowStr.dotposition = 7;
174 1 LedsShowStr.length = 8;
175 1 for(i=0;i<23;i++)
176 1 {
177 2 ClearUpLeds();
178 2 ClearDownLeds();
179 2 memcpy(&LedsShowStr.ledbuf[0],scrchktab+i ,LED_MAX_NUM );
C51 COMPILER V7.07 DISPLAY 11/25/2005 20:22:00 PAGE 4
180 2 TranslateLedCode(LedsShowStr , ledshowcode , 0);/* with mode 0 */
181 2 LedMultiByteDisplay( ledshowcode , POSITION_UP );
182 2 LedMultiByteDisplay( ledshowcode , POSITION_DOWN );
183 2 wait(10);
184 2
185 2 }
186 1 /*reset ledshowstr */
187 1 RESETLEDSHOWSTR();
188 1
189 1 }
190 /*
191 * mode =0; need not to clear head zero
192 * mode =1; need to clear head zero
193 */
194 void TranslateLedCode(STR_LEDBCDCODE cobcd ,UINT8 * coled,UINT8 mode)
195 {
196 1 UINT8 data i;
197 1 UINT8 isheadzero = FALSE ;
198 1 if( mode == 1 ){
199 2 if(!cobcd.isdot && cobcd.length == 1 && cobcd.ledbuf[7]==0 ){
200 3 memset(coled,0xff,8);
201 3 coled[7]=0xa;
202 3 return;
203 3 }
204 2 if( cobcd.isdot && cobcd.length == 1 && cobcd.ledbuf[7]==0){
205 3 memset(coled,0xff,8);
206 3 coled[7]=0x2;
207 3 return;
208 3 }
209 2
210 2 for(i=0;i<LED_MAX_NUM; i++)
211 2 {//for begin
212 3
213 3 if( 0x1== ( i & 0x01 ) ){ /*right */ //if _1
214 4 if((cobcd.ledbuf[i]==0x0 && isheadzero==FALSE )){//if _2
215 5 coled[i] = 0xff;
216 5 }//if 2_
217 4 else{
218 5 coled[i]=R_ledtable[cobcd.ledbuf[i]];
219 5 isheadzero = TRUE;
220 5 }
221 4
222 4 }// if 1_
223 3 else{/* left */
224 4 if((cobcd.ledbuf[i]==0x0 && isheadzero==FALSE )){
225 5 coled[i] = 0xff;
226 5 }
227 4 else{
228 5 coled[i]=L_ledtable[cobcd.ledbuf[i]];
229 5 isheadzero = TRUE;
230 5 }
231 4
232 4 }
233 3 }//for end
234 2
235 2 /*add dot*/
236 2 if( cobcd.isdot == 1 ){ /* 1 -> " ."*/
237 3 if( (cobcd.dotposition &0x01)==0x1 ){
238 4 /* right */
239 4 coled[cobcd.dotposition]=R_dot_ledtable[cobcd.ledbuf[cobcd.dotposition]];
240 4
241 4 }
C51 COMPILER V7.07 DISPLAY 11/25/2005 20:22:00 PAGE 5
242 3 else{
243 4 /* left */
244 4 coled[cobcd.dotposition]=L_dot_ledtable[cobcd.ledbuf[cobcd.dotposition]];
245 4 }
246 3 }
247 2
248 2 return;
249 2
250 2 }
251 1 if( mode == 0 ){
252 2 for(i=0;i<LED_MAX_NUM;i++)
253 2 {
254 3 if(0x1 == (i & 0x01)){
255 4 /* right */
256 4 coled[i]=R_dot_ledtable[cobcd.ledbuf[i]];
257 4 }
258 3 else{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -