mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Fix many SubGhz history bugs
No "history full" if "delete old signals" Delete more old signals if history full Fix visual offset bug with "delete old signals" Fix led and sound for full history / not "Delete old signals" in decode raw too
This commit is contained in:
@@ -7,7 +7,10 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
FuriString* history_stat_str = furi_string_alloc();
|
||||
if(!subghz_history_get_text_space_left(
|
||||
subghz->history, history_stat_str, subghz->gps->satellites)) {
|
||||
subghz->history,
|
||||
history_stat_str,
|
||||
subghz->gps->satellites,
|
||||
subghz->last_settings->delete_old_signals)) {
|
||||
FuriString* frequency_str = furi_string_alloc();
|
||||
FuriString* modulation_str = furi_string_alloc();
|
||||
|
||||
@@ -57,6 +60,20 @@ static void subghz_scene_add_to_history_callback(
|
||||
preset.latitude = subghz->gps->latitude;
|
||||
preset.longitude = subghz->gps->longitude;
|
||||
|
||||
if(subghz->last_settings->delete_old_signals && subghz_history_full(subghz->history)) {
|
||||
subghz_view_receiver_disable_draw_callback(subghz->subghz_receiver);
|
||||
|
||||
while(idx > 0 && subghz_history_full(subghz->history)) {
|
||||
subghz_history_delete_item(subghz->history, 0);
|
||||
subghz_view_receiver_delete_item(subghz->subghz_receiver, 0);
|
||||
idx--;
|
||||
}
|
||||
|
||||
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_add_to_history(subghz->history, decoder_base, &preset)) {
|
||||
furi_string_reset(item_name);
|
||||
furi_string_reset(item_time);
|
||||
@@ -80,9 +97,6 @@ static void subghz_scene_add_to_history_callback(
|
||||
// Restore ui state
|
||||
subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
subghz_view_receiver_enable_draw_callback(subghz->subghz_receiver);
|
||||
if(subghz_history_get_last_index(subghz->history) == 0) {
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart);
|
||||
}
|
||||
}
|
||||
|
||||
subghz_history_get_text_item_menu(subghz->history, item_name, idx);
|
||||
|
||||
@@ -50,7 +50,10 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
FuriString* history_stat_str = furi_string_alloc();
|
||||
if(!subghz_history_get_text_space_left(
|
||||
subghz->history, history_stat_str, subghz->gps->satellites)) {
|
||||
subghz->history,
|
||||
history_stat_str,
|
||||
subghz->gps->satellites,
|
||||
subghz->last_settings->delete_old_signals)) {
|
||||
FuriString* frequency_str = furi_string_alloc();
|
||||
FuriString* modulation_str = furi_string_alloc();
|
||||
|
||||
@@ -96,7 +99,6 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
|
||||
subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF,
|
||||
READ_BIT(subghz->filter, SubGhzProtocolFlag_BinRAW) > 0,
|
||||
subghz->repeater);
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
}
|
||||
furi_string_free(history_stat_str);
|
||||
|
||||
@@ -134,24 +136,28 @@ static void subghz_scene_add_to_history_callback(
|
||||
preset.longitude = subghz->gps->longitude;
|
||||
|
||||
if(subghz->last_settings->delete_old_signals && subghz_history_full(subghz->history)) {
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
subghz_view_receiver_disable_draw_callback(subghz->subghz_receiver);
|
||||
|
||||
subghz_history_delete_item(subghz->history, 0);
|
||||
subghz_view_receiver_delete_item(subghz->subghz_receiver, 0);
|
||||
while(idx > 0 && subghz_history_full(subghz->history)) {
|
||||
subghz_history_delete_item(subghz->history, 0);
|
||||
subghz_view_receiver_delete_item(subghz->subghz_receiver, 0);
|
||||
idx--;
|
||||
}
|
||||
|
||||
subghz_view_receiver_enable_draw_callback(subghz->subghz_receiver);
|
||||
if(idx == 0) {
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart);
|
||||
}
|
||||
subghz_scene_receiver_update_statusbar(subghz);
|
||||
subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
idx--;
|
||||
}
|
||||
|
||||
if(subghz_history_add_to_history(history, decoder_base, &preset)) {
|
||||
furi_string_reset(item_name);
|
||||
furi_string_reset(item_time);
|
||||
|
||||
//If the repeater is on, dont add to the menu, just TX the signal.
|
||||
if(subghz->repeater != SubGhzRepeaterStateOff) {
|
||||
//subghz_scene_receiver_update_statusbar(subghz);
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubGhzCustomEventViewRepeaterStart);
|
||||
} else {
|
||||
@@ -176,7 +182,7 @@ static void subghz_scene_add_to_history_callback(
|
||||
subghz->idx_menu_chosen =
|
||||
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
subghz_view_receiver_enable_draw_callback(subghz->subghz_receiver);
|
||||
if(subghz_history_get_last_index(subghz->history) == 0) {
|
||||
if(idx == 0) {
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart);
|
||||
}
|
||||
}
|
||||
@@ -191,8 +197,12 @@ static void subghz_scene_add_to_history_callback(
|
||||
subghz_history_get_repeats(history, idx));
|
||||
|
||||
subghz_scene_receiver_update_statusbar(subghz);
|
||||
if(subghz_history_get_text_space_left(subghz->history, NULL, 0)) {
|
||||
if(!subghz->last_settings->delete_old_signals &&
|
||||
subghz_history_full(subghz->history)) {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
notification_message(subghz->notifications, &sequence_error);
|
||||
} else {
|
||||
subghz->state_notifications = SubGhzNotificationStateRxDone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,8 +263,10 @@ void subghz_scene_receiver_on_enter(void* context) {
|
||||
subghz->subghz_receiver, subghz_scene_receiver_callback, subghz);
|
||||
subghz_txrx_set_rx_callback(subghz->txrx, subghz_scene_add_to_history_callback, subghz);
|
||||
|
||||
if(!subghz_history_get_text_space_left(subghz->history, NULL, 0)) {
|
||||
if(!subghz_history_full(subghz->history)) {
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
} else {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
}
|
||||
|
||||
// Check if hopping was enabled
|
||||
|
||||
@@ -127,7 +127,7 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
|
||||
subghz_scene_receiver_info_draw_widget(subghz);
|
||||
|
||||
if(!subghz_history_get_text_space_left(subghz->history, NULL, 0)) {
|
||||
if(!subghz_history_full(subghz->history)) {
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
subghz_txrx_rx_start(subghz->txrx);
|
||||
|
||||
subghz_txrx_hopper_unpause(subghz->txrx);
|
||||
if(!subghz_history_get_text_space_left(subghz->history, NULL, 0)) {
|
||||
if(!subghz_history_full(subghz->history)) {
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user