主函数
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "qrencode.h"
#include "qr_encode.h"
const u8 QRcontent[]={"https://shop155026927.taobao.com/?spm=a230r.7195193.1997079397.2.58b92aa9OM6NCL"};
#define QRCODE_Y 80
void DISPLAY_RENCODE_TO_TFT(u8 *qrcode_data);
int main(void)
{
u8 i;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
delay_init();
uart_init(115200);
LED_Init();
LCD_Init();
POINT_COLOR=RED;
LCD_Clear(WHITE);
DISPLAY_RENCODE_TO_TFT((u8 *)QRcontent);
while(1)
{
printf("请发送您需要显示的字符串,以 \\r\\n 结束\r\n");
if(USART_RX_STA&0x8000)
{
printf("您发送的数据为:%s\r\n",USART_RX_BUF);
LCD_Clear(WHITE);
DISPLAY_RENCODE_TO_TFT((u8 *)USART_RX_BUF);
for(i=0;i<=200;i++)
USART_RX_BUF[i]=0;
USART_RX_STA = 0;
}
delay_ms(300);
}
}
void DISPLAY_RENCODE_TO_TFT(u8 *qrcode_data)
{
u8 i,j;
u16 x,y,p;
u8 stringBUFF[30];
EncodeData((char *)qrcode_data);
sprintf((char*)stringBUFF,"code size:%dx%d",m_nSymbleSize,m_nSymbleSize);
printf((char*)stringBUFF);
printf("\r\n\r\n");
LCD_ShowString(10,25,200,100,16,stringBUFF);
if(m_nSymbleSize*2>240)
{
LCD_ShowString(10,45,200,100,16,(u8 *)"too big");
return;
}
for(i=0;i<10;i++)
{
if((m_nSymbleSize*i*2)>240) break;
}
p = (i-1)*2;
x = (240-m_nSymbleSize*p)/2;
y = QRCODE_Y;
sprintf((char*)stringBUFF,"Each point:%dx%d",m_nSymbleSize,m_nSymbleSize);
printf((char*)stringBUFF);
printf("\r\n\r\n");
LCD_ShowString(10,45,200,100,16,stringBUFF);
for(i=0;i<m_nSymbleSize;i++)
{
for(j=0;j<m_nSymbleSize;j++)
{
if(m_byModuleData[i][j]==1)
{
LCD_Color_Fill(x+p*i,y+p*j,x+p*(i+1)-1,y+p*(j+1)-1, BLACK);
printf("▇");
}
else
{
printf(" ");
}
}
printf("\r\n");
}
}
Qcode源码链接:
Q_Code源码链接 提取码:7f8l