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

📄 lcd_draw_graphic.c

📁 3c44B0实验箱上液晶屏的控制程序
💻 C
字号:
#include"def.h"
#include"LCD320.h"
#include"math.h"
#define GUISWAP(a, b) {a^=b; b^=a; a^=b;}
extern U32 LCDBuffer[LCDHEIGHT][LCDWIDTH];
/**********************************画点**********************************/
/*void LCD_PutPixel(s16 x,s16 y,u32 color)
 {
   LCDBuffer[x][y]=color; 
   //LCD_Refresh();  //是否及时刷新更改的像素点
  }*LCD320.c中有定义 /


/*********************************画水平线*******************************/
void Lcd_Draw_HLine(s16 usX0,s16 usX1,s16 usY0,u32 usColor,U16 usWidth)
{
 s16 usLen;
 if(usX1<usX0)
 {
  GUISWAP(usX1,usX0);
 }
 while((usWidth--)>0)
 {
  usLen=usX1-usX0+1;
  while((usLen--)>0)
  {
   LCD_PutPixel(usX0+usLen,usY0,usColor);
  }
 usY0++;
 }
}


/**********************************画垂直线********************************/
void Lcd_Draw_VLine(s16 usY0,s16 usY1,s16 usX0,u32 usColor,U16 usWidth)
{
 s16 usLen;
  if(usY1<usY0)
  {
   GUISWAP(usY1,usY0);
  }
  while((usWidth--)>0)
   {
    usLen=usY1-usY0+1;
    while((usLen--)>0)
    {
     LCD_PutPixel(usX0,usY0+usLen,usColor);
    }
    usX0++;
   }
  }

/*********************************画矩形框********************************/
void Lcd_Draw_Box(s16 usLeft,s16 usTop,s16 usRight,s16 usBottom,u32 usColor)
{ 
  Lcd_Draw_HLine(usLeft,usRight,usTop,usColor,1);
  Lcd_Draw_HLine(usLeft,usRight,usBottom,usColor,1);
  Lcd_Draw_VLine(usTop,usBottom,usLeft,usColor,1);
  Lcd_Draw_VLine(usTop,usBottom,usRight,usColor,1);
  //LCD_Refresh();
}

/********************************画矩形条*********************************/
void Lcd_Draw_Rectangle(s16 usLeft,s16 usTop,s16 usRight,s16 usBottom,u32 usColor)
{  int i,j;
   for(i=usTop;i<=usBottom;i++)
      { 
       for(j=usLeft;j<usRight;j++) 
          {
           LCDBuffer[i][j]=usColor;
          }
      }
   //LCD_Refresh();
} 
         
/**********************************画弧***********************************/
void LCD_Draw_Rad(s16 x0, s16 y0, s16 r, u32 usColor)
{u16 x1,y1,x;
 u16 i;
 x1=x0;
 y1=y0+r;
 LCD_PutPixel(x1,y1,usColor);
 for(i=0;i<r;i++)
  {y1--;
   x=(sqrt(r*r-(y1-y0)*(y1-y0)));
   x1=x0+x;
   LCD_PutPixel(x1,y1,usColor); 
  } 
}

⌨️ 快捷键说明

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