From 3d1ef1aae37619ed901fd9e3fe68a25aba663a02 Mon Sep 17 00:00:00 2001 From: Nikita Vostokov Date: Mon, 26 Jun 2023 14:48:57 +0300 Subject: [PATCH 1/3] Disable subghz item scrolling * Show time on receive new signal also --- applications/main/subghz/views/receiver.c | 72 +++++++++++------------ 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/applications/main/subghz/views/receiver.c b/applications/main/subghz/views/receiver.c index 53921f866..279d0d350 100644 --- a/applications/main/subghz/views/receiver.c +++ b/applications/main/subghz/views/receiver.c @@ -14,8 +14,7 @@ #define SUBGHZ_RAW_THRESHOLD_MIN -90.0f -#define SCROLL_INTERVAL (606) -#define SCROLL_DELAY (2) +#define FLIP_TIMEOUT (500) typedef struct { FuriString* item_str; @@ -55,7 +54,7 @@ struct SubGhzViewReceiver { View* view; SubGhzViewReceiverCallback callback; void* context; - FuriTimer* scroll_timer; + FuriTimer* flip_time_timer; }; typedef struct { @@ -70,7 +69,7 @@ typedef struct { SubGhzViewReceiverBarShow bar_show; SubGhzViewReceiverMode mode; uint8_t u_rssi; - size_t scroll_counter; + bool show_time; bool nodraw; } SubGhzViewReceiverModel; @@ -148,6 +147,24 @@ static void subghz_view_receiver_update_offset(SubGhzViewReceiver* subghz_receiv true); } +static void subghz_view_receiver_show_time_moment(void* context) { + furi_assert(context); + SubGhzViewReceiver* subghz_receiver = context; + with_view_model( + subghz_receiver->view, SubGhzViewReceiverModel * model, { model->show_time = true; }, true); + furi_timer_start(subghz_receiver->flip_time_timer, FLIP_TIMEOUT); +} + +static void subghz_view_receiver_flip_string_callback(void* context) { + furi_assert(context); + SubGhzViewReceiver* subghz_receiver = context; + with_view_model( + subghz_receiver->view, + SubGhzViewReceiverModel * model, + { model->show_time = false; }, + true); +} + void subghz_view_receiver_add_item_to_menu( SubGhzViewReceiver* subghz_receiver, const char* name, @@ -166,6 +183,7 @@ void subghz_view_receiver_add_item_to_menu( if((model->idx == model->history_item - 1)) { model->history_item++; model->idx++; + subghz_view_receiver_show_time_moment(subghz_receiver); } else { model->history_item++; } @@ -255,29 +273,17 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) { break; } furi_string_set(str_buff, item_menu->item_str); - size_t scroll_counter = model->scroll_counter; if(model->idx == idx) { subghz_view_receiver_draw_frame(canvas, i, scrollbar); - if(scroll_counter < SCROLL_DELAY) { + if(model->show_time) { // Show time of signal one moment furi_string_set(str_buff, item_menu->time); - scroll_counter = 0; - } else { - scroll_counter -= SCROLL_DELAY; } } else { canvas_set_color(canvas, ColorBlack); - scroll_counter = 0; } canvas_draw_icon(canvas, 4, 2 + i * FRAME_HEIGHT, ReceiverItemIcons[item_menu->type]); - elements_scrollable_text_line( - canvas, - 15, - 9 + i * FRAME_HEIGHT, - (scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX), - str_buff, - scroll_counter, - (model->idx != idx)); + canvas_draw_str(canvas, 15, 9 + i * FRAME_HEIGHT, furi_string_get_cstr(str_buff)); furi_string_reset(str_buff); } if(scrollbar) { @@ -384,13 +390,6 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) { } } -static void subghz_view_receiver_scroll_timer_callback(void* context) { - furi_assert(context); - SubGhzViewReceiver* subghz_receiver = context; - with_view_model( - subghz_receiver->view, SubGhzViewReceiverModel * model, { model->scroll_counter++; }, true); -} - static void subghz_view_receiver_timer_callback(void* context) { furi_assert(context); SubGhzViewReceiver* subghz_receiver = context; @@ -450,7 +449,7 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) { SubGhzViewReceiverModel * model, { if(model->idx != 0) model->idx--; - model->scroll_counter = 0; + subghz_view_receiver_show_time_moment(context); }, true); } else if( @@ -460,9 +459,10 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) { subghz_receiver->view, SubGhzViewReceiverModel * model, { - if((model->history_item != 0) && (model->idx != model->history_item - 1)) + if((model->history_item != 0) && (model->idx != model->history_item - 1)) { model->idx++; - model->scroll_counter = 0; + subghz_view_receiver_show_time_moment(context); + } }, true); } else if(event->key == InputKeyLeft && event->type == InputTypeShort) { @@ -499,13 +499,7 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) { void subghz_view_receiver_enter(void* context) { furi_assert(context); - SubGhzViewReceiver* subghz_receiver = context; - with_view_model( - subghz_receiver->view, - SubGhzViewReceiverModel * model, - { model->scroll_counter = 0; }, - true); - furi_timer_start(subghz_receiver->scroll_timer, SCROLL_INTERVAL); + subghz_view_receiver_show_time_moment(context); } void subghz_view_receiver_exit(void* context) { @@ -533,7 +527,7 @@ void subghz_view_receiver_exit(void* context) { }, false); furi_timer_stop(subghz_receiver->timer); - furi_timer_stop(subghz_receiver->scroll_timer); + furi_timer_stop(subghz_receiver->flip_time_timer); } SubGhzViewReceiver* subghz_view_receiver_alloc() { @@ -552,8 +546,8 @@ SubGhzViewReceiver* subghz_view_receiver_alloc() { view_set_enter_callback(subghz_receiver->view, subghz_view_receiver_enter); view_set_exit_callback(subghz_receiver->view, subghz_view_receiver_exit); - subghz_receiver->scroll_timer = furi_timer_alloc( - subghz_view_receiver_scroll_timer_callback, FuriTimerTypePeriodic, subghz_receiver); + subghz_receiver->flip_time_timer = furi_timer_alloc( + subghz_view_receiver_flip_string_callback, FuriTimerTypeOnce, subghz_receiver); with_view_model( subghz_receiver->view, @@ -577,7 +571,7 @@ SubGhzViewReceiver* subghz_view_receiver_alloc() { void subghz_view_receiver_free(SubGhzViewReceiver* subghz_receiver) { furi_assert(subghz_receiver); - furi_timer_free(subghz_receiver->scroll_timer); + furi_timer_free(subghz_receiver->flip_time_timer); with_view_model( subghz_receiver->view, From 0b6848751992ac17e2c19ed075e050bdbf9885d3 Mon Sep 17 00:00:00 2001 From: Nikita Vostokov Date: Mon, 26 Jun 2023 15:01:38 +0300 Subject: [PATCH 2/3] Fix cursor hiding after delete and exit from exit dialog --- applications/main/subghz/scenes/subghz_scene_receiver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index d9fd38836..3076904c5 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -204,6 +204,9 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { SubGhz* subghz = context; bool consumed = false; if(event.type == SceneManagerEventTypeCustom) { + // Save cursor position before going to any other dialog + subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver); + switch(event.event) { case SubGhzCustomEventViewReceiverBack: // Stop CC1101 Rx @@ -226,23 +229,21 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { break; case SubGhzCustomEventViewReceiverOK: // Show file info, scene: receiver_info - subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverInfo); dolphin_deed(DolphinDeedSubGhzReceiverInfo); consumed = true; break; case SubGhzCustomEventViewReceiverDeleteItem: subghz->state_notifications = SubGhzNotificationStateRx; - subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver); subghz_view_receiver_disable_draw_callback(subghz->subghz_receiver); subghz_history_delete_item(subghz->history, subghz->idx_menu_chosen); subghz_view_receiver_delete_element_callback(subghz->subghz_receiver); - subghz_view_receiver_enable_draw_callback(subghz->subghz_receiver); subghz_scene_receiver_update_statusbar(subghz); + subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver); if(subghz_history_get_last_index(subghz->history) == 0) { subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart); } @@ -250,7 +251,6 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { break; case SubGhzCustomEventViewReceiverConfig: // Actually signals are received but SubGhzNotificationStateRx is not working inside Config Scene - subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver); scene_manager_set_scene_state( subghz->scene_manager, SubGhzViewIdReceiver, SubGhzCustomEventManagerSet); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig); From ad12071f4c8fd370d66519051df6e64c9be4228a Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 2 Jul 2023 10:01:57 +0300 Subject: [PATCH 3/3] fix text bug --- applications/main/subghz/views/receiver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/main/subghz/views/receiver.c b/applications/main/subghz/views/receiver.c index 279d0d350..eb7a5a154 100644 --- a/applications/main/subghz/views/receiver.c +++ b/applications/main/subghz/views/receiver.c @@ -282,6 +282,7 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) { } else { canvas_set_color(canvas, ColorBlack); } + elements_string_fit_width(canvas, str_buff, scrollbar ? MAX_LEN_PX - 7 : MAX_LEN_PX); canvas_draw_icon(canvas, 4, 2 + i * FRAME_HEIGHT, ReceiverItemIcons[item_menu->type]); canvas_draw_str(canvas, 15, 9 + i * FRAME_HEIGHT, furi_string_get_cstr(str_buff)); furi_string_reset(str_buff);