Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show satellites with an icon #215

Merged
merged 7 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions applications/main/subghz/scenes/subghz_scene_decode_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
static void subghz_scene_receiver_update_statusbar(void* context) {
SubGhz* subghz = context;
FuriString* history_stat_str = furi_string_alloc();
bool show_sats = subghz->gps && furi_hal_rtc_get_timestamp() % 2;
if(!subghz_history_get_text_space_left(
subghz->history,
history_stat_str,
subghz->gps ? subghz->gps->satellites : 0,
subghz->last_settings->delete_old_signals)) {
subghz->last_settings->delete_old_signals,
show_sats,
show_sats ? subghz->gps->satellites : 0)) {
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();

Expand All @@ -25,6 +27,7 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
furi_string_get_cstr(history_stat_str),
subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF,
READ_BIT(subghz->filter, SubGhzProtocolFlag_BinRAW) > 0,
show_sats,
subghz->repeater);

furi_string_free(frequency_str);
Expand All @@ -37,6 +40,7 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
"",
subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF,
READ_BIT(subghz->filter, SubGhzProtocolFlag_BinRAW) > 0,
show_sats,
subghz->repeater);
}
furi_string_free(history_stat_str);
Expand Down
8 changes: 6 additions & 2 deletions applications/main/subghz/scenes/subghz_scene_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ const NotificationSequence subghz_sequence_tx_beep = {
static void subghz_scene_receiver_update_statusbar(void* context) {
SubGhz* subghz = context;
FuriString* history_stat_str = furi_string_alloc();
bool show_sats = subghz->gps && furi_hal_rtc_get_timestamp() % 2;
if(!subghz_history_get_text_space_left(
subghz->history,
history_stat_str,
subghz->gps ? subghz->gps->satellites : 0,
subghz->last_settings->delete_old_signals)) {
subghz->last_settings->delete_old_signals,
show_sats,
show_sats ? subghz->gps->satellites : 0)) {
FuriString* frequency_str = furi_string_alloc();
FuriString* modulation_str = furi_string_alloc();

Expand Down Expand Up @@ -87,6 +89,7 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
furi_string_get_cstr(history_stat_str),
subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF,
READ_BIT(subghz->filter, SubGhzProtocolFlag_BinRAW) > 0,
show_sats,
subghz->repeater);

furi_string_free(frequency_str);
Expand All @@ -99,6 +102,7 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
"",
subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF,
READ_BIT(subghz->filter, SubGhzProtocolFlag_BinRAW) > 0,
show_sats,
subghz->repeater);
}
furi_string_free(history_stat_str);
Expand Down
15 changes: 6 additions & 9 deletions applications/main/subghz/subghz_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx
bool subghz_history_get_text_space_left(
SubGhzHistory* instance,
FuriString* output,
uint8_t sats,
bool ignore_full) {
bool ignore_full,
bool show_sats,
uint8_t sats) {
furi_assert(instance);
if(!ignore_full) {
if(memmgr_get_free_heap() < SUBGHZ_HISTORY_FREE_HEAP) {
Expand All @@ -207,14 +208,10 @@ bool subghz_history_get_text_space_left(
}
}
if(output != NULL) {
if(sats == 0) {
furi_string_printf(output, "%02u", instance->last_index_write);
if(show_sats) {
furi_string_printf(output, "%d", sats);
} else {
if(furi_hal_rtc_get_timestamp() % 2) {
furi_string_printf(output, "%02u", instance->last_index_write);
} else {
furi_string_printf(output, "%d sats", sats);
}
furi_string_printf(output, "%02u", instance->last_index_write);
}
}
return false;
Expand Down
14 changes: 8 additions & 6 deletions applications/main/subghz/subghz_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,21 @@ void subghz_history_get_text_item_menu(SubGhzHistory* instance, FuriString* outp
*/
void subghz_history_get_time_item_menu(SubGhzHistory* instance, FuriString* output, uint16_t idx);

/** Get string the remaining number of records to history
/** Get string the remaining number of records to history, or sats
*
* @param instance - SubGhzHistory instance
* @param output - FuriString* output
* @param sats - Number of satellites
* @param instance - SubGhzHistory instance
* @param output - FuriString* output
* @param ignore_full - Ignore if history is full
* @param show_sats - Whether to show the satellite number
* @param sats - Number of satellites
* @return bool - is FULL
*/
bool subghz_history_get_text_space_left(
SubGhzHistory* instance,
FuriString* output,
uint8_t sats,
bool ignore_full);
bool ignore_full,
bool show_sats,
uint8_t sats);

/** Return last index
*
Expand Down
15 changes: 13 additions & 2 deletions applications/main/subghz/views/receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ typedef struct {
FuriString* progress_str;
bool hopping_enabled;
bool bin_raw_enabled;
bool show_sats;
SubGhzRepeaterState repeater_state;
SubGhzReceiverHistory* history;
uint16_t idx;
Expand Down Expand Up @@ -210,6 +211,7 @@ void subghz_view_receiver_add_data_statusbar(
const char* history_stat_str,
bool hopping_enabled,
bool bin_raw_enabled,
bool show_sats,
SubGhzRepeaterState repeater_state) {
furi_assert(subghz_receiver);
with_view_model(
Expand All @@ -221,6 +223,7 @@ void subghz_view_receiver_add_data_statusbar(
furi_string_set(model->history_stat_str, history_stat_str);
model->hopping_enabled = hopping_enabled;
model->bin_raw_enabled = bin_raw_enabled;
model->show_sats = show_sats;
model->repeater_state = repeater_state;
},
true);
Expand Down Expand Up @@ -408,7 +411,11 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
AlignRight,
AlignBottom,
furi_string_get_cstr(model->history_stat_str));
canvas_draw_icon(canvas, 116, 53, &I_sub1_10px);
if(model->show_sats) {
canvas_draw_icon(canvas, 118, 54, &I_Sats_6x9);
} else {
canvas_draw_icon(canvas, 116, 53, &I_sub1_10px);
}
}
canvas_set_font(canvas, FontSecondary);
elements_bold_rounded_frame(canvas, 14, 8, 99, 48);
Expand Down Expand Up @@ -453,7 +460,11 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
AlignRight,
AlignBottom,
furi_string_get_cstr(model->history_stat_str));
canvas_draw_icon(canvas, 116, 53, &I_sub1_10px);
if(model->show_sats) {
canvas_draw_icon(canvas, 118, 54, &I_Sats_6x9);
} else {
canvas_draw_icon(canvas, 116, 53, &I_sub1_10px);
}
}
} break;
}
Expand Down
1 change: 1 addition & 0 deletions applications/main/subghz/views/receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void subghz_view_receiver_add_data_statusbar(
const char* history_stat_str,
bool hopping_enabled,
bool bin_raw_enabled,
bool show_sats,
SubGhzRepeaterState repeater_enabled);

void subghz_view_receiver_set_radio_device_type(
Expand Down
Binary file added assets/icons/SubGhz/Sats_6x9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions targets/f7/api_symbols.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3987,6 +3987,7 @@ Variable,+,I_Rpc_active_7x8,const Icon,
Variable,+,I_SDQuestion_35x43,const Icon,
Variable,+,I_SDcardFail_11x8,const Icon,
Variable,+,I_SDcardMounted_11x8,const Icon,
Variable,+,I_Sats_6x9,const Icon,
Variable,+,I_Scanning_123x52,const Icon,
Variable,+,I_SmallArrowDown_3x5,const Icon,
Variable,+,I_SmallArrowUp_3x5,const Icon,
Expand Down
Loading