lcd.lst

来自「单片机的实用程序代码」· LST 代码 · 共 417 行 · 第 1/2 页

LST
417
字号
 194   1                      LCDWR ( LCDDAT,0x00);
 195   1                      LCDWR( LCDCOM,0x3a);// bias set
 196   1                      LCDWR ( LCDDAT,0x05);
 197   1      
 198   1                      _delay_ms(50);  
 199   1                      LCDWR( LCDCOM,0x29);   //booster set
 200   1                      _delay_ms(50);  
 201   1                      //LCDWR( LCDCOM,0x2c);   //booster efficiency set
 202   1      }
 203          /*
 204          ========================================================================================================
 205          Name: LCDDrawDollop
 206          Function: Draw a dollop at a special area
 207          Input:  1. *dollop : The pointer of a DOLLOP struct
 208          Output: None
 209          Note: The value of the input structrue must be correct, This function does not check the parameters.
 210          Author: LiYong
 211          Date  : 2008.08.09
 212          ========================================================================================================
 213          */
 214          void LCDSetArea( INT16U x1, INT16U y1, INT16U x2, INT16U y2 )
 215          {
 216   1              x1+=2;
 217   1              x2+=2;
 218   1              y1+=3;
 219   1              y2+=3;  
 220   1      
 221   1          LCDWR ( LCDCOM, 0x2A);
 222   1              LCDWR ( LCDDAT,  x1>>8);
 223   1              LCDWR ( LCDDAT, x1);
 224   1              LCDWR ( LCDDAT,  x2>>8);
 225   1              LCDWR ( LCDDAT, x2 + 0); 
 226   1      
 227   1              LCDWR ( LCDCOM, 0x2B);
 228   1              LCDWR ( LCDDAT,  y1>>8);
 229   1              LCDWR ( LCDDAT, y1); 
 230   1              LCDWR ( LCDDAT,  y2>>8);
 231   1              LCDWR ( LCDDAT, y2); 
 232   1              LCDWR ( LCDCOM, 0x2C);
 233   1      }
 234          
 235          void    LCDDrawDollop( DOLLOP* dollop )
 236          {
 237   1              INT16U x,y;
 238   1      
 239   1              LCDSetArea(dollop->xs, dollop->ys, dollop->xe, dollop->ye);     //Set a area at the screen
 240   1              for( x = 0; x < dollop->xe - dollop->xs + 1; x ++ )                                     //Display rows
C51 COMPILER V7.50   LCD                                                                   09/13/2011 19:37:14 PAGE 5   

 241   1              {
 242   2                      for( y = 0; y < dollop->ye - dollop->ys + 1; y ++ )                             //Display columns
 243   2                      {
 244   3                              LCDWR( LCDDAT, dollop->Color>>8 );
 245   3                              LCDWR( LCDDAT, dollop->Color );
 246   3                      }
 247   2              }
 248   1      }
 249          /*
 250          ========================================================================================================
 251          Name: LCDDrawPoint( );
 252          Function: Draw a point
 253          Input:  -pPoint, A structure pointer
 254          Output: None
 255          ========================================================================================================
 256          */
 257          void LCDDrawPoint( POINT* pPoint )
 258          {
 259   1          LCDSetArea( pPoint->x, pPoint->y, pPoint->x, pPoint->y );
 260   1              LCDWR ( LCDDAT,  ( pPoint->Color >> 8 ) & 0xff );
 261   1              LCDWR ( LCDDAT,  pPoint->Color & 0xff );
 262   1      }
 263          /*
 264          ========================================================================================================
 265          Name: LCDDrawHRLine( );
 266          Function: Draw a line
 267          Input:  -pLine, A structure pointer to a line
 268          Output: None
 269          ========================================================================================================
 270          */
 271          void LCDDrawHRLine( LINE* pLine )
 272          {
 273   1              INT8U x0, x1, y0, y1;
 274   1              if( pLine->xs != pLine->xe && pLine->ys != pLine->ye )   return;
 275   1              if( pLine->ys > pLine->ye )
 276   1              {
 277   2                      y0 = pLine->ye;
 278   2                      y1 = pLine->ys;
 279   2              }
 280   1              else
 281   1              {
 282   2                      y0 = pLine->ys;
 283   2                      y1 = pLine->ye;
 284   2              }
 285   1              if( pLine->xs > pLine->xe )
 286   1              {
 287   2                      x0 = pLine->xe;
 288   2                      x1 = pLine->xs;
 289   2              }
 290   1              else
 291   1              {
 292   2                      x0 = pLine->xs;
 293   2                      x1 = pLine->xe;
 294   2              }
 295   1              LCDSetArea( x0, y0, x1, y1 );
 296   1              x0 = x1 - x0;
 297   1              if( x0 == 0 ) x0 = y1 - y0;
 298   1              for( y0 = 0; y0 < x0; y0 ++ )
 299   1              {
 300   2                      LCDWR( LCDDAT, pLine->Color >> 8 );
 301   2                      LCDWR( LCDDAT, pLine->Color );
 302   2              }
C51 COMPILER V7.50   LCD                                                                   09/13/2011 19:37:14 PAGE 6   

 303   1      }
 304          /*
 305          ========================================================================================================
 306          Name: PrintBitBlock
 307          Function: Print a special block in the screen.
 308          Input:  pBitBlock: This is a pointer, It points to a block whitch contains informations of the block,
 309                  eg. height, width, and so on.
 310          Output: None
 311          Note:   None
 312          Author: LiYong
 313          Date  : 2008.08.09
 314          ========================================================================================================
 315          */
 316          void    PrintBitBlock( BitBlock *pBitBlock )
 317          {
 318   1          INT8U       Row, Column;
 319   1              INT32U  BytesAbs;
 320   1              INT8U   RowBytes;
 321   1      
 322   1              LCDSetArea( pBitBlock->xs, pBitBlock->ys,
 323   1                      pBitBlock->xs + pBitBlock->Width - 1, pBitBlock->ys + pBitBlock->Height - 1 );
 324   1      
 325   1              RowBytes = pBitBlock->Width >> 3;
 326   1              if( pBitBlock->Width & 0x07 )
 327   1              {
 328   2                      RowBytes ++;
 329   2              }
 330   1              for( Row = 0; Row <  pBitBlock->Height; Row ++ )
 331   1              {
 332   2                      for( Column = 0; Column < pBitBlock->Width; Column ++ )
 333   2                      {
 334   3                              BytesAbs = Row * RowBytes + ( Column >> 3 )     ;
 335   3                              if( *( pBitBlock->pData + BytesAbs )    & ( 1<<( Column & 0x07 )) )
 336   3                              {
 337   4                                      LCDWR( LCDDAT, pBitBlock->Color >> 8 );
 338   4                                      LCDWR( LCDDAT, pBitBlock->Color );
 339   4                              }
 340   3                              else
 341   3                              {
 342   4                                      LCDWR( LCDDAT, pBitBlock->BackColor >> 8 );
 343   4                                      LCDWR( LCDDAT, pBitBlock->BackColor );
 344   4                              }
 345   3                      }
 346   2              }
 347   1      }
 348          /*
 349          ========================================================================================================
 350          Name: GUI_Image( )
 351          Function: Print a image
 352          Input:  point to a struct which contains the informations of the image
 353          Output: None
 354          Note:   None
 355          Author: LiYong
 356          Date  : 2008.08.09
 357          ========================================================================================================
 358          */
 359          void GUI_Image( IMAGE *pImage )
 360          {
 361   1          INT16U x, y;
 362   1          INT32U datacount = 0;
 363   1          LCDSetArea( pImage->xs, pImage->ys, pImage->xs + pImage->length - 1, pImage->ys + pImage->height - 1 )
             -;
C51 COMPILER V7.50   LCD                                                                   09/13/2011 19:37:14 PAGE 7   

 364   1      
 365   1          for( x = 0; x < pImage->length; x ++ )
 366   1          {
 367   2              for( y = 0; y < pImage->height; y ++ )
 368   2              {
 369   3                  LCDWR( LCDDAT, *( pImage->pData + datacount++ ) );
 370   3                  LCDWR( LCDDAT, *( pImage->pData + datacount++ ) );
 371   3      
 372   3              }
 373   2          }
 374   1      }
 375          /*
 376          ================================================================================
 377          -----------------------------------End of file----------------------------------
 378          ================================================================================
 379          */


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2074    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----      42
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?