mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-27 07:40:59 +00:00
refactor(legacy): separate QR rendering into a helper function
[no changelog]
This commit is contained in:
parent
6b76378d34
commit
023e0c8722
@ -876,34 +876,14 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last) {
|
|||||||
|
|
||||||
#define QR_MAX_VERSION 9
|
#define QR_MAX_VERSION 9
|
||||||
|
|
||||||
void layoutAddress(const char *address, const char *desc, bool qrcode,
|
static void renderQR(const char *text) {
|
||||||
bool ignorecase, const uint32_t *address_n,
|
|
||||||
size_t address_n_count, bool address_is_account) {
|
|
||||||
if (layoutLast != layoutAddress && layoutLast != layoutXPUBMultisig) {
|
|
||||||
layoutSwipe();
|
|
||||||
} else {
|
|
||||||
oledClear();
|
|
||||||
}
|
|
||||||
layoutLast = layoutAddress;
|
|
||||||
|
|
||||||
uint32_t addrlen = strlen(address);
|
|
||||||
if (qrcode) {
|
|
||||||
char address_upcase[addrlen + 1];
|
|
||||||
memset(address_upcase, 0, sizeof(address_upcase));
|
|
||||||
if (ignorecase) {
|
|
||||||
for (uint32_t i = 0; i < addrlen + 1; i++) {
|
|
||||||
address_upcase[i] = address[i] >= 'a' && address[i] <= 'z'
|
|
||||||
? address[i] + 'A' - 'a'
|
|
||||||
: address[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0};
|
uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0};
|
||||||
uint8_t tempdata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0};
|
uint8_t tempdata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0};
|
||||||
|
|
||||||
int side = 0;
|
int side = 0;
|
||||||
if (qrcodegen_encodeText(ignorecase ? address_upcase : address, tempdata,
|
if (qrcodegen_encodeText(text, tempdata, codedata, qrcodegen_Ecc_LOW,
|
||||||
codedata, qrcodegen_Ecc_LOW, qrcodegen_VERSION_MIN,
|
qrcodegen_VERSION_MIN, QR_MAX_VERSION,
|
||||||
QR_MAX_VERSION, qrcodegen_Mask_AUTO, true)) {
|
qrcodegen_Mask_AUTO, true)) {
|
||||||
side = qrcodegen_getSize(codedata);
|
side = qrcodegen_getSize(codedata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,6 +908,30 @@ void layoutAddress(const char *address, const char *desc, bool qrcode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 && layoutLast != layoutXPUBMultisig) {
|
||||||
|
layoutSwipe();
|
||||||
|
} else {
|
||||||
|
oledClear();
|
||||||
|
}
|
||||||
|
layoutLast = layoutAddress;
|
||||||
|
|
||||||
|
uint32_t addrlen = strlen(address);
|
||||||
|
if (qrcode) {
|
||||||
|
char address_upcase[addrlen + 1];
|
||||||
|
memset(address_upcase, 0, sizeof(address_upcase));
|
||||||
|
if (ignorecase) {
|
||||||
|
for (uint32_t i = 0; i < addrlen + 1; i++) {
|
||||||
|
address_upcase[i] = address[i] >= 'a' && address[i] <= 'z'
|
||||||
|
? address[i] + 'A' - 'a'
|
||||||
|
: address[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
renderQR(ignorecase ? address_upcase : address);
|
||||||
} else {
|
} else {
|
||||||
if (desc) {
|
if (desc) {
|
||||||
oledDrawString(0, 0 * 9, desc, FONT_STANDARD);
|
oledDrawString(0, 0 * 9, desc, FONT_STANDARD);
|
||||||
|
Loading…
Reference in New Issue
Block a user