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:
Willy-JL
2024-01-27 19:12:59 +00:00
parent cb635ff2d2
commit 0e8703a7a1
6 changed files with 63 additions and 25 deletions

View File

@@ -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