From 1d31000516b64f1a17c352339b736957a74a173b Mon Sep 17 00:00:00 2001 From: gornekich Date: Tue, 11 Jan 2022 20:45:49 +0300 Subject: [PATCH] iButton fix data layout (#953) * ibutton: fix info and delete scenes layout * loader: fix incorrect heap allocation memory calc * ibutton: cleanup --- .../scene/ibutton_scene_delete_confirm.cpp | 18 ++++++++++----- .../ibutton/scene/ibutton_scene_info.cpp | 22 ++++++++++--------- applications/loader/loader.c | 5 ++++- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/applications/ibutton/scene/ibutton_scene_delete_confirm.cpp b/applications/ibutton/scene/ibutton_scene_delete_confirm.cpp index a87a2488..4dc83b90 100755 --- a/applications/ibutton/scene/ibutton_scene_delete_confirm.cpp +++ b/applications/ibutton/scene/ibutton_scene_delete_confirm.cpp @@ -14,14 +14,14 @@ void iButtonSceneDeleteConfirm::on_enter(iButtonApp* app) { app->set_text_store("\e#Delete %s?\e#", key->get_name()); widget_add_text_box_element( - widget, 0, 0, 128, 23, AlignCenter, AlignCenter, app->get_text_store()); + widget, 0, 0, 128, 27, AlignCenter, AlignCenter, app->get_text_store()); widget_add_button_element(widget, GuiButtonTypeLeft, "Back", callback, app); widget_add_button_element(widget, GuiButtonTypeRight, "Delete", callback, app); switch(key->get_key_type()) { case iButtonKeyType::KeyDallas: app->set_text_store( - "%02X %02X %02X %02X %02X %02X %02X %02X\nDallas", + "%02X %02X %02X %02X %02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], @@ -30,17 +30,23 @@ void iButtonSceneDeleteConfirm::on_enter(iButtonApp* app) { key_data[5], key_data[6], key_data[7]); + widget_add_string_element( + widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Dallas"); break; case iButtonKeyType::KeyCyfral: - app->set_text_store("%02X %02X\nCyfral", key_data[0], key_data[1]); + app->set_text_store("%02X %02X", key_data[0], key_data[1]); + widget_add_string_element( + widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Cyfral"); break; case iButtonKeyType::KeyMetakom: app->set_text_store( - "%02X %02X %02X %02X\nMetakom", key_data[0], key_data[1], key_data[2], key_data[3]); + "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]); + widget_add_string_element( + widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Metakom"); break; } - widget_add_string_multiline_element( - widget, 64, 23, AlignCenter, AlignTop, FontSecondary, app->get_text_store()); + widget_add_string_element( + widget, 64, 33, AlignCenter, AlignBottom, FontSecondary, app->get_text_store()); view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget); } diff --git a/applications/ibutton/scene/ibutton_scene_info.cpp b/applications/ibutton/scene/ibutton_scene_info.cpp index 03a4b313..81c43c5d 100755 --- a/applications/ibutton/scene/ibutton_scene_info.cpp +++ b/applications/ibutton/scene/ibutton_scene_info.cpp @@ -14,13 +14,13 @@ void iButtonSceneInfo::on_enter(iButtonApp* app) { app->set_text_store("%s", key->get_name()); widget_add_text_box_element( - widget, 0, 0, 128, 23, AlignCenter, AlignCenter, app->get_text_store()); + widget, 0, 0, 128, 27, AlignCenter, AlignCenter, app->get_text_store()); widget_add_button_element(widget, GuiButtonTypeLeft, "Back", callback, app); switch(key->get_key_type()) { case iButtonKeyType::KeyDallas: app->set_text_store( - "\e#%02X %02X %02X %02X %02X %02X %02X %02X\e#\nDallas", + "%02X %02X %02X %02X %02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], @@ -29,21 +29,23 @@ void iButtonSceneInfo::on_enter(iButtonApp* app) { key_data[5], key_data[6], key_data[7]); + widget_add_string_element( + widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Dallas"); break; case iButtonKeyType::KeyMetakom: app->set_text_store( - "\e#%02X %02X %02X %02X\e#\nMetakom", - key_data[0], - key_data[1], - key_data[2], - key_data[3]); + "%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]); + widget_add_string_element( + widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Metakom"); break; case iButtonKeyType::KeyCyfral: - app->set_text_store("\e#%02X %02X\e#\nCyfral", key_data[0], key_data[1]); + app->set_text_store("%02X %02X", key_data[0], key_data[1]); + widget_add_string_element( + widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Cyfral"); break; } - widget_add_text_box_element( - widget, 0, 23, 128, 40, AlignCenter, AlignTop, app->get_text_store()); + widget_add_string_element( + widget, 64, 33, AlignCenter, AlignBottom, FontPrimary, app->get_text_store()); view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget); } diff --git a/applications/loader/loader.c b/applications/loader/loader.c index 81cf9a21..4cb2e209 100644 --- a/applications/loader/loader.c +++ b/applications/loader/loader.c @@ -217,9 +217,11 @@ static void loader_thread_state_callback(FuriThreadState thread_state, void* con LoaderEvent event; if(thread_state == FuriThreadStateRunning) { - instance->free_heap_size = memmgr_get_free_heap(); event.type = LoaderEventTypeApplicationStarted; furi_pubsub_publish(loader_instance->pubsub, &event); + + // Snapshot current memory usage + instance->free_heap_size = memmgr_get_free_heap(); } else if(thread_state == FuriThreadStateStopped) { /* * Current Leak Sanitizer assumes that memory is allocated and freed @@ -240,6 +242,7 @@ static void loader_thread_state_callback(FuriThreadState thread_state, void* con furi_thread_get_heap_size(instance->thread)); furi_hal_power_insomnia_exit(); loader_unlock(instance); + event.type = LoaderEventTypeApplicationStopped; furi_pubsub_publish(loader_instance->pubsub, &event); }