Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into release-candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed May 24, 2024
2 parents 3e35806 + ab2fcaf commit 7363012
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 30 deletions.
30 changes: 29 additions & 1 deletion applications/debug/text_box_view_test/text_box_view_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions applications/main/archive/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions applications/main/archive/archive_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typedef enum {

struct ArchiveApp {
Gui* gui;
Loader* loader;
ViewDispatcher* view_dispatcher;
SceneManager* scene_manager;
ArchiveBrowserView* browser;
Expand Down
24 changes: 12 additions & 12 deletions applications/main/archive/scenes/archive_scene_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}
}
15 changes: 4 additions & 11 deletions applications/main/nfc/scenes/nfc_scene_set_uid.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,20 @@

#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;
byte_input_set_header_text(byte_input, "Enter UID in hex");
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);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions applications/services/gui/modules/text_box.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions targets/f7/furi_hal/furi_hal_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7363012

Please sign in to comment.