mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-28 18:38:39 +00:00
vendor: replace vendor/trezor-qrenc with vendor/QR-Code-generator
This commit is contained in:
parent
92382d3f2c
commit
79e9ae28b7
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -4,9 +4,6 @@
|
|||||||
[submodule "trezor-common"]
|
[submodule "trezor-common"]
|
||||||
path = vendor/trezor-common
|
path = vendor/trezor-common
|
||||||
url = https://github.com/trezor/trezor-common.git
|
url = https://github.com/trezor/trezor-common.git
|
||||||
[submodule "trezor-qrenc"]
|
|
||||||
path = vendor/trezor-qrenc
|
|
||||||
url = https://github.com/trezor/trezor-qrenc.git
|
|
||||||
[submodule "libopencm3"]
|
[submodule "libopencm3"]
|
||||||
path = vendor/libopencm3
|
path = vendor/libopencm3
|
||||||
url = https://github.com/libopencm3/libopencm3.git
|
url = https://github.com/libopencm3/libopencm3.git
|
||||||
@ -16,3 +13,6 @@
|
|||||||
[submodule "vendor/trezor-storage"]
|
[submodule "vendor/trezor-storage"]
|
||||||
path = vendor/trezor-storage
|
path = vendor/trezor-storage
|
||||||
url = https://github.com/trezor/trezor-storage.git
|
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
|
||||||
|
@ -72,7 +72,7 @@ CFLAGS += $(OPTFLAGS) \
|
|||||||
-I$(TOP_DIR) \
|
-I$(TOP_DIR) \
|
||||||
-I$(TOP_DIR)gen \
|
-I$(TOP_DIR)gen \
|
||||||
-I$(TOP_DIR)vendor/trezor-crypto \
|
-I$(TOP_DIR)vendor/trezor-crypto \
|
||||||
-I$(TOP_DIR)vendor/trezor-qrenc \
|
-I$(TOP_DIR)vendor/QR-Code-generator/c \
|
||||||
-I$(TOP_DIR)vendor/trezor-storage
|
-I$(TOP_DIR)vendor/trezor-storage
|
||||||
|
|
||||||
LDFLAGS += -L$(TOP_DIR) \
|
LDFLAGS += -L$(TOP_DIR) \
|
||||||
|
@ -82,7 +82,7 @@ OBJS += ../vendor/trezor-crypto/chacha20poly1305/rfc7539.o
|
|||||||
|
|
||||||
OBJS += ../vendor/trezor-crypto/nem.o
|
OBJS += ../vendor/trezor-crypto/nem.o
|
||||||
|
|
||||||
OBJS += ../vendor/trezor-qrenc/qr_encode.o
|
OBJS += ../vendor/QR-Code-generator/c/qrcodegen.o
|
||||||
|
|
||||||
OBJS += ../vendor/trezor-storage/storage.o
|
OBJS += ../vendor/trezor-storage/storage.o
|
||||||
OBJS += ../vendor/trezor-storage/norcow.o
|
OBJS += ../vendor/trezor-storage/norcow.o
|
||||||
@ -117,7 +117,6 @@ DEBUG_LOG ?= 0
|
|||||||
|
|
||||||
CFLAGS += -Wno-sequence-point
|
CFLAGS += -Wno-sequence-point
|
||||||
CFLAGS += -I../vendor/nanopb -Iprotob -DPB_FIELD_16BIT=1
|
CFLAGS += -I../vendor/nanopb -Iprotob -DPB_FIELD_16BIT=1
|
||||||
CFLAGS += -DQR_MAX_VERSION=0
|
|
||||||
CFLAGS += -DDEBUG_LINK=$(DEBUG_LINK)
|
CFLAGS += -DDEBUG_LINK=$(DEBUG_LINK)
|
||||||
CFLAGS += -DDEBUG_LOG=$(DEBUG_LOG)
|
CFLAGS += -DDEBUG_LOG=$(DEBUG_LOG)
|
||||||
CFLAGS += -DSCM_REVISION='"$(shell git rev-parse HEAD | sed 's:\(..\):\\x\1:g')"'
|
CFLAGS += -DSCM_REVISION='"$(shell git rev-parse HEAD | sed 's:\(..\):\\x\1:g')"'
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "bitmaps.h"
|
#include "bitmaps.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "qr_encode.h"
|
#include "qrcodegen.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "bignum.h"
|
#include "bignum.h"
|
||||||
#include "secp256k1.h"
|
#include "secp256k1.h"
|
||||||
@ -553,6 +553,8 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last)
|
|||||||
oledRefresh();
|
oledRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define QR_MAX_VERSION 9
|
||||||
|
|
||||||
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase, const uint32_t *address_n, size_t address_n_count, bool address_is_account)
|
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase, const uint32_t *address_n, size_t address_n_count, bool address_is_account)
|
||||||
{
|
{
|
||||||
if (layoutLast != layoutAddress) {
|
if (layoutLast != layoutAddress) {
|
||||||
@ -564,7 +566,6 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
|
|||||||
|
|
||||||
uint32_t addrlen = strlen(address);
|
uint32_t addrlen = strlen(address);
|
||||||
if (qrcode) {
|
if (qrcode) {
|
||||||
static unsigned char bitdata[QR_MAX_BITDATA];
|
|
||||||
char address_upcase[addrlen + 1];
|
char address_upcase[addrlen + 1];
|
||||||
if (ignorecase) {
|
if (ignorecase) {
|
||||||
for (uint32_t i = 0; i < addrlen + 1; i++) {
|
for (uint32_t i = 0; i < addrlen + 1; i++) {
|
||||||
@ -572,16 +573,28 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
|
|||||||
address[i] + 'A' - 'a' : address[i];
|
address[i] + 'A' - 'a' : address[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int side = qr_encode(addrlen <= (ignorecase ? 60 : 40) ? QR_LEVEL_M : QR_LEVEL_L, 0,
|
uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)];
|
||||||
ignorecase ? address_upcase : address, 0, bitdata);
|
uint8_t tempdata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)];
|
||||||
|
|
||||||
|
int side = 0;
|
||||||
|
if (qrcodegen_encodeText(
|
||||||
|
ignorecase ? address_upcase : address,
|
||||||
|
tempdata,
|
||||||
|
codedata,
|
||||||
|
qrcodegen_Ecc_LOW,
|
||||||
|
qrcodegen_VERSION_MIN,
|
||||||
|
QR_MAX_VERSION,
|
||||||
|
qrcodegen_Mask_AUTO,
|
||||||
|
true)) {
|
||||||
|
side = qrcodegen_getSize(codedata);
|
||||||
|
}
|
||||||
|
|
||||||
oledInvert(0, 0, 63, 63);
|
oledInvert(0, 0, 63, 63);
|
||||||
if (side > 0 && side <= 29) {
|
if (side > 0 && side <= 29) {
|
||||||
int offset = 32 - side;
|
int offset = 32 - side;
|
||||||
for (int i = 0; i < side; i++) {
|
for (int i = 0; i < side; i++) {
|
||||||
for (int j = 0; j< side; j++) {
|
for (int j = 0; j< side; j++) {
|
||||||
int a = j * side + i;
|
if (qrcodegen_getModule(codedata, i, j)) {
|
||||||
if (bitdata[a / 8] & (1 << (7 - a % 8))) {
|
|
||||||
oledBox(offset + i * 2, offset + j * 2,
|
oledBox(offset + i * 2, offset + j * 2,
|
||||||
offset + 1 + i * 2, offset + 1 + j * 2, false);
|
offset + 1 + i * 2, offset + 1 + j * 2, false);
|
||||||
}
|
}
|
||||||
@ -591,8 +604,7 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
|
|||||||
int offset = 32 - (side / 2);
|
int offset = 32 - (side / 2);
|
||||||
for (int i = 0; i < side; i++) {
|
for (int i = 0; i < side; i++) {
|
||||||
for (int j = 0; j< side; j++) {
|
for (int j = 0; j< side; j++) {
|
||||||
int a = j * side + i;
|
if (qrcodegen_getModule(codedata, i, j)) {
|
||||||
if (bitdata[a / 8] & (1 << (7 - a % 8))) {
|
|
||||||
oledClearPixel(offset + i, offset + j);
|
oledClearPixel(offset + i, offset + j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
vendor/QR-Code-generator
vendored
Submodule
1
vendor/QR-Code-generator
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 40d24f38aa0a8180b271b6c88be8633f842ed9d4
|
1
vendor/trezor-qrenc
vendored
1
vendor/trezor-qrenc
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit 4da44cacb7bd69aa297bafe4a41c498a050225a4
|
|
Loading…
Reference in New Issue
Block a user