【ESK32-360测评】+ TFT屏显示功能及扩展(2)
<p>2. 绘图函数的扩展</p><p>要实现绘图功能,首先是添加画点函数,然后是添加画线函数和区域填充函数。</p>
<p>添加的画点函数为:</p>
<pre>
<code class="language-cpp">void LCD_dotDraw(u16 X_Location, u16 Y_Location, u16 Color)
{
LCD_StarterSet(X_Location, Y_Location);
LCD_WriteRAMPrior();
LCD_WriteRAM(Color);
}</code></pre>
<p>添加的画线函数为:</p>
<pre>
<code class="language-cpp">void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2, u16 Color)
{
u16 t;
s16 xerr=0,yerr=0,delta_x,delta_y,distance;
u16 incx,incy,uRow,uCol;
delta_x=x2-x1;
delta_y=y2-y1;
uRow=x1;
uCol=y1;
if(delta_x>0)incx=1;
else if(delta_x==0)incx=0;
else { incx=-1; delta_x=-delta_x; }
if(delta_y>0)incy=1;
else if(delta_y==0)incy=0;
else { incy=-1; delta_y=-delta_y; }
if( delta_x>delta_y) distance=delta_x;
else distance=delta_y;
for(t=0;t<=distance+1;t++)
{
LCD_dotDraw(uRow,uCol,Color);
xerr+=delta_x ;
yerr+=delta_y ;
if(xerr>distance)
{
xerr-=distance;
uRow+=incx;
}
if(yerr>distance)
{
yerr-=distance;
uCol+=incy;
}
}
}</code></pre>
<p>添加的区域填充函数:</p>
<pre>
<code class="language-cpp">void LCD_fill(u16 x,u16 y,u16 Height,u16 Width,u16 Color)
{
u16 i,j;
for(j=0;j<Height;j++)
{
LCD_StarterSet(x,y);
LCD_WriteRAMPrior();
for (i = Width; i > 0; i--)
{
LCD_WriteRAM(Color);
}
x++;
}
}</code></pre>
<p>有了这3个函数,后面我们在进行A/D采集时就可以轻松地实现数据的波形显示,稍后见!</p>
<p>可以尝试移植个littlevgl呀,有画点函数了就够了</p>
宋元浩 发表于 2020-8-7 09:55
可以尝试移植个littlevgl呀,有画点函数了就够了
<p>以前接触的不多,后面了解一下。</p>
页:
[1]