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 4414835ecce..7bbcb285b8d 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/main/archive/archive.c b/applications/main/archive/archive.c index 8dd934cc7b9..5db650445da 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 d444aef8fcb..13b975a44d3 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 284e534abaa..ba928c4993c 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; + } } diff --git a/applications/main/nfc/scenes/nfc_scene_set_uid.c b/applications/main/nfc/scenes/nfc_scene_set_uid.c index f09d0a43033..f702fa05b3b 100644 --- a/applications/main/nfc/scenes/nfc_scene_set_uid.c +++ b/applications/main/nfc/scenes/nfc_scene_set_uid.c @@ -2,22 +2,12 @@ #include "../helpers/protocol_support/nfc_protocol_support_gui_common.h" -static void nfc_scene_set_uid_byte_input_changed_callback(void* context) { - NfcApp* instance = context; - // Retrieve previously saved UID length - const size_t uid_len = scene_manager_get_scene_state(instance->scene_manager, NfcSceneSetUid); - nfc_device_set_uid(instance->nfc_device, instance->byte_input_store, uid_len); -} - void nfc_scene_set_uid_on_enter(void* context) { NfcApp* instance = context; size_t uid_len; const uint8_t* uid = nfc_device_get_uid(instance->nfc_device, &uid_len); - memcpy(instance->byte_input_store, uid, uid_len); - // Save UID length for use in callback - scene_manager_set_scene_state(instance->scene_manager, NfcSceneSetUid, uid_len); // Setup view ByteInput* byte_input = instance->byte_input; @@ -25,7 +15,7 @@ void nfc_scene_set_uid_on_enter(void* context) { byte_input_set_result_callback( byte_input, nfc_protocol_support_common_byte_input_done_callback, - nfc_scene_set_uid_byte_input_changed_callback, + NULL, instance, instance->byte_input_store, uid_len); @@ -39,6 +29,9 @@ bool nfc_scene_set_uid_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == NfcCustomEventByteInputDone) { + size_t uid_len = 0; + nfc_device_get_uid(instance->nfc_device, &uid_len); + nfc_device_set_uid(instance->nfc_device, instance->byte_input_store, uid_len); if(scene_manager_has_previous_scene(instance->scene_manager, NfcSceneSavedMenu)) { if(nfc_save(instance)) { scene_manager_next_scene(instance->scene_manager, NfcSceneSaveSuccess); diff --git a/applications/services/gui/modules/text_box.c b/applications/services/gui/modules/text_box.c index 954847c650a..c3bff00d085 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 43f80c61eb9..9cf64acc589 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" @@ -150,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) {