打印

GD32F450的LTI和API的Demo程序中只是对图片进行显示,对点、线等画图函数没有体现

[复制链接]
377|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hualiangjia|  楼主 | 2020-10-29 15:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
GD32F450IGHT6的LTI和API的Demo程序中只是对图片进行显示,对点、线等画图函数没有体现,请问谁有关于这些代码修改的例程

使用特权

评论回复
沙发
guijial511| | 2020-10-29 22:21 | 只看该作者
点、线、圆等基础图形的算法都是通用的,可以参考GUI的函数或者正点原子的例子,只需要提供显示控制接口函数。

使用特权

评论回复
板凳
chenjun89| | 2020-10-29 22:34 | 只看该作者
一楼正解

使用特权

评论回复
地板
castle520| | 2020-11-11 19:58 | 只看该作者
你好,分享一下画点画线写汉字等函数,其中blended_address_buffer数组即是TLI显示时使用的数组,其实只要知道画点,剩下的函数就比较简单了。


#include "gd32f4xx.h"
#include <stdio.h>
#include <gd_lcd.h>
#include <font.h>
#include "gd32f450i_eval.h"
#include "systick.h"
unsigned char temp =0;
uint16_t blended_address_buffer[96000];
uint16_t WHITE=0xFFff;                //白色
uint16_t BLACK =0x0000;          //黑色
uint16_t BLUE =0x001F;          //蓝色
void lcd_point_set(uint16_t xpos, uint16_t ypos, uint16_t color)        //画点
{
    *(__IO uint16_t*)(blended_address_buffer + ((480*ypos) + xpos)) = color;
}

//在指定位置显示一个字符
//x,y:起始坐标
//num:要显示的字符
void LCD_ShowChar(uint16_t xpos,uint16_t ypos,uint8_t num)
{                                                            
        unsigned int i,xpos_temp,ypos_temp=0;
        unsigned char line_x,line_xx,line_y=0;
  i=0;
        line_x =0;
        line_y =0;

        ypos_temp =ypos;
        xpos_temp =xpos;
        for(line_y=0;line_y<32;line_y++) //32  x  16
        {
                xpos =xpos_temp;
                for(line_xx=0;line_xx<2;line_xx++) //2*8bit =16bit 行写
                {                  
                        temp=char_buffer[num][i];
                        while(line_x < 8)
                        {
                                if(temp&0x80)  
                                {
                                        lcd_point_set(xpos,ypos,0x001f);
                                }
                                else
                                {
                                        lcd_point_set(xpos,ypos,0xffff);
                                }
                                xpos=xpos+1;
                                temp=temp<<1;
                                line_x++;
                        }
                        i++;
                        line_x =0;
                        temp =0;
                }
                ypos++;        //行
        }                    
}   

void show_num(uint16_t x, uint16_t y,int num_num)   //显示数字
{
                int a,b,c;
                if(num_num<10)
                {
                                LCD_ShowChar(x,y,num_num);
                }
                else if(num_num>=10&&num_num<100)
                {
                    
                    a=num_num%100/10;
                    b=num_num%10;

                                LCD_ShowChar(x,y,a);
                                delay_1ms(1);
                                LCD_ShowChar(x+16,y,b);
                }
                else if(num_num>=100)
                {
                    a=num_num/100;
                    b=num_num%100/10;
                    c=num_num%10;
                    LCD_ShowChar(x,y,a);
                                LCD_ShowChar(x+16,y,b);
                                LCD_ShowChar(x+32,y,c);
                }
}

void draw_line(uint16_t x1, uint16_t y1,uint16_t x2, uint16_t y2)       //画线
{
        uint16_t t;
        int xerr=0,yerr=0,delta_x,delta_y,distance;
        int 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_point_set(uRow,uCol,0x001f);//画点
                xerr+=delta_x ;
                yerr+=delta_y ;
                if(xerr>distance)
                {
                        xerr-=distance;
                        uRow+=incx;
                }
                if(yerr>distance)
                {
                        yerr-=distance;
                        uCol+=incy;
                }
        }  
}

void draw_font(uint16_t xpos, uint16_t ypos,unsigned char num)  //写汉字
{
        unsigned int i=0,xpos_temp,ypos_temp=0;
        unsigned char line_x,line_xx,line_y=0;
        unsigned char temp =0;
        line_x =0;
        line_y =0;
        ypos_temp =ypos;
        xpos_temp =xpos;
        for(line_y=0;line_y<32;line_y++) //32  x  32
        {
                xpos =xpos_temp;
                for(line_xx=0;line_xx<4;line_xx++) //4*8bit =32bit 行写
                {
                        temp=blended_address_buffer2[num][i];
                        while(line_x < 8)
                        {
                                if(temp&0x80)
                                {
                                        lcd_point_set(xpos,ypos,0x0000);
                                }
                                else
                                {
                                        lcd_point_set(xpos,ypos,0xffff);
                                }
                                xpos=xpos+1;
                                temp=temp<<1;
                                line_x++;
                        }
                        i++;
                        line_x =0;
                        temp =0;
                }
                ypos++;        //行
        }
}
void LCD_DrawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)//画矩形
{
        draw_line(x1,y1,x2,y1);
        draw_line(x1,y1,x1,y2);
        draw_line(x1,y2,x2,y2);
        draw_line(x2,y1,x2,y2);
}
void LCD_Draw_Circle(uint16_t x0,uint16_t y0,uint8_t r)                 //画圆
{
        int a,b;
        int di;
        a=0;b=r;          
        di=3-(r<<1);             //判断下个点位置的标志
        while(a<=b)
        {
                lcd_point_set(x0+a,y0-b,0x0000);             //5
                lcd_point_set(x0+b,y0-a,0x0000);             //0           
                lcd_point_set(x0+b,y0+a,0x0000);             //4               
                lcd_point_set(x0+a,y0+b,0x0000);             //6
                lcd_point_set(x0-a,y0+b,0x0000);             //1      
                lcd_point_set(x0-b,y0+a,0x0000);            
                lcd_point_set(x0-a,y0-b,0x0000);             //2            
          lcd_point_set(x0-b,y0-a,0x0000);             //7                     
                a++;
                //使用Bresenham算法画圆     
                if(di<0)di +=4*a+6;          
                else
                {
                        di+=10+4*(a-b);   
                        b--;
                }                                                     
        }
}

使用特权

评论回复
5
middle007| | 2020-11-25 17:54 | 只看该作者
IPA模块有bug. 填充功能会造成溢出. 无法正常使用

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

4

帖子

0

粉丝