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

📄 lcd.c

📁 ucosII在TMS320LF2407成功移植的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
**************************************************************************
*                                           Write Data to LCD Display Buffer
*
* Description :  This function is used to send a single byte to LCD display buffer.
* Arguments  :  'left_right' indicates left screen or right screen. 'LEFT' means left screen;
*                       'RIGHT' means right screen.
*                      'data' is a single byte to be sent.
* Returns      :   None.                  
**************************************************************************
*/
void DispDataWr(BOOLEAN left_right,INT8U data)
{
     data &=0xFF;
	 switch(left_right)
     	{
	 	case LEFT:  
	 	 {
	 	   Disp_L_DataAddr=data;
	 	   Disp_Aux_InstrAddr=DISP_CMD_AUXILIARY;
           break;
           }
		case RIGHT:
		  {
	 	   Disp_R_DataAddr=data;
	 	   Disp_Aux_InstrAddr=DISP_CMD_AUXILIARY;
           break;
           }
		default: break;
     	}
	 DELAY(1);
	 return;
}

/*
**************************************************************************
*                   Convert an ASCII code to Bitmap Array Index
*
* Description :  This function is used to convert an ASCII code to bitmap array index.
* Arguments  :   'c' is an ASCII code.
* Returns      :  The index of corresponding ASCII code in bitmap array. If the code is not
*                     in the scope of 0x20 to 0x7F, the value is 0.
**************************************************************************
*/
static INT8U atoIx(INT8U c)
{ 
   if(c>=0x20&&c<=0x7F) return (c-0x20);
   else return 0x0;
   
}

/*
**************************************************************************
*                                           Display an ASCII Character
*
* Description :  This function is used to write an ASCII character to LCD display buffer.
* Arguments  :  'row'  is the row position of the character left-top;
*                      'col'  is the column position of the character left-top;
*                      'c' is the character to write to the display current row/col position.
* Returns      :   None.                  
**************************************************************************
*/
void DispChar (INT8U row,INT8U col,CHAR c)
{

#if MULTITASK == 1
     INT8U err;
     xOSSemTake(DispSem, 0, &err);
#endif

	   c=atoIx(c);
	   DispBitmap(row,col,CurBitmap.BitmapTotalPages,CurBitmap.BitmapWidth,CurBitmap.BitmapData,c);

#if MULTITASK == 1
     xOSSemGive(DispSem);
#endif	

	   return;
}

/*
**************************************************************************
*                                           Write a non-ASCII Chinese Character
*
* Description :  This function is used to write a non-ASCII character (such as Chinese 
*                      character) to LCD display buffer.
* Arguments  :  'row'  is the row position of the character left-top;
*                      'col'  is the column position of the character left-top;
*                      'ix' is the index of the character to write in character bitmap array.
* Returns      :   None.                      
**************************************************************************
*/
#if DISP_NONASCII_CHAR == 1
void DispNAChar(INT8U row,INT8U col,INT8U ix)
{
#if MULTITASK == 1
     INT8U err;
     xOSSemTake(DispSem, 0, &err);
#endif

  DispBitmap(row,col,CurBitmap.BitmapTotalPages,CurBitmap.BitmapWidth,CurBitmap.BitmapData,ix);

#if MULTITASK == 1
     xOSSemGive(DispSem);
#endif	
	   return;
}

#endif
/*
**************************************************************************
*                                           Display a Picture
*
* Description :  This function is used to write an ASCII character to LCD display buffer.
* Arguments  :  'row'  is the row position of the picture left-top;
*                      'col'  is the column position of the picture left-top;
* Returns      :   None.                 
**************************************************************************
*/
#if DISP_PICTURE == 1

void DispGraphic(INT8U row,INT8U col)
{

#if MULTITASK == 1
     INT8U err;
     xOSSemTake(DispSem, 0, &err);
#endif

      DispBitmap(row, col, CurBitmap.BitmapTotalPages,CurBitmap.BitmapWidth,CurBitmap.BitmapData,0);

#if MULTITASK == 1
     xOSSemGive(DispSem);
#endif

    return;
}

