From 11070c9e5e4340fb4bab43644cecbc287c88d17d Mon Sep 17 00:00:00 2001 From: gornekich Date: Wed, 22 May 2024 18:14:33 +0100 Subject: [PATCH 1/3] Text Box: fix displaying text with end text focus (#3658) * text box: fix reset text offset state after initial text iteration * debug: add tests for text box view debug app * hal: flash: removed redundant #else Co-authored-by: hedger --- .../text_box_view_test/text_box_view_test.c | 30 ++++++++++++++++++- applications/services/gui/modules/text_box.c | 3 +- targets/f7/furi_hal/furi_hal_flash.c | 1 - 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/applications/debug/text_box_view_test/text_box_view_test.c b/applications/debug/text_box_view_test/text_box_view_test.c index 4414835ec..7bbcb285b 100644 --- a/applications/debug/text_box_view_test/text_box_view_test.c +++ b/applications/debug/text_box_view_test/text_box_view_test.c @@ -18,6 +18,33 @@ static const TextBoxViewTestContent text_box_view_test_content_arr[] = { .focus = TextBoxFocusStart, .text = "Hello, let's test text box. Press Right and Left to switch content", }, + { + .font = TextBoxFontText, + .focus = TextBoxFocusEnd, + .text = "First test to add dynamically lines with EndFocus set\nLine 0", + }, + { + .font = TextBoxFontText, + .focus = TextBoxFocusEnd, + .text = "First test to add dynamically lines with EndFocus set\nLine 0\nLine 1", + }, + { + .font = TextBoxFontText, + .focus = TextBoxFocusEnd, + .text = "First test to add dynamically lines with EndFocus set\nLine 0\nLine 1\nLine 2", + }, + { + .font = TextBoxFontText, + .focus = TextBoxFocusEnd, + .text = + "First test to add dynamically lines with EndFocus set\nLine 0\nLine 1\nLine 2\nLine 3", + }, + { + .font = TextBoxFontText, + .focus = TextBoxFocusEnd, + .text = + "First test to add dynamically lines with EndFocus set\nLine 0\nLine 1\nLine 2\nLine 3\nLine 4", + }, { .font = TextBoxFontText, .focus = TextBoxFocusStart, @@ -57,7 +84,8 @@ typedef struct { } TextBoxViewTest; static void text_box_update_view(TextBoxViewTest* instance) { - text_box_reset(instance->text_box); + // Intentional incorrect way to reset text box to verify that state resets if text changes + text_box_set_text(instance->text_box, ""); const TextBoxViewTestContent* content = &text_box_view_test_content_arr[instance->current_content_i]; diff --git a/applications/services/gui/modules/text_box.c b/applications/services/gui/modules/text_box.c index 954847c65..c3bff00d0 100644 --- a/applications/services/gui/modules/text_box.c +++ b/applications/services/gui/modules/text_box.c @@ -227,14 +227,13 @@ static void text_box_prepare_model(Canvas* canvas, TextBoxModel* model) { text_box_seek_next_line(canvas, model); lines_num++; } while(!text_box_end_of_text_reached(model)); + model->text_offset = 0; lines_num++; if(model->focus == TextBoxFocusEnd) { if(lines_num > model->lines_on_screen) { model->text_offset = window_offset[(lines_num - 1) % model->lines_on_screen]; } - } else { - model->text_offset = 0; } if(lines_num > model->lines_on_screen) { diff --git a/targets/f7/furi_hal/furi_hal_flash.c b/targets/f7/furi_hal/furi_hal_flash.c index 43f80c61e..322a2e905 100644 --- a/targets/f7/furi_hal/furi_hal_flash.c +++ b/targets/f7/furi_hal/furi_hal_flash.c @@ -19,7 +19,6 @@ #ifdef FLASH_OP_DEBUG #undef FURI_LOG_T #define FURI_LOG_T(...) -#else #endif #define FURI_HAL_CRITICAL_MSG "Critical flash operation fail" From 8ba938cec13946080bf4283e8f8a58d2e12d191c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Wed, 22 May 2024 18:35:59 +0100 Subject: [PATCH 2/3] [FL-3775] Archive: fix condition race on exit (#3659) * Archive: fix condition race on exit * Format sources and remove debug logging --------- Co-authored-by: hedger --- applications/main/archive/archive.c | 3 +++ applications/main/archive/archive_i.h | 1 + .../archive/scenes/archive_scene_browser.c | 24 +++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/applications/main/archive/archive.c b/applications/main/archive/archive.c index 8dd934cc7..5db650445 100644 --- a/applications/main/archive/archive.c +++ b/applications/main/archive/archive.c @@ -16,6 +16,7 @@ ArchiveApp* archive_alloc(void) { ArchiveApp* archive = malloc(sizeof(ArchiveApp)); archive->gui = furi_record_open(RECORD_GUI); + archive->loader = furi_record_open(RECORD_LOADER); archive->text_input = text_input_alloc(); archive->fav_move_str = furi_string_alloc(); @@ -61,6 +62,8 @@ void archive_free(ArchiveApp* archive) { text_input_free(archive->text_input); + furi_record_close(RECORD_LOADER); + archive->loader = NULL; furi_record_close(RECORD_GUI); archive->gui = NULL; diff --git a/applications/main/archive/archive_i.h b/applications/main/archive/archive_i.h index d444aef8f..13b975a44 100644 --- a/applications/main/archive/archive_i.h +++ b/applications/main/archive/archive_i.h @@ -22,6 +22,7 @@ typedef enum { struct ArchiveApp { Gui* gui; + Loader* loader; ViewDispatcher* view_dispatcher; SceneManager* scene_manager; ArchiveBrowserView* browser; diff --git a/applications/main/archive/scenes/archive_scene_browser.c b/applications/main/archive/scenes/archive_scene_browser.c index 284e534ab..ba928c499 100644 --- a/applications/main/archive/scenes/archive_scene_browser.c +++ b/applications/main/archive/scenes/archive_scene_browser.c @@ -86,10 +86,8 @@ void archive_scene_browser_on_enter(void* context) { archive_update_focus(browser, archive->text_store); view_dispatcher_switch_to_view(archive->view_dispatcher, ArchiveViewBrowser); - Loader* loader = furi_record_open(RECORD_LOADER); - archive->loader_stop_subscription = - furi_pubsub_subscribe(loader_get_pubsub(loader), archive_loader_callback, archive); - furi_record_close(RECORD_LOADER); + archive->loader_stop_subscription = furi_pubsub_subscribe( + loader_get_pubsub(archive->loader), archive_loader_callback, archive); uint32_t state = scene_manager_get_scene_state(archive->scene_manager, ArchiveAppSceneBrowser); @@ -213,10 +211,11 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) { if(!archive_is_home(browser)) { archive_leave_dir(browser); } else { - Loader* loader = furi_record_open(RECORD_LOADER); - furi_pubsub_unsubscribe( - loader_get_pubsub(loader), archive->loader_stop_subscription); - furi_record_close(RECORD_LOADER); + if(archive->loader_stop_subscription) { + furi_pubsub_unsubscribe( + loader_get_pubsub(archive->loader), archive->loader_stop_subscription); + archive->loader_stop_subscription = NULL; + } view_dispatcher_stop(archive->view_dispatcher); } @@ -232,8 +231,9 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) { void archive_scene_browser_on_exit(void* context) { ArchiveApp* archive = (ArchiveApp*)context; - - Loader* loader = furi_record_open(RECORD_LOADER); - furi_pubsub_unsubscribe(loader_get_pubsub(loader), archive->loader_stop_subscription); - furi_record_close(RECORD_LOADER); + if(archive->loader_stop_subscription) { + furi_pubsub_unsubscribe( + loader_get_pubsub(archive->loader), archive->loader_stop_subscription); + archive->loader_stop_subscription = NULL; + } } From 807bec14b16e849825e1b0a0609fa5614fdc1c84 Mon Sep 17 00:00:00 2001 From: hedger Date: Wed, 22 May 2024 22:13:28 +0400 Subject: [PATCH 3/3] Replaced obsolete-format delay (#3660) --- targets/f7/furi_hal/furi_hal_flash.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/targets/f7/furi_hal/furi_hal_flash.c b/targets/f7/furi_hal/furi_hal_flash.c index 322a2e905..9cf64acc5 100644 --- a/targets/f7/furi_hal/furi_hal_flash.c +++ b/targets/f7/furi_hal/furi_hal_flash.c @@ -149,9 +149,8 @@ static void furi_hal_flash_begin_with_core2(bool erase_flag) { /* Erase activity notification */ if(erase_flag) SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_ON); - /* 64mHz 5us core2 flag protection */ - for(volatile uint32_t i = 0; i < 35; i++) - ; + /* 5us core2 flag protection */ + furi_delay_us(5); FuriHalCortexTimer timer = furi_hal_cortex_timer_get(FURI_HAL_FLASH_C2_LOCK_TIMEOUT_MS * 1000); while(true) {