|
|
@@ -1,28 +1,30 @@
|
|
|
# qrcode
|
|
|
|
|
|
-## 1、介绍
|
|
|
+[中文页](README_ZH.md) | English
|
|
|
|
|
|
-**qrcode** 是一个用于将字符串生成二维码的软件包。该软件包是 **RT-Thread** 基于 [ricmoo/QRCode](https://github.com/ricmoo/QRCode) 开源库的移植。
|
|
|
+## 1 Introduction
|
|
|
|
|
|
-### 1.1 目录结构
|
|
|
+**qrcode** is a software package used to generate a QR code from a string. This software package is a port of **RT-Thread** based on [ricmoo/QRCode](https://github.com/ricmoo/QRCode) open source library.
|
|
|
|
|
|
-| 名称 | 说明 |
|
|
|
+### 1.1 Directory structure
|
|
|
+
|
|
|
+| Name | Description |
|
|
|
| ---- | ---- |
|
|
|
-| examples | 例子目录,并有相应的一些说明 |
|
|
|
-| inc | 头文件目录 |
|
|
|
-| src | 源代码目录 |
|
|
|
+| examples | Examples directory, and some corresponding instructions |
|
|
|
+| inc | Header file directory |
|
|
|
+| src | Source Code Directory |
|
|
|
|
|
|
-### 1.2 许可证
|
|
|
+### 1.2 License
|
|
|
|
|
|
-`qrcode` 软件包延用 `QRCode` 软件包许可协议,请见 `qrcode/LICENSE` 文件。
|
|
|
+The `qrcode` software package extends the `QRCode` software package license agreement, please see the `qrcode/LICENSE` file.
|
|
|
|
|
|
-### 1.3 依赖
|
|
|
+### 1.3 Dependency
|
|
|
|
|
|
- RT-Thread 3.0+
|
|
|
|
|
|
-## 2、如何打开 qrcode
|
|
|
+## 2. How to open qrcode
|
|
|
|
|
|
-使用 qrcodepackage 需要在 RT-Thread 的包管理器中选择它,具体路径如下:
|
|
|
+To use qrcodepackage, you need to select it in the package manager of RT-Thread. The specific path is as follows:
|
|
|
|
|
|
```shell
|
|
|
RT-Thread online packages
|
|
|
@@ -31,64 +33,64 @@ RT-Thread online packages
|
|
|
[*] Enable qrcode sample
|
|
|
```
|
|
|
|
|
|
-- `Enable qrcode sample`: 开启二维码例程;
|
|
|
+- `Enable qrcode sample`: Enable QR code sample;
|
|
|
|
|
|
-然后让 RT-Thread 的包管理器自动更新,或者使用 `pkgs --update` 命令更新包到 BSP 中。
|
|
|
+Then let RT-Thread's package manager automatically update, or use the `pkgs --update` command to update the package to the BSP.
|
|
|
|
|
|
-## 3、使用 qrcode
|
|
|
+## 3. Use qrcode
|
|
|
|
|
|
-### 生成二维码
|
|
|
+### Generate QR code
|
|
|
|
|
|
-在使用 qrcode 软件包时首先要定义一个结构体来管理二维码,
|
|
|
+When using the qrcode software package, you must first define a structure to manage the QR code.
|
|
|
|
|
|
```c
|
|
|
QRCode qrcode;
|
|
|
```
|
|
|
|
|
|
-然后根据要版本号来申请动态内存,用来保存生成的二维码,
|
|
|
+Then apply for dynamic memory according to the version number to save the generated QR code,
|
|
|
|
|
|
```c
|
|
|
uint8_t *qrcodeBytes = (uint8_t *)rt_calloc(1, qrcode_getBufferSize(DEFAULT_QR_VERSION));
|
|
|
```
|
|
|
|
|
|
-最后使用二维码生成函数生成二维码。
|
|
|
+Finally, use the QR code generation function to generate the QR code.
|
|
|
|
|
|
```c
|
|
|
qrcode_initText(&qrcode, qrcodeBytes, DEFAULT_QR_VERSION, ECC_LOW, "HELLO WORLD");
|
|
|
```
|
|
|
|
|
|
-### 打印二维码
|
|
|
+### Print QR code
|
|
|
|
|
|
-生成的二维码是点阵数据,8个点构成一个 Byte。显示二维码可以使用以下代码
|
|
|
+The generated two-dimensional code is dot matrix data, 8 dots constitute a Byte. The following codes can be used to display the QR code
|
|
|
|
|
|
```c
|
|
|
-for (uint8 y = 0; y < qrcode.size; y++) {
|
|
|
- for (uint8 x = 0; x < qrcode.size; x++) {
|
|
|
+for (uint8 y = 0; y <qrcode.size; y++) {
|
|
|
+ for (uint8 x = 0; x <qrcode.size; x++) {
|
|
|
if (qrcode_getModule(&qrcode, x, y) {
|
|
|
rt_kprintf("**");
|
|
|
} else {
|
|
|
- rt_kprintf(" ");
|
|
|
+ rt_kprintf(" ");
|
|
|
}
|
|
|
}
|
|
|
Serial.print("\n");
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-## 4、示例演示
|
|
|
+## 4. Demo
|
|
|
|
|
|
-本示例需要在 qrcode 软件包中开启二维码例程。
|
|
|
+In this example, the QR code routine needs to be opened in the qrcode software package.
|
|
|
|
|
|
-在 MSH 中输入命令 qrcode RT-Thread,可以在串口助手上打印出一个二维码来,利用手机扫码软件扫描后可以看到结果为 RT-Thread。
|
|
|
+Enter the command qrcode RT-Thread in MSH, you can print out a QR code on the serial port assistant, scan it with the mobile phone code scanning software, you can see the result is RT-Thread.
|
|
|
|
|
|

|
|
|
|
|
|
-## 5、注意事项
|
|
|
+## 5. Matters needing attention
|
|
|
|
|
|
-- 在生成二维码时,使用的版本越高,需要申请的动态内存就越大。
|
|
|
-- 扫描串口助手上的二维码时,注意设置串口助手白底黑字。
|
|
|
-- 扫描串口助手上的二维码时,注意缩小文字显示,让*间的间距减小。
|
|
|
+- When generating a QR code, the higher the version used, the larger the dynamic memory that needs to be applied for.
|
|
|
+- When scanning the QR code on the serial port assistant, pay attention to setting the serial port assistant with black characters on a white background.
|
|
|
+- When scanning the QR code on the serial port assistant, pay attention to reducing the text display to reduce the space between *.
|
|
|
|
|
|
-## 6、联系方式 & 感谢
|
|
|
+## 6. Contact & Thanks
|
|
|
|
|
|
-* 维护:[qgyhd1234](https://github.com/qgyhd1234)
|
|
|
-* 主页:https://github.com/RT-Thread-packages/qrcode
|
|
|
+* Maintenance: [qgyhd1234](https://github.com/qgyhd1234)
|
|
|
+* Homepage: https://github.com/RT-Thread-packages/qrcode
|