diff --git a/README.md b/README.md index b08b856..df681f8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # qrcode -[中文页](README_ZH.md) | English +[中文页](README_ZH.md) | English | [Offical](README_offical.md) ## 1 Introduction @@ -10,7 +10,8 @@ | Name | Description | | ---- | ---- | -| examples | Examples directory, and some corresponding instructions | +| samples | Examples directory, and some corresponding instructions | +| examples | Arduino | | inc | Header file directory | | src | Source Code Directory | diff --git a/README_ZH.md b/README_ZH.md index 4649ce6..6591d14 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,6 +1,6 @@ # qrcode -中文页 | [English](README.md) +中文页 | [English](README.md) | [官方文档](README_offical.md) ## 1、介绍 @@ -10,7 +10,8 @@ | 名称 | 说明 | | ---- | ---- | -| examples | 例子目录,并有相应的一些说明 | +| samples | 例子目录,并有相应的一些说明 | +| examples | Arduino 例程 | | inc | 头文件目录 | | src | 源代码目录 | diff --git a/README_offical.md b/README_offical.md new file mode 100644 index 0000000..8fe4c71 --- /dev/null +++ b/README_offical.md @@ -0,0 +1,677 @@ +QRCode +====== + +A simple library for generating [QR codes](https://en.wikipedia.org/wiki/QR_code) in C, +optimized for processing and memory constrained systems. + +**Features:** + +- Stack-based (no heap necessary; but you can use heap if you want) +- Low-memory foot print (relatively) +- Compile-time stripping of unecessary logic and constants +- MIT License; do with this as you please + + +Installing +---------- + +To install this library, download and save it to your Arduino libraries directory. + +Rename the directory to QRCode (if downloaded from GitHub, the filename may be +qrcode-master; library names may not contain the hyphen, so it must be renamed) + + +API +--- + +**Generate a QR Code** + +```c +// The structure to manage the QR code +QRCode qrcode; + +// Allocate a chunk of memory to store the QR code +uint8_t qrcodeBytes[qrcode_getBufferSize(3)]; + +qrcode_initText(&qrcode, qrcodeBytes, 3, ECC_LOW, "HELLO WORLD"); +``` + +**Draw a QR Code** + +How a QR code is used will vary greatly from project to project. For example: + +- Display on an OLED screen (128x64 nicely supports 2 side-by-side version 3 QR codes) +- Print as a bitmap on a thermal printer +- Store as a BMP (or with a some extra work, possibly a PNG) on an SD card + +The following example prints a QR code to the Serial Monitor (it likely will +not be scannable, but is just for demonstration purposes). + +```c +for (uint8_t y = 0; y < qrcode.size; y++) { + for (uint8_t x = 0; x < qrcode.size; x++) { + if (qrcode_getModule(&qrcode, x, y)) { + Serial.print("**"); + } else { + Serial.print(" "); + } + } + Serial.print("\n"); +} +``` + + +What is Version, Error Correction and Mode? +------------------------------------------- + +A QR code is composed of many little squares, called **modules**, which represent +encoded data, with additional error correction (allowing partially damaged QR +codes to still be read). + +The **version** of a QR code is a number between 1 and 40 (inclusive), which indicates +the size of the QR code. The width and height of a QR code are always equal (it is +square) and are equal to `4 * version + 17`. + +The level of **error correction** is a number between 0 and 3 (inclusive), or can be +one of the symbolic names ECC_LOW, ECC_MEDIUM, ECC_QUARTILE and ECC_HIGH. Higher +levels of error correction sacrifice data capacity, but allow a larger portion of +the QR code to be damaged or unreadable. + +The **mode** of a QR code is determined by the data being encoded. Each mode is encoded +internally using a compact representation, so lower modes can contain more data. + +- **NUMERIC:** numbers (`0-9`) +- **ALPHANUMERIC:** uppercase letters (`A-Z`), numbers (`0-9`), the space (` `), dollar sign (`$`), percent sign (`%`), asterisk (`*`), plus (`+`), minus (`-`), decimal point (`.`), slash (`/`) and colon (`:`). +- **BYTE:** any character + + +Data Capacities +--------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VersionSizeError CorrectionMode
NumericAlphanumericByte
121 x 21LOW412517
MEDIUM342014
QUARTILE271611
HIGH17107
225 x 25LOW774732
MEDIUM633826
QUARTILE482920
HIGH342014
329 x 29LOW1277753
MEDIUM1016142
QUARTILE774732
HIGH583524
433 x 33LOW18711478
MEDIUM1499062
QUARTILE1116746
HIGH825034
537 x 37LOW255154106
MEDIUM20212284
QUARTILE1448760
HIGH1066444
641 x 41LOW322195134
MEDIUM255154106
QUARTILE17810874
HIGH1398458
745 x 45LOW370224154
MEDIUM293178122
QUARTILE20712586
HIGH1549364
849 x 49LOW461279192
MEDIUM365221152
QUARTILE259157108
HIGH20212284
953 x 53LOW552335230
MEDIUM432262180
QUARTILE312189130
HIGH23514398
1057 x 57LOW652395271
MEDIUM513311213
QUARTILE364221151
HIGH288174119
1161 x 61LOW772468321
MEDIUM604366251
QUARTILE427259177
HIGH331200137
1265 x 65LOW883535367
MEDIUM691419287
QUARTILE489296203
HIGH374227155
1369 x 69LOW1022619425
MEDIUM796483331
QUARTILE580352241
HIGH427259177
1473 x 73LOW1101667458
MEDIUM871528362
QUARTILE621376258
HIGH468283194
1577 x 77LOW1250758520
MEDIUM991600412
QUARTILE703426292
HIGH530321220
1681 x 81LOW1408854586
MEDIUM1082656450
QUARTILE775470322
HIGH602365250
1785 x 85LOW1548938644
MEDIUM1212734504
QUARTILE876531364
HIGH674408280
1889 x 89LOW17251046718
MEDIUM1346816560
QUARTILE948574394
HIGH746452310
1993 x 93LOW19031153792
MEDIUM1500909624
QUARTILE1063644442
HIGH813493338
2097 x 97LOW20611249858
MEDIUM1600970666
QUARTILE1159702482
HIGH919557382
21101 x 101LOW22321352929
MEDIUM17081035711
QUARTILE1224742509
HIGH969587403
22105 x 105LOW240914601003
MEDIUM18721134779
QUARTILE1358823565
HIGH1056640439
23109 x 109LOW262015881091
MEDIUM20591248857
QUARTILE1468890611
HIGH1108672461
24113 x 113LOW281217041171
MEDIUM21881326911
QUARTILE1588963661
HIGH1228744511
25117 x 117LOW305718531273
MEDIUM23951451997
QUARTILE17181041715
HIGH1286779535
26121 x 121LOW328319901367
MEDIUM254415421059
QUARTILE18041094751
HIGH1425864593
27125 x 125LOW351721321465
MEDIUM270116371125
QUARTILE19331172805
HIGH1501910625
28129 x 129LOW366922231528
MEDIUM285717321190
QUARTILE20851263868
HIGH1581958658
29133 x 133LOW390923691628
MEDIUM303518391264
QUARTILE21811322908
HIGH16771016698
30137 x 137LOW415825201732
MEDIUM328919941370
QUARTILE23581429982
HIGH17821080742
31141 x 141LOW441726771840
MEDIUM348621131452
QUARTILE247314991030
HIGH18971150790
32145 x 145LOW468628401952
MEDIUM369322381538
QUARTILE267016181112
HIGH20221226842
33149 x 149LOW496530092068
MEDIUM390923691628
QUARTILE280517001168
HIGH21571307898
34153 x 153LOW525331832188
MEDIUM413425061722
QUARTILE294917871228
HIGH23011394958
35157 x 157LOW552933512303
MEDIUM434326321809
QUARTILE308118671283
HIGH23611431983
36161 x 161LOW583635372431
MEDIUM458827801911
QUARTILE324419661351
HIGH252415301051
37165 x 165LOW615337292563
MEDIUM477528941989
QUARTILE341720711423
HIGH262515911093
38169 x 169LOW647939272699
MEDIUM503930542099
QUARTILE359921811499
HIGH273516581139
39173 x 173LOW674340872809
MEDIUM531332202213
QUARTILE379122981579
HIGH292717741219
40177 x 177LOW708942962953
MEDIUM559633912331
QUARTILE399324201663
HIGH305718521273
+ + +Special Thanks +-------------- + +A HUGE thank you to [Project Nayuki](https://www.nayuki.io/) for the +[QR code C++ library](https://github.com/nayuki/QR-Code-generator/tree/master/cpp) +which was critical in development of this library. + + +License +------- + +MIT License.