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

📄 lcd.c

📁 uCOS-II下实现的lwip协议栈实现Ping功能
💻 C
📖 第 1 页 / 共 2 页
字号:
                     {
                            e=dy-dx/2;
                            while(x1>=x2)
                            {
                                   PutPixel(x1,y1,color);
                                   if(e>0){y1+=1;e-=dx;}	
                                   x1-=1;
                                   e+=dy;
                            }
                     }
                     else		// 3/8 octant
                     {
                            e=dx-dy/2;
                            while(y1<=y2)
                            {
                                   PutPixel(x1,y1,color);
                                   if(e>0){x1-=1;e-=dy;}	
                                   y1+=1;
                                   e+=dx;
                            }
                     }
              }
              else		   // dy<0
              {
                     dy=-dy;   // dy=abs(dy)

                     if(dx>=dy) // 5/8 octant
                     {
                            e=dy-dx/2;
                            while(x1>=x2)
                            {
                                   PutPixel(x1,y1,color);
                                   if(e>0){y1-=1;e-=dx;}	
                                   x1-=1;
                                   e+=dy;
                            }
                     }
                     else		// 6/8 octant
                     {
                            e=dx-dy/2;
                            while(y1>=y2)
                            {
                                   PutPixel(x1,y1,color);
                                   if(e>0){x1-=1;e-=dy;}	
                                   y1-=1;
                                   e+=dx;
                            }
                     }
              }	
       }
}

/**************************************************************
在LCD屏幕上画一个矩形
**************************************************************/
void Glib_Rectangle(int x1,int y1,int x2,int y2,int color)
{
       Glib_Line(x1,y1,x2,y1,color);
       Glib_Line(x2,y1,x2,y2,color);
       Glib_Line(x1,y2,x2,y2,color);
       Glib_Line(x1,y1,x1,y2,color);
}

/**************************************************************
在LCD屏幕上用颜色填充一个矩形
**************************************************************/
void Glib_FilledRectangle(int x1,int y1,int x2,int y2,int color)
{
       int i;

       for(i=y1;i<=y2;i++)
              Glib_Line(x1,i,x2,i,color);
}

/**************************************************************
在LCD屏幕上指定坐标点画一个指定大小的图片
**************************************************************/
void Paint_Bmp(int x0,int y0,int h,int l,unsigned char bmp[])
{
       int x,y;
       U32 c;
       int p = 0;
	
       for( y = y0 ; y < l ; y++ )
       {
              for( x = x0 ; x < h ; x++ )
              {
                     c = bmp[p+1] | (bmp[p]<<8) ;

                     if ( ( (x0+x) < SCR_XSIZE_TFT) && ( (y0+y) < SCR_YSIZE_TFT) )
                            LCD_BUFFER[y0+y][x0+x] = c ;
			
                     p = p + 2 ;
              }
       }
}

#if 0
/**************************************************************
在LCD屏幕上指定坐标点写ASCII码
**************************************************************/
void Lcd_PutASCII(unsigned int x,unsigned int y,unsigned char ch,unsigned int c,unsigned int bk_c,unsigned int st)
{
       unsigned short int i,j;
       unsigned char *pZK,mask,buf;
	
	

       pZK = &__VGA[ch*16];
       for( i = 0 ; i < 16 ; i++ )
       {
              mask = 0x80;
              buf = pZK[i];
              for( j = 0 ; j < 8 ; j++ )
              {
                     if( buf & mask )
                     {
                            PutPixel(x+j,y+i,c);
                     }
                     else
                     {
                            if( !st )
                            {
                                   PutPixel(x+j,y+i,bk_c);
                            }
                     }
            
                     mask = mask >> 1;
              }
       }
}

/**************************************************************
在LCD屏幕上指定坐标点写汉字
**************************************************************/
void Lcd_PutHZ(unsigned int x,unsigned int y,unsigned short int QW,unsigned int c,unsigned int bk_c,unsigned int st)
{
       unsigned short int i,j;
       unsigned char *pZK,mask,buf;

       pZK = &__CHS[ (  ( (QW >> 8) - 1 )*94 + (QW & 0x00FF)- 1 )*32 ];
       for( i = 0 ; i < 16 ; i++ )
       {
              //左
              mask = 0x80;
              buf = pZK[i*2];
              for( j = 0 ; j < 8 ; j++ )
              {
                     if( buf & mask )
                     {
                            PutPixel(x+j,y+i,c);
                     }
                     else
                     {
                            if( !st )
                            {
                                   PutPixel(x+j,y+i,bk_c);
                            }
                     }
                     mask = mask >> 1;
              } 
        
              //右
              mask = 0x80;
              buf = pZK[i*2 + 1];
              for( j = 0 ; j < 8 ; j++ )
              {
                     if( buf & mask )
                     {
                            PutPixel(x+j + 8,y+i,c);
                     }
                     else
                     {
                            if( !st )
                            {
                                   PutPixel(x+j + 8,y+i,bk_c);
                            }
                     }
                     mask = mask >> 1;
              }                 
       }
}

//----------------------
void Lcd_printf(unsigned int x,unsigned int y,unsigned int c,unsigned int bk_c,unsigned int st,char *fmt,...)
{
       char __LCD_Printf_Buf[256];
       va_list ap;
       unsigned char *pStr = (unsigned char *)__LCD_Printf_Buf;
       unsigned int i = 0;

       va_start(ap,fmt);
       vsprintf(__LCD_Printf_Buf,fmt,ap);
       va_end(ap);
	 
       while(*pStr != 0 )
       {
              switch(*pStr)
              {
                     case '\n' :
                            {
			
                                   break;
                            }

                     default:
                            {
                                   if( *pStr > 0xA0 & *(pStr+1) > 0xA0 )  //中文输出
                                   {
                                          Lcd_PutHZ( x , y , (*pStr - 0xA0)*0x0100 + *(pStr+1) - 0xA0 , c , bk_c , st);

                                          pStr++;
                                          i++;

                                          x += 16;
                                   }
                                   else               //英文输出
                                   {
                                          Lcd_PutASCII( x , y , *pStr , c , bk_c , st );

                                          x += 8;

                                   }

                                   break;
                            }
              }
		
              pStr++;
              i++;		

              if( i > 256 ) break;
       }
   
}
#endif

void Lcd_Display(void)
{
       Lcd_Init();
	
       Lcd_PowerEnable(0, 1);
       Lcd_EnvidOnOff(1);

       Lcd_ClearScr( (0x00<<11) | (0x00<<5) | (0x00) );  /*
       #if(LCD_TYPE == T35)
		Paint_Bmp(0, 0, 240, 320, TQ_LOGO_240320);
       #elif((LCD_TYPE == W35) || (LCD_TYPE == S35))
		Paint_Bmp(0, 0, 320, 240, phone);
       #elif(LCD_TYPE == W43)
		Paint_Bmp(0, 0, 480, 272, TQ_LOGO_480272);
       #elif(LCD_TYPE == VGA)
		Paint_Bmp(0, 0, 640, 480, VGA_ucos);
       #elif(LCD_TYPE == TFT70)
		Paint_Bmp(0, 0, 800, 480, TFT70_ucos);
       #endif*/
}

⌨️ 快捷键说明

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