打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
嵌入式平台 STM32 libqrencode 移植 二维码生成


实验环境

硬件:STM32板 (STM32F207 )

     LCD12864 模块 (ST7565)

USB转串口模块 TTL

     ST-Link V2 调试

软件:MDK Keil v5.12

     PortHelper.exe 串口调试助手

实验目的

     在嵌入式平台上生成QR Code,LCD显示

实验步骤:


  1. 建立STM32工程,包括LCD显示或串口打印,使用MicroLIB

  1. https://github.com/fukuchi/libqrencode 下载源码 添加主文件夹下的 .h .c文件到工程,qrenc.c 不要添加
  2. 对所有.C文件做如下修改

    #if HAVE_CONFIG_H

    # include 'config.h'

    #endif

    改为

    # include 'config.h'

    添加 config.h文件,添加如下信息

/* Define to 1 if you have the `strdup' function. */

#define HAVE_STRDUP 0

 

/* Major version number */

#define MAJOR_VERSION 3

/* Micro version number */

#define MICRO_VERSION 0

/* Minor version number */

#define MINOR_VERSION 9

 

/* Define to the version of this package. */

#define PACKAGE_VERSION '3.9.0'

 

/* Version number of package */

//#define VERSION '3.9.0'

#define LIBQRENCODE_VERSION '3.9.0'

 

/* Define to empty if `const' does not conform to ANSI C. */

/* #undef const */

 

/* Define to `__inline__' or `__inline' if that's what the C compiler

calls it, or to nothing if 'inline' is not supported under any name. */

#ifndef __cplusplus

/* #undef inline */

#endif

 

/* Define to 'static' if no test programs will be compiled. */

#define __STATIC

#define WITH_TESTS 1

  1. 在Main.c中添加测试代码

#include 'qrencode.h'

#include 'qrspec.h'

#include 'mqrspec.h'

#include 'bitstream.h'

#include 'qrinput.h'

#include 'rsecc.h'

#include 'split.h'

#include 'mask.h'

#include 'mmask.h'

 

QRcode*qrcode; //最后结果

 

qrcode= QRcode_encodeString('sissi',2, QR_ECLEVEL_L, QR_MODE_8,0);

printf('====version=%d========\r\n',qrcode->version);

for(y=0;yqrcode->width;y++)

{

for(x=0;xqrcode->width;x++)

{

if(qrcode->data[y*qrcode->width+x]&0x01)

{

printf('#');

// LCM_SetPixel(x,y,1);

}

else

{

printf(' ');

// LCM_SetPixel(x,y,0);

}

}

printf('\r\n');

}

printf('\r\n');

 

//DISPLAY_RENCODE_TO_TFT(0,0,2);

QRcode_free(qrcode);

 

  1. 在startup_stm32f2xx.s中修改堆栈,太小了跑步起来qrcode->version都不对。

    改不了先去掉文件的只读权限

     

 

 

  1. 串口打印结果基本可以基本看到二维码图形

  1. QRcode结构体介绍

     

参考:

http://fukuchi.org/works/qrencode/

https://github.com/fukuchi/libqrencode

工程:

http://download.csdn.net/detail/nolnew/9376151


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
基于libqrencode的二维码生成
用QRCode生成带有中间logo图的二维码
tp5.1生成二维码
十几行代码,自己做一个二维码生成器,轻便好用
【Python自动化】如何使用Python批量生成二维码?
C# 二维码生成 ( QRCoder )
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服