⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_io.lst

📁 upsd 3200序列的usb驱动
💻 LST
📖 第 1 页 / 共 2 页
字号:
 234   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 235   4                      {
 236   5                          LCD_index = 0;
 237   5                      }
 238   4                              }
 239   3                  else if (*chr_ptr == 'x') 
 240   3                  {
 241   4                      // Display 1 byte hex 00-FF
C51 COMPILER V7.00 Beta 6  LCD_IO                                                          02/19/2003 15:59:28 PAGE 5   

 242   4                                      chr_ptr++;
 243   4      
 244   4                      var = *var_ptr++;
 245   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
 246   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_hi(var);
 247   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 248   4                      {
 249   5                          LCD_index = 0;
 250   5                      }
 251   4                      BusyCheck();
 252   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
 253   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_lo(var);
 254   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 255   4                      {
 256   5                          LCD_index = 0;
 257   5                      }
 258   4                              }
 259   3                              else if (*chr_ptr == 'w') 
 260   3                  {           
 261   4                      // Display 1 word hex 0000-FFFF
 262   4                                      chr_ptr++;
 263   4      
 264   4                      var = *var_ptr++;
 265   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
 266   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_hi(var);
 267   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 268   4                      {
 269   5                          LCD_index = 0;
 270   5                      }
 271   4                      BusyCheck();
 272   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
 273   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_lo(var);
 274   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 275   4                      {
 276   5                          LCD_index = 0;
 277   5                      }
 278   4      
 279   4                      BusyCheck();
 280   4                      
 281   4                      var = *var_ptr++;
 282   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
 283   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_hi(var);
 284   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 285   4                      {
 286   5                          LCD_index = 0;
 287   5                      }
 288   4                      BusyCheck();
 289   4                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
 290   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = htoa_lo(var);
 291   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 292   4                      {
 293   5                          LCD_index = 0;
 294   5                      }
 295   4                              }
 296   3                              else if (*chr_ptr == 'c')
 297   3                  {
 298   4                      // Display 1 character
 299   4                      chr_ptr++;
 300   4                      var = *var_ptr++;
 301   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = var;
 302   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 303   4                      {
C51 COMPILER V7.00 Beta 6  LCD_IO                                                          02/19/2003 15:59:28 PAGE 6   

 304   5                          LCD_index = 0;
 305   5                      }
 306   4                  }
 307   3                              else 
 308   3                  {
 309   4                      // Out character to LCD Display RAM                
 310   4                      LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = *chr_ptr++;
 311   4                      if (LCD_index >= LCD_BUFFER_SIZE)
 312   4                      {
 313   5                          LCD_index = 0;
 314   5                      }
 315   4                      }
 316   3                      }
 317   2                      else
 318   2                      {
 319   3                  // Out character to LCD Display RAM                         
 320   3                  LCD_reg.LCD_RAM_WR = LCD_buffer[LCD_index++] = *chr_ptr++;
 321   3                  if (LCD_index >= LCD_BUFFER_SIZE)
 322   3                  {
 323   4                      LCD_index = 0;
 324   4                  }
 325   3                      }
 326   2              }
 327   1      }
 328          
 329          //  These are the LCD functions.
 330          /*
 331          void lcd_clear(void)                    // clear all characters from display   
 332                  {
 333                  BusyCheck();
 334                  LCD_reg.LCD_CMD_WR = 0x01;
 335                  Cursor_LCD = DD_ADDR;
 336                  }
 337          
 338          void lcd_string_display(row,col,string)         
 339                                          // send string to LCD   
 340                                          // row = 0 is top row   
 341                                          // row = 1 is bottom    
 342                                          // col = 0 to 15            
 343                                          // length = string length   
 344                                          // string points to char array   
 345          uchar row;
 346          uchar col;
 347          uchar *string;
 348                  {
 349                  char k;
 350                  k = 0;
 351                  lcd_cursor_set(row,col);        // position cursor   
 352                  while (k < LCD_LINE_LENGTH+1 && *string)        // truncate string to 16 
 353                                                  // or end of string   
 354                          {
 355                          BusyCheck();
 356                          LCD_reg.LCD_RAM_WR = *string++; // send character   
 357                          k++;
 358                          }
 359                  }
 360          
 361          
 362          void lcd_char_display(row,col,ch)       // send single char to LCD   
 363                                                  // row = 0 is top row   
 364                                                  // row = 1 is bottom    
 365                                                  // col = 0 to 15            
C51 COMPILER V7.00 Beta 6  LCD_IO                                                          02/19/2003 15:59:28 PAGE 7   

 366          uchar row;
 367          uchar col;
 368          char ch;
 369                  {
 370                  lcd_cursor_set(row,col);        // position cursor   
 371                  BusyCheck();
 372                  LCD_reg.LCD_RAM_WR = ch;                        // send character   
 373                  }
 374          
 375                  
 376          void lcd_cursor_set(row,col)    // move cursor to desired position   
 377          uchar row;
 378          uchar col;
 379                  
 380                  {
 381                  BusyCheck();
 382                  switch(row)
 383                          {
 384                          case 0:
 385                                  LCD_reg.LCD_CMD_WR = (0x80 + col);
 386                                  break;
 387                                  
 388                          case 1:
 389                                  LCD_reg.LCD_CMD_WR = (0xC0 + col);
 390                                  break;
 391                          }
 392                  }
 393          */
 394          
 395          
 396          // this is a collection of conversion routines used in conjunction with the LCD display
 397          /*
 398          static char Bin2Hex(char temp) {
 399          
 400                  if (temp <= 9) temp += '0'; else temp=(temp-10)+'A';
 401                  return (temp);
 402          }
 403          */
 404          
 405          static char htoa_lo(byte)        // converts low nibble of unsigned byte
 406                                                                   // (0-F hex) to ascii   
 407          uchar byte;
 408                  {
 409   1              byte = byte & 0x0F;     // keep lower nibble only   
 410   1              if (byte <= 0x09)
 411   1                      return(byte + 0x30);
 412   1              else
 413   1                      return (byte + 0x37);
 414   1              }
 415          
 416          /*
 417          static char lhtoa_lo(word)       // converts 2nd nibble of unsigned int
 418                                                                   // (0-F hex) to ascii   
 419          unsigned int word;
 420                  {
 421                  word = word >> 8;
 422                  word = word & 0x000F;
 423                  if (word <= 0x0009)
 424                          return((char)word + 0x30);
 425                  else
 426                          return ((char)word + 0x37);
 427                  }
C51 COMPILER V7.00 Beta 6  LCD_IO                                                          02/19/2003 15:59:28 PAGE 8   

 428          */
 429          
 430          static char htoa_hi(byte)        // converts hi nibble of unsigned byte
 431                                                                   // (0-F hex) to ascii   
 432          uchar byte;
 433                  {
 434   1              byte = byte & 0xF0;     // keep upper nibble only   
 435   1              byte = byte >> 4;
 436   1              if (byte <= 0x09)
 437   1                      return(byte + 0x30);
 438   1              else
 439   1                      return (byte + 0x37);
 440   1              }
 441          
 442          /*
 443          static char lhtoa_hi(word)       // converts 1st nibble of unsigned int
 444                                                                   // (0-F hex) to ascii   
 445          unsigned int word;
 446                  {
 447                  word = word >> 12;
 448                  word = word & 0x000F;
 449                  if (word <= 0x0009)
 450                          return((char)word + 0x30);
 451                  else
 452                          return ((char)word + 0x37);
 453                  }
 454          */
 455          
 456          
 457          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1125    ----
   CONSTANT SIZE    =     57    ----
   XDATA SIZE       =     38      50
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =      1    ----
   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 + -