mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-20 03:41:42 +03:00
commit
c547781ba0
@ -204,6 +204,9 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
|||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
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) {
|
switch(event.event) {
|
||||||
case SubGhzCustomEventViewReceiverBack:
|
case SubGhzCustomEventViewReceiverBack:
|
||||||
// Stop CC1101 Rx
|
// Stop CC1101 Rx
|
||||||
@ -226,23 +229,21 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
|||||||
break;
|
break;
|
||||||
case SubGhzCustomEventViewReceiverOK:
|
case SubGhzCustomEventViewReceiverOK:
|
||||||
// Show file info, scene: receiver_info
|
// 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);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverInfo);
|
||||||
dolphin_deed(DolphinDeedSubGhzReceiverInfo);
|
dolphin_deed(DolphinDeedSubGhzReceiverInfo);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
break;
|
break;
|
||||||
case SubGhzCustomEventViewReceiverDeleteItem:
|
case SubGhzCustomEventViewReceiverDeleteItem:
|
||||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
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_view_receiver_disable_draw_callback(subghz->subghz_receiver);
|
||||||
|
|
||||||
subghz_history_delete_item(subghz->history, subghz->idx_menu_chosen);
|
subghz_history_delete_item(subghz->history, subghz->idx_menu_chosen);
|
||||||
subghz_view_receiver_delete_element_callback(subghz->subghz_receiver);
|
subghz_view_receiver_delete_element_callback(subghz->subghz_receiver);
|
||||||
|
|
||||||
subghz_view_receiver_enable_draw_callback(subghz->subghz_receiver);
|
subghz_view_receiver_enable_draw_callback(subghz->subghz_receiver);
|
||||||
|
|
||||||
subghz_scene_receiver_update_statusbar(subghz);
|
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) {
|
if(subghz_history_get_last_index(subghz->history) == 0) {
|
||||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart);
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart);
|
||||||
}
|
}
|
||||||
@ -250,7 +251,6 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
|||||||
break;
|
break;
|
||||||
case SubGhzCustomEventViewReceiverConfig:
|
case SubGhzCustomEventViewReceiverConfig:
|
||||||
// Actually signals are received but SubGhzNotificationStateRx is not working inside Config Scene
|
// 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(
|
scene_manager_set_scene_state(
|
||||||
subghz->scene_manager, SubGhzViewIdReceiver, SubGhzCustomEventManagerSet);
|
subghz->scene_manager, SubGhzViewIdReceiver, SubGhzCustomEventManagerSet);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig);
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
|
|
||||||
#define SUBGHZ_RAW_THRESHOLD_MIN -90.0f
|
#define SUBGHZ_RAW_THRESHOLD_MIN -90.0f
|
||||||
|
|
||||||
#define SCROLL_INTERVAL (606)
|
#define FLIP_TIMEOUT (500)
|
||||||
#define SCROLL_DELAY (2)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FuriString* item_str;
|
FuriString* item_str;
|
||||||
@ -55,7 +54,7 @@ struct SubGhzViewReceiver {
|
|||||||
View* view;
|
View* view;
|
||||||
SubGhzViewReceiverCallback callback;
|
SubGhzViewReceiverCallback callback;
|
||||||
void* context;
|
void* context;
|
||||||
FuriTimer* scroll_timer;
|
FuriTimer* flip_time_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -70,7 +69,7 @@ typedef struct {
|
|||||||
SubGhzViewReceiverBarShow bar_show;
|
SubGhzViewReceiverBarShow bar_show;
|
||||||
SubGhzViewReceiverMode mode;
|
SubGhzViewReceiverMode mode;
|
||||||
uint8_t u_rssi;
|
uint8_t u_rssi;
|
||||||
size_t scroll_counter;
|
bool show_time;
|
||||||
bool nodraw;
|
bool nodraw;
|
||||||
} SubGhzViewReceiverModel;
|
} SubGhzViewReceiverModel;
|
||||||
|
|
||||||
@ -148,6 +147,24 @@ static void subghz_view_receiver_update_offset(SubGhzViewReceiver* subghz_receiv
|
|||||||
true);
|
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(
|
void subghz_view_receiver_add_item_to_menu(
|
||||||
SubGhzViewReceiver* subghz_receiver,
|
SubGhzViewReceiver* subghz_receiver,
|
||||||
const char* name,
|
const char* name,
|
||||||
@ -166,6 +183,7 @@ void subghz_view_receiver_add_item_to_menu(
|
|||||||
if((model->idx == model->history_item - 1)) {
|
if((model->idx == model->history_item - 1)) {
|
||||||
model->history_item++;
|
model->history_item++;
|
||||||
model->idx++;
|
model->idx++;
|
||||||
|
subghz_view_receiver_show_time_moment(subghz_receiver);
|
||||||
} else {
|
} else {
|
||||||
model->history_item++;
|
model->history_item++;
|
||||||
}
|
}
|
||||||
@ -255,29 +273,18 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
furi_string_set(str_buff, item_menu->item_str);
|
furi_string_set(str_buff, item_menu->item_str);
|
||||||
size_t scroll_counter = model->scroll_counter;
|
|
||||||
if(model->idx == idx) {
|
if(model->idx == idx) {
|
||||||
subghz_view_receiver_draw_frame(canvas, i, scrollbar);
|
subghz_view_receiver_draw_frame(canvas, i, scrollbar);
|
||||||
if(scroll_counter < SCROLL_DELAY) {
|
if(model->show_time) {
|
||||||
// Show time of signal one moment
|
// Show time of signal one moment
|
||||||
furi_string_set(str_buff, item_menu->time);
|
furi_string_set(str_buff, item_menu->time);
|
||||||
scroll_counter = 0;
|
|
||||||
} else {
|
|
||||||
scroll_counter -= SCROLL_DELAY;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
scroll_counter = 0;
|
|
||||||
}
|
}
|
||||||
|
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_icon(canvas, 4, 2 + i * FRAME_HEIGHT, ReceiverItemIcons[item_menu->type]);
|
||||||
elements_scrollable_text_line(
|
canvas_draw_str(canvas, 15, 9 + i * FRAME_HEIGHT, furi_string_get_cstr(str_buff));
|
||||||
canvas,
|
|
||||||
15,
|
|
||||||
9 + i * FRAME_HEIGHT,
|
|
||||||
(scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX),
|
|
||||||
str_buff,
|
|
||||||
scroll_counter,
|
|
||||||
(model->idx != idx));
|
|
||||||
furi_string_reset(str_buff);
|
furi_string_reset(str_buff);
|
||||||
}
|
}
|
||||||
if(scrollbar) {
|
if(scrollbar) {
|
||||||
@ -384,13 +391,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) {
|
static void subghz_view_receiver_timer_callback(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubGhzViewReceiver* subghz_receiver = context;
|
SubGhzViewReceiver* subghz_receiver = context;
|
||||||
@ -450,7 +450,7 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) {
|
|||||||
SubGhzViewReceiverModel * model,
|
SubGhzViewReceiverModel * model,
|
||||||
{
|
{
|
||||||
if(model->idx != 0) model->idx--;
|
if(model->idx != 0) model->idx--;
|
||||||
model->scroll_counter = 0;
|
subghz_view_receiver_show_time_moment(context);
|
||||||
},
|
},
|
||||||
true);
|
true);
|
||||||
} else if(
|
} else if(
|
||||||
@ -460,9 +460,10 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) {
|
|||||||
subghz_receiver->view,
|
subghz_receiver->view,
|
||||||
SubGhzViewReceiverModel * model,
|
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->idx++;
|
||||||
model->scroll_counter = 0;
|
subghz_view_receiver_show_time_moment(context);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
true);
|
true);
|
||||||
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
|
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
|
||||||
@ -499,13 +500,7 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) {
|
|||||||
|
|
||||||
void subghz_view_receiver_enter(void* context) {
|
void subghz_view_receiver_enter(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubGhzViewReceiver* subghz_receiver = context;
|
subghz_view_receiver_show_time_moment(context);
|
||||||
with_view_model(
|
|
||||||
subghz_receiver->view,
|
|
||||||
SubGhzViewReceiverModel * model,
|
|
||||||
{ model->scroll_counter = 0; },
|
|
||||||
true);
|
|
||||||
furi_timer_start(subghz_receiver->scroll_timer, SCROLL_INTERVAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_view_receiver_exit(void* context) {
|
void subghz_view_receiver_exit(void* context) {
|
||||||
@ -533,7 +528,7 @@ void subghz_view_receiver_exit(void* context) {
|
|||||||
},
|
},
|
||||||
false);
|
false);
|
||||||
furi_timer_stop(subghz_receiver->timer);
|
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() {
|
SubGhzViewReceiver* subghz_view_receiver_alloc() {
|
||||||
@ -552,8 +547,8 @@ SubGhzViewReceiver* subghz_view_receiver_alloc() {
|
|||||||
view_set_enter_callback(subghz_receiver->view, subghz_view_receiver_enter);
|
view_set_enter_callback(subghz_receiver->view, subghz_view_receiver_enter);
|
||||||
view_set_exit_callback(subghz_receiver->view, subghz_view_receiver_exit);
|
view_set_exit_callback(subghz_receiver->view, subghz_view_receiver_exit);
|
||||||
|
|
||||||
subghz_receiver->scroll_timer = furi_timer_alloc(
|
subghz_receiver->flip_time_timer = furi_timer_alloc(
|
||||||
subghz_view_receiver_scroll_timer_callback, FuriTimerTypePeriodic, subghz_receiver);
|
subghz_view_receiver_flip_string_callback, FuriTimerTypeOnce, subghz_receiver);
|
||||||
|
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subghz_receiver->view,
|
subghz_receiver->view,
|
||||||
@ -577,7 +572,7 @@ SubGhzViewReceiver* subghz_view_receiver_alloc() {
|
|||||||
void subghz_view_receiver_free(SubGhzViewReceiver* subghz_receiver) {
|
void subghz_view_receiver_free(SubGhzViewReceiver* subghz_receiver) {
|
||||||
furi_assert(subghz_receiver);
|
furi_assert(subghz_receiver);
|
||||||
|
|
||||||
furi_timer_free(subghz_receiver->scroll_timer);
|
furi_timer_free(subghz_receiver->flip_time_timer);
|
||||||
|
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subghz_receiver->view,
|
subghz_receiver->view,
|
||||||
|
Loading…
Reference in New Issue
Block a user