1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-26 15:20:58 +00:00

refactor(legacy): separate QR rendering into a helper function

[no changelog]
This commit is contained in:
Roman Zeyde 2025-01-08 15:13:58 +01:00 committed by Roman Zeyde
parent 6b76378d34
commit 023e0c8722

View File

@ -876,34 +876,14 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last) {
#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) {
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];
}
}
static void renderQR(const char *text) {
uint8_t codedata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0};
uint8_t tempdata[qrcodegen_BUFFER_LEN_FOR_VERSION(QR_MAX_VERSION)] = {0};
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)) {
if (qrcodegen_encodeText(text, tempdata, codedata, qrcodegen_Ecc_LOW,
qrcodegen_VERSION_MIN, QR_MAX_VERSION,
qrcodegen_Mask_AUTO, true)) {
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 {
if (desc) {
oledDrawString(0, 0 * 9, desc, FONT_STANDARD);