mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 14:58:09 +00:00
fix(core/prodtest): fix prodtest build with NEW_RENDERING on
[no changelog]
This commit is contained in:
parent
e19138cdc8
commit
c0b295a9b1
@ -8,6 +8,7 @@ CMAKELISTS = int(ARGUMENTS.get('CMAKELISTS', 0))
|
|||||||
PRODUCTION = ARGUMENTS.get('PRODUCTION', '0') == '1'
|
PRODUCTION = ARGUMENTS.get('PRODUCTION', '0') == '1'
|
||||||
BOOTLOADER_DEVEL = ARGUMENTS.get('BOOTLOADER_DEVEL', '0') == '1'
|
BOOTLOADER_DEVEL = ARGUMENTS.get('BOOTLOADER_DEVEL', '0') == '1'
|
||||||
HW_REVISION = ARGUMENTS.get('HW_REVISION', None)
|
HW_REVISION = ARGUMENTS.get('HW_REVISION', None)
|
||||||
|
NEW_RENDERING = ARGUMENTS.get('NEW_RENDERING', '1') == '1'
|
||||||
|
|
||||||
if TREZOR_MODEL in ('DISC1', 'DISC2'):
|
if TREZOR_MODEL in ('DISC1', 'DISC2'):
|
||||||
# skip prodtest build
|
# skip prodtest build
|
||||||
@ -22,6 +23,9 @@ if TREZOR_MODEL in ('DISC1', 'DISC2'):
|
|||||||
|
|
||||||
FEATURES_WANTED = ["input", "sbu", "sd_card", "rdb_led", "usb", "consumption_mask", "optiga", "haptic"]
|
FEATURES_WANTED = ["input", "sbu", "sd_card", "rdb_led", "usb", "consumption_mask", "optiga", "haptic"]
|
||||||
|
|
||||||
|
if NEW_RENDERING:
|
||||||
|
FEATURES_WANTED.append("new_rendering")
|
||||||
|
|
||||||
CCFLAGS_MOD = ''
|
CCFLAGS_MOD = ''
|
||||||
CPPPATH_MOD = []
|
CPPPATH_MOD = []
|
||||||
CPPDEFINES_MOD = [
|
CPPDEFINES_MOD = [
|
||||||
@ -100,11 +104,14 @@ CPPPATH_MOD += [
|
|||||||
|
|
||||||
SOURCE_MOD += [
|
SOURCE_MOD += [
|
||||||
'embed/lib/colors.c',
|
'embed/lib/colors.c',
|
||||||
'embed/lib/display_draw.c',
|
|
||||||
'embed/lib/display_utils.c',
|
'embed/lib/display_utils.c',
|
||||||
'embed/lib/error_handling.c',
|
'embed/lib/error_handling.c',
|
||||||
'embed/lib/fonts/font_bitmap.c',
|
'embed/lib/fonts/font_bitmap.c',
|
||||||
'embed/lib/fonts/fonts.c',
|
'embed/lib/fonts/fonts.c',
|
||||||
|
'embed/lib/gfx_color.c',
|
||||||
|
'embed/lib/gfx_bitblt_rgb565.c',
|
||||||
|
'embed/lib/gfx_bitblt_rgba8888.c',
|
||||||
|
'embed/lib/gfx_bitblt_mono8.c',
|
||||||
'embed/lib/image.c',
|
'embed/lib/image.c',
|
||||||
'embed/lib/mini_printf.c',
|
'embed/lib/mini_printf.c',
|
||||||
'embed/lib/qr-code-generator/qrcodegen.c',
|
'embed/lib/qr-code-generator/qrcodegen.c',
|
||||||
@ -114,6 +121,18 @@ SOURCE_MOD += [
|
|||||||
'vendor/micropython/lib/uzlib/tinflate.c',
|
'vendor/micropython/lib/uzlib/tinflate.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
if NEW_RENDERING:
|
||||||
|
CPPDEFINES_MOD += ['NEW_RENDERING']
|
||||||
|
SOURCE_MOD += [
|
||||||
|
'embed/lib/gfx_draw.c',
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
SOURCE_MOD += [
|
||||||
|
'embed/lib/display_draw.c',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
tools.add_font('NORMAL', FONT_NORMAL, CPPDEFINES_MOD, SOURCE_MOD)
|
||||||
tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
tools.add_font('BOLD', FONT_BOLD, CPPDEFINES_MOD, SOURCE_MOD)
|
||||||
|
@ -241,6 +241,53 @@ void gfx_draw_text(gfx_offset_t pos, const char* text, size_t maxlen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TREZOR_PRODTEST
|
||||||
|
|
||||||
|
#include "qr-code-generator/qrcodegen.h"
|
||||||
|
#define QR_MAX_VERSION 9
|
||||||
|
|
||||||
|
void gfx_draw_qrcode(int x, int y, uint8_t scale, const char* data) {
|
||||||
|
if (scale < 1 || scale > 10) return;
|
||||||
|
|
||||||
|
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(data, tempdata, codedata, qrcodegen_Ecc_MEDIUM,
|
||||||
|
qrcodegen_VERSION_MIN, QR_MAX_VERSION,
|
||||||
|
qrcodegen_Mask_AUTO, true)) {
|
||||||
|
side = qrcodegen_getSize(codedata);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate border size (1 extra modules around the QR code)
|
||||||
|
int border_side = ((side + 2) * scale);
|
||||||
|
|
||||||
|
// Calculate border left-top corner
|
||||||
|
x -= border_side / 2;
|
||||||
|
y -= border_side / 2;
|
||||||
|
|
||||||
|
// Fill the backround (including the border) with white color
|
||||||
|
gfx_rect_t border_rect = gfx_rect_wh(x, y, border_side, border_side);
|
||||||
|
gfx_draw_bar(border_rect, COLOR_WHITE);
|
||||||
|
|
||||||
|
// Center QR code inside the border
|
||||||
|
x += scale;
|
||||||
|
y += scale;
|
||||||
|
|
||||||
|
// Draw black modules
|
||||||
|
for (int i = 0; i < side; i++) {
|
||||||
|
for (int j = 0; j < side; j++) {
|
||||||
|
if (qrcodegen_getModule(codedata, i, j)) {
|
||||||
|
gfx_rect_t rect =
|
||||||
|
gfx_rect_wh(x + i * scale, y + j * scale, scale, scale);
|
||||||
|
gfx_draw_bar(rect, COLOR_BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TREZOR_PRODTEST
|
||||||
|
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
// emulation of legacy functions
|
// emulation of legacy functions
|
||||||
|
|
||||||
@ -274,3 +321,9 @@ void display_text_center(int x, int y, const char* text, int textlen, int font,
|
|||||||
int w = font_text_width(font, text, textlen);
|
int w = font_text_width(font, text, textlen);
|
||||||
gfx_draw_text(gfx_offset(x - w / 2, y), text, maxlen, &attr);
|
gfx_draw_text(gfx_offset(x - w / 2, y), text, maxlen, &attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TREZOR_PRODTEST
|
||||||
|
void display_qrcode(int x, int y, const char* data, uint8_t scale) {
|
||||||
|
gfx_draw_qrcode(x, y, scale, data);
|
||||||
|
}
|
||||||
|
#endif // TREZOR_PRODTEST
|
||||||
|
@ -150,4 +150,13 @@ void gfx_draw_bitmap(gfx_rect_t rect, const gfx_bitmap_t* bitmap);
|
|||||||
void gfx_draw_text(gfx_offset_t offset, const char* text, size_t maxlen,
|
void gfx_draw_text(gfx_offset_t offset, const char* text, size_t maxlen,
|
||||||
const gfx_text_attr_t* attr);
|
const gfx_text_attr_t* attr);
|
||||||
|
|
||||||
|
#ifdef TREZOR_PRODTEST
|
||||||
|
// Draws a QR code to the specified position.
|
||||||
|
//
|
||||||
|
// `x`, `y` - center of the QR code
|
||||||
|
// `scale` - size of a single QR code module
|
||||||
|
// `data` - utf-8 text
|
||||||
|
void gfx_draw_qrcode(int x, int y, uint8_t scale, const char* data);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // GFX_DRAW_H
|
#endif // GFX_DRAW_H
|
||||||
|
@ -831,6 +831,7 @@ int main(void) {
|
|||||||
display_qrcode(DISPLAY_RESX / 2, DISPLAY_RESY / 2, dom, 4);
|
display_qrcode(DISPLAY_RESX / 2, DISPLAY_RESY / 2, dom, 4);
|
||||||
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 30, dom + 8, -1,
|
display_text_center(DISPLAY_RESX / 2, DISPLAY_RESY - 30, dom + 8, -1,
|
||||||
FONT_BOLD, COLOR_WHITE, COLOR_BLACK);
|
FONT_BOLD, COLOR_WHITE, COLOR_BLACK);
|
||||||
|
display_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
display_fade(0, BACKLIGHT_NORMAL, 1000);
|
display_fade(0, BACKLIGHT_NORMAL, 1000);
|
||||||
|
Loading…
Reference in New Issue
Block a user