#endif
/*
**************************************************************************
*                                           Write Bitmap
*
* Description :  This function is used to write bitmap.
* Arguments  :  'row'  is the row position of the picture left-top;
*                      'col'  is the column position of the picture left-top;
*                      'bitmapTotalPages' is the total pages that bitmap occupied, it can be looked
*                       as the height of this bitmap;
*                      'bitmapWidth' is the width of this bitmap;
*                      'bitmapData' is the pointer to the bitmap data;
*                      'dataArrayStartIx' is the start index of the content to be display in bitmap
*                       data array.
* Returns      :   None.                  
**************************************************************************
*/

  void DispBitmap(INT8U row, INT8U col,
                                INT8U bitmapTotalPages,INT8U bitmapWidth,
                                 INT8U *bitmapData,INT8U dataArrayStartIx)
{
         INT8U i ,colCnt,pageIx;
         BOOLEAN left_right;
         
         row %=DISP_MAX_ROWS;
         col %=DISP_MAX_COLS;
         
		 i=0;
		 if(((DISP_MAX_COLS/2-1)-col%(DISP_MAX_COLS/2))>=bitmapWidth)
		 	{
      		          
      		    for(pageIx=0;pageIx<bitmapTotalPages;pageIx++)
      	            {
      		 	      left_right=DispSetCursor(row+pageIx*DISP_ROWS_PERPAGE,col);
			          for(;i<(pageIx+1)*bitmapWidth;i++)
		                 {   
                           DispDataWr(left_right,bitmapData[TRANS(dataArrayStartIx,i)]);
			              }
		 	         }
		 	   }
		 else
		 	{
			 	for(pageIx=0;pageIx<bitmapTotalPages;pageIx++)
                      {
                        left_right=DispSetCursor(row+pageIx*DISP_ROWS_PERPAGE,col);
                        colCnt=col%(DISP_MAX_COLS/2);
                        for(;i<(pageIx+1)*bitmapWidth;i++)
                        	{   
                        	  if(colCnt<=DISP_MAX_COLS/2-1)
                        		 {DispDataWr(left_right,bitmapData[TRANS(dataArrayStartIx,i)]);}
                        	  else
                        		 {DispSetCursor(row+pageIx*DISP_ROWS_PERPAGE,0);colCnt=0;left_right=!left_right;
                        		  DispDataWr(left_right,bitmapData[TRANS(dataArrayStartIx,i)]);}
                        	  colCnt++;
                        	  DELAY(2);
                        	}
                        }  	 
		 	  }
		 return;
}


/*
**************************************************************************
*                                           Set Cursor Position
*
* Description :  This function is used to set cursor position.
* Arguments  :  'row' is the row position of the cursor;
*                      'col' is the column position of the cursor;.
* Returns      :   None.                  
**************************************************************************
*/
BOOLEAN DispSetCursor (INT8U row,INT8U col)
{
      if (row>DISP_MAX_ROWS-1)
	   {
	      row%=DISP_MAX_ROWS;
	    }
	    if(col>DISP_MAX_COLS-1)
	   {
	      col%=DISP_MAX_COLS;
	    }
     
           DispSetStartLine(row%(DISP_MAX_PAGES));
           DispSetPageAddr(row/(DISP_MAX_PAGES));
	     if(col<=(DISP_MAX_COLS/2-1))
               {DispSetYAddr(col); return LEFT;}
	     else
		 {DispSetYAddr(col-DISP_MAX_COLS/2);return RIGHT;}

	 
}
/*
**************************************************************************
*                                  Display a String
*
* Description :  This function is used to display a string.
* Arguments  :  'row' is the row position of the cursor;
*                      'col' is the column position of the cursor;
*                      's' is a pointer to the string to write to the dispaly.
* Returns      :   None.                  
**************************************************************************
*/
void DispStr(INT8U row,INT8U col, CHAR *s)
{
  
  while(*s)
  {
    DispSetCursor(row,col);
    DispChar(row,col,*s++);
    col +=CurBitmap.BitmapWidth;
    }
    
}

/*
******************************************************************************************
                                     End of LCD.c
******************************************************************************************
*/

⌨️ 快捷键说明

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