查看: 7330|回复: 19

[原创] lpc1768显示二维码

[复制链接]
  • TA的每日心情
    开心
    2019-7-20 09:11
  • 签到天数: 7 天

    连续签到: 1 天

    [LV.3]偶尔看看II

    30

    主题

    104

    帖子

    0

    高级会员

    Rank: 4

    积分
    642
    最后登录
    2019-12-2
    发表于 2019-4-26 17:44:40 | 显示全部楼层 |阅读模式
    本帖最后由 wbeast 于 2019-4-26 17:55 编辑

    最近在同性交流网站github上看到一个开源动态显示二维码源码。移植在lpc1768上显示。
    源码来自:http://github.com/fukuchi/libqrencode,

    移植步骤:
       1、下载源码
       2、把以下的文件添加进来
    TIM截图20190426172346.png
      3、创建config.h文件。添加以下内容
    1. /* config.h.in.  Generated from configure.ac by autoheader.  */

    2. /* Define to 1 if you have the <dlfcn.h> header file. */
    3. #undef HAVE_DLFCN_H

    4. /* Define if you have the iconv() function and it works. */
    5. #undef HAVE_ICONV

    6. /* Define to 1 if you have the <inttypes.h> header file. */
    7. #undef HAVE_INTTYPES_H

    8. /* Define to 1 if using pthread is enabled. */
    9. #undef HAVE_LIBPTHREAD

    10. /* Define to 1 if you have the <memory.h> header file. */
    11. #undef HAVE_MEMORY_H

    12. /* Define to 1 if using libpng is enabled. */
    13. #undef HAVE_PNG

    14. /* Define to 1 if using SDL is enabled. */
    15. #undef HAVE_SDL

    16. /* Define to 1 if you have the <stdint.h> header file. */
    17. #undef HAVE_STDINT_H

    18. /* Define to 1 if you have the <stdlib.h> header file. */
    19. #undef HAVE_STDLIB_H

    20. /* Define to 1 if you have the `strdup' function. */
    21. #undef HAVE_STRDUP

    22. /* Define to 1 if you have the <strings.h> header file. */
    23. #undef HAVE_STRINGS_H

    24. /* Define to 1 if you have the <string.h> header file. */
    25. #undef HAVE_STRING_H

    26. /* Define to 1 if you have the <sys/stat.h> header file. */
    27. #undef HAVE_SYS_STAT_H

    28. /* Define to 1 if you have the <sys/types.h> header file. */
    29. #undef HAVE_SYS_TYPES_H

    30. /* Define to 1 if you have the <unistd.h> header file. */
    31. #undef HAVE_UNISTD_H

    32. /* Define to the sub-directory where libtool stores uninstalled libraries. */
    33. #undef LT_OBJDIR



    34. #define HAVE_STRDUP 0

    35. /* Major version number */

    36. #define MAJOR_VERSION 3

    37. /* Micro version number */

    38. #define MICRO_VERSION 0

    39. /* Minor version number */

    40. #define MINOR_VERSION 9

    41. /* Name of package */
    42. #undef PACKAGE

    43. /* Define to the address where bug reports for this package should be sent. */
    44. #undef PACKAGE_BUGREPORT

    45. /* Define to the full name of this package. */
    46. #undef PACKAGE_NAME

    47. /* Define to the full name and version of this package. */
    48. #undef PACKAGE_STRING

    49. /* Define to the one symbol short name of this package. */
    50. #undef PACKAGE_TARNAME

    51. /* Define to the home page for this package. */
    52. #undef PACKAGE_URL

    53. /* Define to the version of this package. */
    54. #undef PACKAGE_VERSION

    55. /* Define to 1 if you have the ANSI C header files. */
    56. #undef STDC_HEADERS

    57. /* Version number of package */
    58. #define VERSION  "V4.01"

    59. /* Define to empty if `const' does not conform to ANSI C. */
    60. #undef const

    61. /* Define to `__inline__' or `__inline' if that's what the C compiler
    62.    calls it, or to nothing if 'inline' is not supported under any name.  */
    63. #ifndef __cplusplus
    64. #undef inline
    65. #endif

    66. /* Define to 'static' if no test programs will be compiled. */
    67. #define STATIC_IN_RELEASE static
    68. #undef WITH_TESTS
    69.    
    复制代码
         4、在keil中:需要options for Target中设置C/C++ define 选项:HAVE_CONFIG_H
          5、需要设置堆栈的大小:Stack_Size=200,Heap_Size=2000,
          6、只需要调用API函数QRcode_encodeString就可以,QRcode *QRcode_encodeString(const char *string, int version, QRecLevel            level,QRencodeMode hint, int casesensitive)
           string=输入数据,把数据写入二维码中,version=版本,QRecLevel=等级,
          返回:二维码数据,二维码宽度,以及版本信息   
         7、二维码显示
    1. /*********************************************************************************************************
    2. ** 函数名:    void QrCode_Display(uint16_t Xsta,uint16_t Ysta,uint16_t Width,uint16_t Hight,unsigned char *data)
    3. ** 函数函数功能:   显示二维码  可以放大显示二维码
    4. ** 输入参数:   Xsta =显示x轴起始位置,Ysta=显示Y轴起始位置,Width=显示宽度,Hight=显示高度,multiple=放大倍数,data=二维码数据
    5. ** 输出参数:   无
    6. ** 返回值:     无
    7. 放大显示原理:假如放大倍数是=3,会在一个点的数据X轴上画3次,Y轴自增加1,一个点的数据Y轴上画3次,依次类推
    8. 注意:显示尺寸不能大于LCD的尺寸(240X320)               
    9. *********************************************************************************************************/
    10. void QrCode_Display(uint16_t Xsta,uint16_t Ysta,uint16_t Width,uint16_t Hight,uint8_t  multiple,unsigned char *data){

    11.         uint16_t x=0,y=0,xx=0,yy=0;
    12.         
    13. for(y=0;y<Width;y++)//列

    14. {
    15. for(x=0;x<Hight;x++)//行
    16. {
    17.         for(yy=0;yy<multiple;yy++){//放大倍数
    18.                
    19.         for(xx=0;xx<multiple;xx++){//放大倍数

    20. if(data[y*Width+x]&0x01)
    21.   {
    22.   LCD_DrawPoint(Xsta+x*multiple+xx,Ysta+y*multiple+yy,Red);
    23.    
    24.                
    25.         
    26.   }
    27.    else

    28.   {
    29.   LCD_DrawPoint(Xsta+x*multiple+xx,Ysta+y*multiple+yy,White);

    30.   }
    31.         
    32.         
    33.      }
    34.    }        
    35.   }
    36. }

    37. }
    复制代码
    1244590596.jpg
    微信扫出来的数据:
    1784397692.jpg
    【11】LPC1768_LCD显示二维码.rar (241.58 KB, 下载次数: 45)
    哎...今天够累的,签到来了~
    回复

    使用道具 举报

    该用户从未签到

    3

    主题

    379

    帖子

    0

    高级会员

    Rank: 4

    积分
    805
    最后登录
    2020-9-5
    发表于 2019-4-27 09:25:36 | 显示全部楼层
    牛牛
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    昨天 22:51
  • 签到天数: 1847 天

    连续签到: 2 天

    [LV.Master]伴坛终老

    203

    主题

    3万

    帖子

    64

    超级版主

    Rank: 8Rank: 8

    积分
    112627
    最后登录
    2025-7-20
    发表于 2019-4-27 10:11:02 | 显示全部楼层
    支持一下
    该会员没有填写今日想说内容.
    回复

    使用道具 举报

  • TA的每日心情
    无聊
    2019-5-1 06:15
  • 签到天数: 5 天

    连续签到: 1 天

    [LV.2]偶尔看看I

    0

    主题

    91

    帖子

    0

    中级会员

    Rank: 3Rank: 3

    积分
    207
    最后登录
    2021-8-4
    发表于 2019-4-28 15:31:46 | 显示全部楼层
    谢谢分享
    该会员没有填写今日想说内容.
    回复

    使用道具 举报

    该用户从未签到

    3

    主题

    379

    帖子

    0

    高级会员

    Rank: 4

    积分
    805
    最后登录
    2020-9-5
    发表于 2019-5-22 14:59:57 | 显示全部楼层
    回复

    使用道具 举报

    该用户从未签到

    3

    主题

    379

    帖子

    0

    高级会员

    Rank: 4

    积分
    805
    最后登录
    2020-9-5
    发表于 2019-5-28 13:52:58 | 显示全部楼层
    感谢分享~~~~
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2019-7-20 09:11
  • 签到天数: 7 天

    连续签到: 1 天

    [LV.3]偶尔看看II

    30

    主题

    104

    帖子

    0

    高级会员

    Rank: 4

    积分
    642
    最后登录
    2019-12-2
     楼主| 发表于 2019-6-10 14:17:17 | 显示全部楼层
    二维码生成
    哎...今天够累的,签到来了~
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    3

    主题

    379

    帖子

    0

    高级会员

    Rank: 4

    积分
    805
    最后登录
    2020-9-5
    发表于 2019-6-11 10:36:32 | 显示全部楼层
    回复

    使用道具 举报

    该用户从未签到

    3

    主题

    379

    帖子

    0

    高级会员

    Rank: 4

    积分
    805
    最后登录
    2020-9-5
    发表于 2019-6-21 11:37:35 | 显示全部楼层
    回复

    使用道具 举报

    该用户从未签到

    3

    主题

    379

    帖子

    0

    高级会员

    Rank: 4

    积分
    805
    最后登录
    2020-9-5
    发表于 2019-6-27 09:44:51 | 显示全部楼层
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-7-21 02:59 , Processed in 0.109914 second(s), 28 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表