📄 lcd_io.lst
字号:
198 4 //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
199 4 LCD_reg.LCD_RAM_WR = htoa_hi(var);
200 4 BusyCheck();
201 4 //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
202 4 LCD_reg.LCD_RAM_WR = htoa_lo(var);
203 4 }
204 3 else
205 3 if (*chr_ptr == 'w') { // display 1 word hex 0000-FFFF
206 4 chr_ptr++;
207 4
208 4 var = *var_ptr++;
209 4 //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
210 4 LCD_reg.LCD_RAM_WR = htoa_hi(var);
211 4 BusyCheck();
212 4 //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
213 4 LCD_reg.LCD_RAM_WR = htoa_lo(var);
214 4
215 4 BusyCheck();
216 4
217 4 var = *var_ptr++;
218 4 //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
219 4 LCD_reg.LCD_RAM_WR = htoa_hi(var);
220 4 BusyCheck();
221 4 //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
222 4 LCD_reg.LCD_RAM_WR = htoa_lo(var);
223 4 }
224 3 else {
225 4 LCD_reg.LCD_RAM_WR = *chr_ptr++; //out character to LCD Diaplay RAM
226 4 }
227 3 }
228 2 else
229 2 {
230 3 LCD_reg.LCD_RAM_WR = *chr_ptr++; //out character to LCD Diaplay RAM
231 3 }
232 2 }
233 1 }
234 /*
235 char Bin2Hex(char temp) {
236
237 if (temp <= 9) temp += '0'; else temp=(temp-10)+'A';
238 return (temp);
239 }
240 */
241
C51 COMPILER V7.00 LCD_IO 11/13/2002 09:49:12 PAGE 5
242 // These are the LCD functions.
243 void print_hex (byte)
244 unsigned char byte;
245 {
246 1 putch_LCD(htoa_hi(byte)); // print s2con hi nibble
247 1 putch_LCD(htoa_lo(byte)); // print s2con low nibble
248 1 }
249
250 void lcd_clear(void) // clear all characters from display
251 {
252 1 BusyCheck();
253 1 LCD_reg.LCD_CMD_WR = 0x01;
254 1 Cursor_LCD = DD_ADDR;
255 1 }
256
257 /*
258 void lcd_string_display(row,col,string)
259 // send string to LCD
260 // row = 0 is top row
261 // row = 1 is bottom
262 // col = 0 to 15
263 // length = string length
264 // string points to char array
265 unsigned char row;
266 unsigned char col;
267 unsigned char *string;
268 {
269 char k;
270 k = 0;
271 lcd_cursor_set(row,col); // position cursor
272 while (k < LCD_LINE_LENGTH+1 && *string) // truncate string to 16
273 // or end of string
274 {
275 BusyCheck();
276 LCD_reg.LCD_RAM_WR = *string++; // send character
277 k++;
278 }
279 }
280
281
282 void lcd_char_display(row,col,ch) // send single char to LCD
283 // row = 0 is top row
284 // row = 1 is bottom
285 // col = 0 to 15
286 unsigned char row;
287 unsigned char col;
288 char ch;
289 {
290 lcd_cursor_set(row,col); // position cursor
291 BusyCheck();
292 LCD_reg.LCD_RAM_WR = ch; // send character
293 }
294
295
296 void lcd_cursor_set(row,col) // move cursor to desired position
297 unsigned char row;
298 unsigned char col;
299
300 {
301 BusyCheck();
302 switch(row)
303 {
C51 COMPILER V7.00 LCD_IO 11/13/2002 09:49:12 PAGE 6
304 case 0:
305 LCD_reg.LCD_CMD_WR = (0x80 + col);
306 break;
307
308 case 1:
309 LCD_reg.LCD_CMD_WR = (0xC0 + col);
310 break;
311 }
312 }
313
314 */
315
316 // this is a collection of conversion routines used in conjunction with the LCD display
317
318
319 char htoa_lo(byte) // converts low nibble of unsigned byte
320 // (0-F hex) to ascii
321 unsigned char byte;
322 {
323 1 byte = byte & 0x0F; // keep lower nibble only
324 1 if (byte <= 0x09)
325 1 return(byte + 0x30);
326 1 else
327 1 return (byte + 0x37);
328 1 }
329
330 /*
331 char lhtoa_lo(word) // converts 2nd nibble of unsigned int
332 // (0-F hex) to ascii
333 unsigned int word;
334 {
335 word = word >> 8;
336 word = word & 0x000F;
337 if (word <= 0x0009)
338 return((char)word + 0x30);
339 else
340 return ((char)word + 0x37);
341 }
342
343 */
344 char htoa_hi(byte) // converts hi nibble of unsigned byte
345 // (0-F hex) to ascii
346 unsigned char byte;
347 {
348 1 byte = byte & 0xF0; // keep upper nibble only
349 1 byte = byte >> 4;
350 1 if (byte <= 0x09)
351 1 return(byte + 0x30);
352 1 else
353 1 return (byte + 0x37);
354 1 }
355
356 /*
357 char lhtoa_hi(word) // converts 1st nibble of unsigned int
358 // (0-F hex) to ascii
359 unsigned int word;
360 {
361 word = word >> 12;
362 word = word & 0x000F;
363 if (word <= 0x0009)
364 return((char)word + 0x30);
365 else
C51 COMPILER V7.00 LCD_IO 11/13/2002 09:49:12 PAGE 7
366 return ((char)word + 0x37);
367 }
368
369 void copy_message(msg_ptr, destination)
370 unsigned int msg_ptr;
371 unsigned int destination;
372 {
373 xdata unsigned char i;
374 xdata unsigned char code * temp_add;
375 xdata unsigned char src_code;
376 xdata unsigned char xdata * dest_add;
377
378
379 for (i=0; i<LCD_LINE_LENGTH; i++)
380 {
381 temp_add = (unsigned char *) ( msg_ptr + i); // get message byte
382 src_code = * temp_add;
383 dest_add = (unsigned char *) (destination + i); // put message byte
384 * dest_add = src_code;
385 }
386 }
387 */
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 557 ----
CONSTANT SIZE = 57 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 26
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -