Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
Sil333033 committed Jan 27, 2024
2 parents 7c4f6de + 361d5ca commit a18c757
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 46 deletions.
22 changes: 18 additions & 4 deletions applications/main/subghz/scenes/subghz_scene_decode_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
32 changes: 22 additions & 10 deletions applications/main/subghz/scenes/subghz_scene_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

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

Expand Down Expand Up @@ -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 {
Expand All @@ -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);
}
}
Expand All @@ -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;
}
}
}
Expand Down Expand Up @@ -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
Expand Down
42 changes: 21 additions & 21 deletions applications/main/subghz/scenes/subghz_scene_receiver_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ enum SubGhzSettingIndex {
SubGhzSettingIndexRAWRSSIThreshold = SubGhzSettingIndexBinRAW,
SubGhzSettingIndexRepeater,
SubGhzSettingIndexRemoveDuplicates,
SubGhzSettingIndexDeleteOldSignals,
SubGhzSettingIndexIgnoreStarline,
SubGhzSettingIndexIgnoreCars,
SubGhzSettingIndexIgnoreMagellan,
SubGhzSettingIndexIgnorePrinceton,
SubGhzSettingIndexIgnoreNiceFlorS,
SubGhzSettingIndexIgnoreWeather,
SubGhzSettingIndexIgnoreTPMS,
SubGhzSettingIndexDeleteOldSignals,
SubGhzSettingIndexSound,
SubGhzSettingIndexResetToDefault,
SubGhzSettingIndexLock,
Expand Down Expand Up @@ -346,6 +346,15 @@ static void subghz_scene_receiver_config_set_duplicates(VariableItem* item) {
if(index) subghz_history_remove_duplicates(subghz->history);
}

static void subghz_scene_receiver_config_set_delete_old_signals(VariableItem* item) {
SubGhz* subghz = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);

variable_item_set_current_value_text(item, combobox_text[index]);

subghz->last_settings->delete_old_signals = index == 1;
}

static inline bool subghz_scene_receiver_config_ignore_filter_get_index(
SubGhzProtocolFilter filter,
SubGhzProtocolFilter flag) {
Expand Down Expand Up @@ -379,15 +388,6 @@ static void subghz_scene_receiver_config_set_tpms(VariableItem* item) {
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_TPMS);
}

static void subghz_scene_receiver_config_set_delete_old_signals(VariableItem* item) {
SubGhz* subghz = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);

variable_item_set_current_value_text(item, combobox_text[index]);

subghz->last_settings->delete_old_signals = index == 1;
}

static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
furi_assert(context);
SubGhz* subghz = context;
Expand Down Expand Up @@ -535,6 +535,17 @@ void subghz_scene_receiver_config_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, combobox_text[value_index]);

item = variable_item_list_add(
subghz->variable_item_list,
"Delete Old Signals on Full Memory",
COMBO_BOX_COUNT,
subghz_scene_receiver_config_set_delete_old_signals,
subghz);

value_index = subghz->last_settings->delete_old_signals;
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, combobox_text[value_index]);

item = variable_item_list_add(
subghz->variable_item_list,
"Ignore Starline",
Expand Down Expand Up @@ -618,17 +629,6 @@ void subghz_scene_receiver_config_on_enter(void* context) {
subghz->ignore_filter, SubGhzProtocolFilter_TPMS);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, combobox_text[value_index]);

item = variable_item_list_add(
subghz->variable_item_list,
"Delete Old Signals on Full Memory",
COMBO_BOX_COUNT,
subghz_scene_receiver_config_set_delete_old_signals,
subghz);

value_index = subghz->last_settings->delete_old_signals;
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, combobox_text[value_index]);
}

// Enable speaker, will send all incoming noises and signals to speaker so you can listen how your remote sounds like :)
Expand Down
4 changes: 2 additions & 2 deletions applications/main/subghz/scenes/subghz_scene_receiver_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
22 changes: 14 additions & 8 deletions applications/main/subghz/subghz_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,21 @@ FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx
return NULL;
}
}
bool subghz_history_get_text_space_left(SubGhzHistory* instance, FuriString* output, uint8_t sats) {
bool subghz_history_get_text_space_left(
SubGhzHistory* instance,
FuriString* output,
uint8_t sats,
bool ignore_full) {
furi_assert(instance);
if(memmgr_get_free_heap() < SUBGHZ_HISTORY_FREE_HEAP) {
if(output != NULL) furi_string_printf(output, " Memory is FULL");
return true;
}
if(instance->last_index_write == SUBGHZ_HISTORY_MAX) {
if(output != NULL) furi_string_printf(output, " History is FULL");
return true;
if(!ignore_full) {
if(memmgr_get_free_heap() < SUBGHZ_HISTORY_FREE_HEAP) {
if(output != NULL) furi_string_printf(output, " Memory is FULL");
return true;
}
if(instance->last_index_write == SUBGHZ_HISTORY_MAX) {
if(output != NULL) furi_string_printf(output, " History is FULL");
return true;
}
}
if(output != NULL) {
if(sats == 0) {
Expand Down
7 changes: 6 additions & 1 deletion applications/main/subghz/subghz_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,14 @@ void subghz_history_get_time_item_menu(SubGhzHistory* instance, FuriString* outp
* @param instance - SubGhzHistory instance
* @param output - FuriString* output
* @param sats - Number of satellites
* @param ignore_full - Ignore if history is full
* @return bool - is FULL
*/
bool subghz_history_get_text_space_left(SubGhzHistory* instance, FuriString* output, uint8_t sats);
bool subghz_history_get_text_space_left(
SubGhzHistory* instance,
FuriString* output,
uint8_t sats,
bool ignore_full);

/** Return last index
*
Expand Down
1 change: 1 addition & 0 deletions applications/main/subghz/views/receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ void subghz_view_receiver_delete_item(SubGhzViewReceiver* subghz_receiver, uint1
}
},
true);
subghz_view_receiver_update_offset(subghz_receiver);
}

void subghz_view_receiver_enable_draw_callback(SubGhzViewReceiver* subghz_receiver) {
Expand Down

0 comments on commit a18c757

Please sign in to comment.