1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-21 15:08:12 +00:00

vendor: replace vendor/trezor-qrenc with vendor/QR-Code-generator

This commit is contained in:
Pavol Rusnak 2019-02-16 17:36:08 +01:00
parent 6d817a813d
commit 4f28093d2e
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
11 changed files with 31 additions and 20 deletions

6
.gitmodules vendored
View File

@ -1,9 +1,6 @@
[submodule "vendor/trezor-crypto"]
path = vendor/trezor-crypto
url = https://github.com/trezor/trezor-crypto.git
[submodule "vendor/trezor-qrenc"]
path = vendor/trezor-qrenc
url = https://github.com/trezor/trezor-qrenc.git
[submodule "vendor/micropython"]
path = vendor/micropython
url = https://github.com/trezor/micropython.git
@ -16,3 +13,6 @@
[submodule "vendor/trezor-storage"]
path = vendor/trezor-storage
url = https://github.com/trezor/trezor-storage.git
[submodule "vendor/QR-Code-generator"]
path = vendor/QR-Code-generator
url = https://github.com/nayuki/QR-Code-generator.git

View File

@ -34,7 +34,6 @@ SOURCE_MOD += [
CPPDEFINES_MOD += [
'TREZOR_FONT_NORMAL_ENABLE',
'TREZOR_FONT_MONO_ENABLE',
('QR_MAX_VERSION', '0'),
]
SOURCE_MOD += [
'embed/extmod/modtrezorui/display.c',
@ -42,7 +41,7 @@ SOURCE_MOD += [
'embed/extmod/modtrezorui/font_bitmap.c',
'embed/extmod/modtrezorui/font_roboto_regular_20.c',
'embed/extmod/modtrezorui/font_robotomono_regular_20.c',
'embed/extmod/modtrezorui/trezor-qrenc/qr_encode.c',
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c',
]
SOURCE_STMHAL = [

View File

@ -97,7 +97,6 @@ CPPDEFINES_MOD += [
'TREZOR_FONT_NORMAL_ENABLE',
'TREZOR_FONT_MONO_ENABLE',
'TREZOR_FONT_MONO_BOLD_ENABLE',
('QR_MAX_VERSION', '0'),
]
SOURCE_MOD += [
'embed/extmod/modtrezorui/display.c',
@ -108,7 +107,7 @@ SOURCE_MOD += [
'embed/extmod/modtrezorui/font_robotomono_bold_20.c',
'embed/extmod/modtrezorui/font_robotomono_regular_20.c',
'embed/extmod/modtrezorui/modtrezorui.c',
'embed/extmod/modtrezorui/trezor-qrenc/qr_encode.c',
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c',
]
# modtrezorutils

View File

@ -18,14 +18,13 @@ SOURCE_MOD += [
# modtrezorui
CPPDEFINES_MOD += [
'TREZOR_FONT_BOLD_ENABLE',
('QR_MAX_VERSION', '0'),
]
SOURCE_MOD += [
'embed/extmod/modtrezorui/display.c',
'embed/extmod/modtrezorui/inflate.c',
'embed/extmod/modtrezorui/font_bitmap.c',
'embed/extmod/modtrezorui/font_roboto_bold_20.c',
'embed/extmod/modtrezorui/trezor-qrenc/qr_encode.c',
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c',
]
SOURCE_STMHAL = [

View File

@ -18,14 +18,13 @@ SOURCE_MOD += [
# modtrezorui
CPPDEFINES_MOD += [
'TREZOR_FONT_BOLD_ENABLE',
('QR_MAX_VERSION', '0'),
]
SOURCE_MOD += [
'embed/extmod/modtrezorui/display.c',
'embed/extmod/modtrezorui/inflate.c',
'embed/extmod/modtrezorui/font_bitmap.c',
'embed/extmod/modtrezorui/font_roboto_bold_20.c',
'embed/extmod/modtrezorui/trezor-qrenc/qr_encode.c',
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c',
]
SOURCE_STMHAL = [

View File

@ -94,7 +94,6 @@ CPPDEFINES_MOD += [
'TREZOR_FONT_NORMAL_ENABLE',
'TREZOR_FONT_MONO_ENABLE',
'TREZOR_FONT_MONO_BOLD_ENABLE',
('QR_MAX_VERSION', '0'),
]
SOURCE_MOD += [
'embed/extmod/modtrezorui/display.c',
@ -105,7 +104,7 @@ SOURCE_MOD += [
'embed/extmod/modtrezorui/font_robotomono_bold_20.c',
'embed/extmod/modtrezorui/font_robotomono_regular_20.c',
'embed/extmod/modtrezorui/modtrezorui.c',
'embed/extmod/modtrezorui/trezor-qrenc/qr_encode.c',
'embed/extmod/modtrezorui/qr-code-generator/qrcodegen.c',
]
if ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0):
CPPDEFINES_MOD += ['TREZOR_EMULATOR_NOUI']

View File

@ -32,7 +32,7 @@
#include "font_robotomono_bold_20.h"
#endif
#include "trezor-qrenc/qr_encode.h"
#include "qr-code-generator/qrcodegen.h"
#include "common.h"
#include "display.h"
@ -626,11 +626,28 @@ int display_text_width(const char *text, int textlen, int font)
return width;
}
#define QR_MAX_VERSION 9
void display_qrcode(int x, int y, const char *data, int datalen, uint8_t scale)
{
if (scale < 1 || scale > 10) return;
uint8_t bitdata[QR_MAX_BITDATA];
int side = qr_encode(QR_LEVEL_M, 0, data, datalen, bitdata);
uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)];
uint8_t tempdata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)];
int side = 0;
if (qrcodegen_encodeText(
data,
tempdata,
codedata,
qrcodegen_Ecc_MEDIUM,
qrcodegen_VERSION_MIN,
QR_MAX_VERSION,
qrcodegen_Mask_AUTO,
true)) {
side = qrcodegen_getSize(codedata);
}
x += DISPLAY_OFFSET.x - (side + 2) * scale / 2;
y += DISPLAY_OFFSET.y - (side + 2) * scale / 2;
int x0, y0, x1, y1;
@ -645,8 +662,7 @@ void display_qrcode(int x, int y, const char *data, int datalen, uint8_t scale)
PIXELDATA(0xFFFF);
continue;
}
int a = ry * side + rx;
if (bitdata[a / 8] & (1 << (7 - a % 8))) {
if (qrcodegen_getModule(codedata, rx, ry)) {
PIXELDATA(0x0000);
} else {
PIXELDATA(0xFFFF);

View File

@ -0,0 +1 @@
../../../vendor/QR-Code-generator/c

View File

@ -1 +0,0 @@
../../../vendor/trezor-qrenc

1
vendor/QR-Code-generator vendored Submodule

@ -0,0 +1 @@
Subproject commit 40d24f38aa0a8180b271b6c88be8633f842ed9d4

1
vendor/trezor-qrenc vendored

@ -1 +0,0 @@
Subproject commit 9344f23d869030fbe7261d3361862eaba12b9975