Skip to content

Commit 1232a43

Browse files
authored
Fix boot UI overlap && optimize GIF memory management (#405)
* fix: rectangle coordinate calculation in fb_fill_rect * fix: rename bc-only to btc in build name * refactor: consolidate progress bar visibility management * chore: update lvgl submodule
1 parent 659efd6 commit 1232a43

File tree

8 files changed

+77
-123
lines changed

8 files changed

+77
-123
lines changed

core/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ FIRMWARE_BUILD_VERSION=$(shell cat ./embed/firmware/version.h | grep -E '#define
5454
ifndef BUILD_ID
5555
BUILD_COMMIT=$(shell git rev-parse HEAD | cut -c1-7)
5656
ifeq ($(BITCOIN_ONLY), 1)
57-
FIRMWARE_BUILD_NAME=pro.$(FIRMWARE_BUILD_VERSION)-Stable-bc-only-$(BUILD_DATE)-$(BUILD_COMMIT)
58-
FIRMWARE_BUILD_ID=pro.$(FIRMWARE_BUILD_VERSION)-Stable-bc-only-$(BUILD_COMMIT)
57+
FIRMWARE_BUILD_NAME=pro.$(FIRMWARE_BUILD_VERSION)-Stable-btc-$(BUILD_DATE)-$(BUILD_COMMIT)
58+
FIRMWARE_BUILD_ID=pro.$(FIRMWARE_BUILD_VERSION)-Stable-btc-$(BUILD_COMMIT)
5959
else
6060
FIRMWARE_BUILD_NAME=pro.$(FIRMWARE_BUILD_VERSION)-Stable-$(BUILD_DATE)-$(BUILD_COMMIT)
6161
FIRMWARE_BUILD_ID=pro.$(FIRMWARE_BUILD_VERSION)-Stable-$(BUILD_COMMIT)

core/embed/bootloader/bootui.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ void ui_screen_confirm(char* title, char* note_l1, char* note_l2, char* note_l3,
360360
ui_confirm_cancel_buttons("Back", "OK", COLOR_BL_DARK, COLOR_BL_FAIL);
361361
}
362362

363+
static bool ui_progress_bar_visible = false;
364+
363365
void ui_screen_progress_bar_init(char* title, char* notes, int progress) {
364366
ui_statusbar_update();
365367
ui_logo_onekey();
@@ -373,16 +375,30 @@ void ui_screen_progress_bar_init(char* title, char* notes, int progress) {
373375
void ui_screen_progress_bar_prepare(char* title, char* notes) {
374376
ui_statusbar_update();
375377
ui_logo_onekey();
376-
ui_screen_progress_bar_update(title, notes, -1);
378+
ui_progress_bar_visible = true;
379+
if (title != NULL) {
380+
display_text_center(DISPLAY_RESX / 2, TITLE_OFFSET_Y, title, -1,
381+
FONT_PJKS_BOLD_38, COLOR_BL_FG, COLOR_BL_BG);
382+
}
383+
display_progress(notes ? notes : "Keep connected.", 0);
377384
}
378385

379386
void ui_screen_progress_bar_update(char* title, char* notes, int progress) {
387+
if (!ui_progress_bar_visible) {
388+
ui_fadeout();
389+
ui_statusbar_update();
390+
ui_logo_onekey();
391+
display_progress(notes ? notes : "Keep connected.", 0);
392+
ui_fadein();
393+
ui_progress_bar_visible = true;
394+
}
395+
380396
if (title != NULL) {
381397
display_text_center(DISPLAY_RESX / 2, TITLE_OFFSET_Y, title, -1,
382398
FONT_PJKS_BOLD_38, COLOR_BL_FG, COLOR_BL_BG);
383399
}
384400

385-
if ((progress >= 0) && (progress <= 100)) {
401+
if (progress >= 0 && progress <= 100) {
386402
if (progress > 0) {
387403
display_progress(NULL, progress);
388404
}
@@ -391,6 +407,8 @@ void ui_screen_progress_bar_update(char* title, char* notes, int progress) {
391407
}
392408
}
393409

410+
void ui_progress_bar_visible_clear(void) { ui_progress_bar_visible = false; }
411+
394412
void ui_screen_install_start(void) {
395413
ui_statusbar_update();
396414
ui_logo_onekey();
@@ -967,6 +985,8 @@ void ui_bootloader_first(const image_header* const hdr) {
967985
uint8_t se_state;
968986
char se_info[64] = {0};
969987

988+
ui_progress_bar_visible_clear();
989+
970990
static image_header* current_hdr = NULL;
971991

972992
if (current_hdr == NULL && hdr) {
@@ -1289,11 +1309,11 @@ void ui_bootloader_page_switch(const image_header* const hdr) {
12891309
}
12901310
}
12911311
} else if (ui_bootloader_page_current == 2) {
1292-
response = ui_input_poll(INPUT_PREVIOUS | INPUT_RESTART, false);
1293-
if (INPUT_PREVIOUS == response) {
1312+
response = ui_input_poll(INPUT_CANCEL | INPUT_CONFIRM, false);
1313+
if (INPUT_CANCEL == response) {
12941314
display_clear();
12951315
ui_bootloader_first(hdr);
1296-
} else if (INPUT_RESTART == response) {
1316+
} else if (INPUT_CONFIRM == response) {
12971317
device_burnin_test_clear_flag();
12981318
}
12991319
click_now = HAL_GetTick();

core/embed/bootloader/bootui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void ui_screen_confirm(char* title, char* note_l1, char* note_l2, char* note_l3,
5555
void ui_screen_progress_bar_init(char* title, char* notes, int progress);
5656
void ui_screen_progress_bar_prepare(char* title, char* notes);
5757
void ui_screen_progress_bar_update(char* msg_status, char* notes, int progress);
58+
void ui_progress_bar_visible_clear(void);
5859

5960
void ui_screen_wipe_confirm(void);
6061
void ui_screen_wipe(void);

core/embed/bootloader/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ static secbool bootloader_usb_loop(const vendor_header* const vhdr,
388388
// give a way to go back to bootloader home page
389389
if (get_ui_bootloader_page_current() != 0) {
390390
ble_power_button_state_clear();
391-
ui_progress_bar_visible_clear();
392391
ui_fadeout();
393392
ui_bootloader_first(NULL);
394393
ui_fadein();

core/embed/emmc_wrapper/emmc_commands.c

Lines changed: 42 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,52 @@
11
#include "emmc_commands.h"
22
#include "emmc_commands_macros.h"
33

4+
#include "bootui.h"
45
#include "fw_keys.h"
56
#include "se_thd89.h"
67
#include "thd89_boot.h"
78

89
// ######## global vars ########
910
// SDRAM BUFFER
1011
bootloader_buffer* bl_buffer = (bootloader_buffer*)FMC_SDRAM_BOOLOADER_BUFFER_ADDRESS;
11-
// UI progesss
12-
bool ui_progress_bar_visible = false;
1312

14-
// ######## helpers ########
13+
static int ui_progress_bar_handle_update(int percentage, const char* title)
14+
{
15+
static uint32_t ui_percentage_last = 0xff;
16+
char* progress_title = (char*)((title != NULL) ? title : "Transferring Data");
17+
18+
if ( (percentage < 0) || (percentage > 100) )
19+
{
20+
return -1;
21+
}
22+
23+
if ( ui_percentage_last == (uint32_t)percentage )
24+
{
25+
return 0;
26+
}
27+
28+
ui_percentage_last = (uint32_t)percentage;
29+
30+
if ( percentage < 100 )
31+
{
32+
ui_screen_progress_bar_update(progress_title, NULL, percentage);
33+
}
34+
else
35+
{
36+
ui_screen_progress_bar_update(progress_title, NULL, percentage);
37+
ui_fadeout();
38+
ui_bootloader_first(NULL);
39+
ui_fadein();
40+
}
1541

16-
void ui_progress_bar_visible_clear()
42+
return 0;
43+
}
44+
45+
static void ui_progress_bar_handle_clear(void)
1746
{
18-
ui_progress_bar_visible = false;
47+
ui_progress_bar_visible_clear();
48+
display_clear();
49+
ui_bootloader_first(NULL);
1950
}
2051

2152
static void packet_generate_first(
@@ -1701,58 +1732,16 @@ int process_msg_EmmcFileRead(uint8_t iface_num, uint32_t msg_size, uint8_t* buf)
17011732
// (requester intersted) size
17021733
if ( msg_recv.has_ui_percentage )
17031734
{
1704-
char ui_progress_title[] = "Transferring Data";
1705-
1706-
// sanity check
1707-
if ( (msg_recv.ui_percentage < 0) || (msg_recv.ui_percentage > 100) )
1735+
const char* progress_title = "Transferring Data";
1736+
if ( ui_progress_bar_handle_update(msg_recv.ui_percentage, progress_title) != 0 )
17081737
{
17091738
send_failure(iface_num, FailureType_Failure_ProcessError, "Percentage invalid!");
17101739
return -1;
17111740
}
1712-
1713-
else if ( msg_recv.ui_percentage < 100 )
1714-
{
1715-
if ( !ui_progress_bar_visible )
1716-
{
1717-
ui_fadeout();
1718-
ui_screen_progress_bar_prepare(ui_progress_title, NULL);
1719-
ui_fadein();
1720-
ui_screen_progress_bar_update(NULL, NULL, msg_recv.ui_percentage);
1721-
ui_progress_bar_visible = true;
1722-
}
1723-
else
1724-
ui_screen_progress_bar_update(NULL, NULL, msg_recv.ui_percentage);
1725-
}
1726-
else if ( msg_recv.ui_percentage == 100 )
1727-
{
1728-
if ( !ui_progress_bar_visible )
1729-
{
1730-
// this is for the instant 100% case, which happens if the file is too
1731-
// small
1732-
ui_fadeout();
1733-
ui_screen_progress_bar_prepare(ui_progress_title, NULL);
1734-
ui_screen_progress_bar_update(NULL, NULL, msg_recv.ui_percentage);
1735-
ui_fadein();
1736-
}
1737-
else
1738-
{
1739-
// normal path
1740-
ui_screen_progress_bar_update(NULL, NULL, msg_recv.ui_percentage);
1741-
ui_progress_bar_visible = false;
1742-
}
1743-
ui_fadeout();
1744-
ui_bootloader_first(NULL);
1745-
ui_fadein();
1746-
}
17471741
}
17481742
else
17491743
{
1750-
if ( ui_progress_bar_visible )
1751-
{
1752-
ui_progress_bar_visible = false;
1753-
display_clear();
1754-
ui_bootloader_first(NULL);
1755-
}
1744+
ui_progress_bar_handle_clear();
17561745
}
17571746

17581747
// get file info
@@ -1853,69 +1842,16 @@ int process_msg_EmmcFileWrite(uint8_t iface_num, uint32_t msg_size, uint8_t* buf
18531842
// (requester intersted) size
18541843
if ( msg_recv.has_ui_percentage )
18551844
{
1856-
char ui_progress_title[] = "Transferring Data";
1857-
1858-
static uint32_t ui_percentage_last = 0xff;
1859-
1860-
// sanity check
1861-
if ( (msg_recv.ui_percentage < 0) || (msg_recv.ui_percentage > 100) )
1845+
const char* progress_title = "Transferring Data";
1846+
if ( ui_progress_bar_handle_update(msg_recv.ui_percentage, progress_title) != 0 )
18621847
{
18631848
send_failure(iface_num, FailureType_Failure_ProcessError, "Percentage invalid!");
18641849
return -1;
18651850
}
1866-
else if ( msg_recv.ui_percentage < 100 )
1867-
{
1868-
if ( ui_percentage_last != msg_recv.ui_percentage )
1869-
{
1870-
ui_percentage_last = msg_recv.ui_percentage;
1871-
if ( !ui_progress_bar_visible )
1872-
{
1873-
ui_fadeout();
1874-
ui_screen_progress_bar_prepare(ui_progress_title, NULL);
1875-
ui_fadein();
1876-
ui_screen_progress_bar_update(NULL, NULL, msg_recv.ui_percentage);
1877-
ui_progress_bar_visible = true;
1878-
}
1879-
else
1880-
{
1881-
ui_screen_progress_bar_update(NULL, NULL, msg_recv.ui_percentage);
1882-
}
1883-
}
1884-
}
1885-
else if ( msg_recv.ui_percentage == 100 )
1886-
{
1887-
if ( ui_percentage_last != msg_recv.ui_percentage )
1888-
{
1889-
ui_percentage_last = msg_recv.ui_percentage;
1890-
if ( !ui_progress_bar_visible )
1891-
{
1892-
// this is for the instant 100% case, which happens if the file is too
1893-
// small
1894-
ui_fadeout();
1895-
ui_screen_progress_bar_prepare(ui_progress_title, NULL);
1896-
ui_screen_progress_bar_update(NULL, NULL, msg_recv.ui_percentage);
1897-
ui_fadein();
1898-
}
1899-
else
1900-
{
1901-
// normal path
1902-
ui_screen_progress_bar_update(NULL, NULL, msg_recv.ui_percentage);
1903-
ui_progress_bar_visible = false;
1904-
}
1905-
ui_fadeout();
1906-
ui_bootloader_first(NULL);
1907-
ui_fadein();
1908-
}
1909-
}
19101851
}
19111852
else
19121853
{
1913-
if ( ui_progress_bar_visible )
1914-
{
1915-
ui_progress_bar_visible = false;
1916-
display_clear();
1917-
ui_bootloader_first(NULL);
1918-
}
1854+
ui_progress_bar_handle_clear();
19191855
}
19201856

19211857
// get file info

core/embed/emmc_wrapper/emmc_commands.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,8 @@ typedef struct
143143

144144
// ######## global vars ########
145145

146-
extern bool ui_progress_bar_visible;
147-
148146
// ######## functions ########
149147

150-
void ui_progress_bar_visible_clear();
151-
152148
// void packet_generate_first(
153149
// uint16_t msg_id, uint32_t msg_size, uint8_t* desc_buff, size_t desc_buff_offset, const uint8_t*
154150
// src_buff, size_t data_len

core/embed/extmod/modtrezorui/mipi_lcd.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,15 +468,17 @@ void fb_fill_rect(uint32_t x_pos, uint32_t y_pos, uint32_t width,
468468
}
469469
start_x = x_pos < lcd_window.start_x ? lcd_window.start_x : x_pos;
470470
start_y = y_pos < lcd_window.start_y ? lcd_window.start_y : y_pos;
471-
end_x = x_pos + width > lcd_window.end_x ? lcd_window.end_x : x_pos + width;
472-
end_y = y_pos + height > lcd_window.end_y ? lcd_window.end_y : y_pos + height;
471+
end_x = x_pos + width - 1;
472+
end_y = y_pos + height - 1;
473+
end_x = end_x > lcd_window.end_x ? lcd_window.end_x : end_x;
474+
end_y = end_y > lcd_window.end_y ? lcd_window.end_y : end_y;
473475
/* Get the rectangle start address */
474476
uint32_t address = lcd_params.fb_base +
475477
((lcd_params.bbp) * (lcd_params.hres * start_y + start_x));
476478

477479
/* Fill the rectangle */
478-
fb_fill_buffer((uint32_t*)address, end_x - start_x, end_y - start_y,
479-
(lcd_params.hres - (end_x - start_x)), color);
480+
fb_fill_buffer((uint32_t*)address, end_x - start_x + 1, end_y - start_y + 1,
481+
(lcd_params.hres - (end_x - start_x + 1)), color);
480482
}
481483

482484
void fb_draw_hline(uint32_t x_pos, uint32_t y_pos, uint32_t len,

vendor/lvgl_mp

Submodule lvgl_mp updated 1 file

0 commit comments

Comments
 (0)