mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-24 11:14:26 +03:00
Show region information in sub-GHz app (#2249)
* Show region info in sub-GHz app * SubGhz: reset widget on region info scene exit * Format sources Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
c24bea6b06
commit
2c450bd835
@ -7,7 +7,7 @@ enum SubmenuIndex {
|
|||||||
SubmenuIndexDetectReader,
|
SubmenuIndexDetectReader,
|
||||||
SubmenuIndexSaved,
|
SubmenuIndexSaved,
|
||||||
SubmenuIndexExtraAction,
|
SubmenuIndexExtraAction,
|
||||||
SubmenuIndexAddManualy,
|
SubmenuIndexAddManually,
|
||||||
SubmenuIndexDebug,
|
SubmenuIndexDebug,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ void nfc_scene_start_on_enter(void* context) {
|
|||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu, "Extra Actions", SubmenuIndexExtraAction, nfc_scene_start_submenu_callback, nfc);
|
submenu, "Extra Actions", SubmenuIndexExtraAction, nfc_scene_start_submenu_callback, nfc);
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
submenu, "Add Manually", SubmenuIndexAddManualy, nfc_scene_start_submenu_callback, nfc);
|
submenu, "Add Manually", SubmenuIndexAddManually, nfc_scene_start_submenu_callback, nfc);
|
||||||
|
|
||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
@ -68,7 +68,7 @@ bool nfc_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|||||||
} else if(event.event == SubmenuIndexExtraAction) {
|
} else if(event.event == SubmenuIndexExtraAction) {
|
||||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneExtraActions);
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneExtraActions);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
} else if(event.event == SubmenuIndexAddManualy) {
|
} else if(event.event == SubmenuIndexAddManually) {
|
||||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetType);
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetType);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
} else if(event.event == SubmenuIndexDebug) {
|
} else if(event.event == SubmenuIndexDebug) {
|
||||||
|
@ -23,3 +23,4 @@ ADD_SCENE(subghz, more_raw, MoreRAW)
|
|||||||
ADD_SCENE(subghz, delete_raw, DeleteRAW)
|
ADD_SCENE(subghz, delete_raw, DeleteRAW)
|
||||||
ADD_SCENE(subghz, need_saving, NeedSaving)
|
ADD_SCENE(subghz, need_saving, NeedSaving)
|
||||||
ADD_SCENE(subghz, rpc, Rpc)
|
ADD_SCENE(subghz, rpc, Rpc)
|
||||||
|
ADD_SCENE(subghz, region_info, RegionInfo)
|
||||||
|
39
applications/main/subghz/scenes/subghz_scene_region_info.c
Normal file
39
applications/main/subghz/scenes/subghz_scene_region_info.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include "../subghz_i.h"
|
||||||
|
|
||||||
|
#include <furi_hal_region.h>
|
||||||
|
|
||||||
|
void subghz_scene_region_info_on_enter(void* context) {
|
||||||
|
SubGhz* subghz = context;
|
||||||
|
const FuriHalRegion* const region = furi_hal_region_get();
|
||||||
|
FuriString* buffer;
|
||||||
|
buffer = furi_string_alloc();
|
||||||
|
if(region) {
|
||||||
|
furi_string_cat_printf(buffer, "Region: %s, bands:\n", region->country_code);
|
||||||
|
for(uint16_t i = 0; i < region->bands_count; ++i) {
|
||||||
|
furi_string_cat_printf(
|
||||||
|
buffer,
|
||||||
|
" %lu-%lu kHz\n",
|
||||||
|
region->bands[i].start / 1000,
|
||||||
|
region->bands[i].end / 1000);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
furi_string_cat_printf(buffer, "Region: N/A\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
widget_add_string_multiline_element(
|
||||||
|
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(buffer));
|
||||||
|
|
||||||
|
furi_string_free(buffer);
|
||||||
|
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool subghz_scene_region_info_on_event(void* context, SceneManagerEvent event) {
|
||||||
|
UNUSED(context);
|
||||||
|
UNUSED(event);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void subghz_scene_region_info_on_exit(void* context) {
|
||||||
|
SubGhz* subghz = context;
|
||||||
|
widget_reset(subghz->widget);
|
||||||
|
}
|
@ -5,9 +5,10 @@ enum SubmenuIndex {
|
|||||||
SubmenuIndexRead = 10,
|
SubmenuIndexRead = 10,
|
||||||
SubmenuIndexSaved,
|
SubmenuIndexSaved,
|
||||||
SubmenuIndexTest,
|
SubmenuIndexTest,
|
||||||
SubmenuIndexAddManualy,
|
SubmenuIndexAddManually,
|
||||||
SubmenuIndexFrequencyAnalyzer,
|
SubmenuIndexFrequencyAnalyzer,
|
||||||
SubmenuIndexReadRAW,
|
SubmenuIndexReadRAW,
|
||||||
|
SubmenuIndexShowRegionInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
void subghz_scene_start_submenu_callback(void* context, uint32_t index) {
|
void subghz_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||||
@ -33,7 +34,7 @@ void subghz_scene_start_on_enter(void* context) {
|
|||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
subghz->submenu,
|
subghz->submenu,
|
||||||
"Add Manually",
|
"Add Manually",
|
||||||
SubmenuIndexAddManualy,
|
SubmenuIndexAddManually,
|
||||||
subghz_scene_start_submenu_callback,
|
subghz_scene_start_submenu_callback,
|
||||||
subghz);
|
subghz);
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
@ -42,6 +43,12 @@ void subghz_scene_start_on_enter(void* context) {
|
|||||||
SubmenuIndexFrequencyAnalyzer,
|
SubmenuIndexFrequencyAnalyzer,
|
||||||
subghz_scene_start_submenu_callback,
|
subghz_scene_start_submenu_callback,
|
||||||
subghz);
|
subghz);
|
||||||
|
submenu_add_item(
|
||||||
|
subghz->submenu,
|
||||||
|
"Region Information",
|
||||||
|
SubmenuIndexShowRegionInfo,
|
||||||
|
subghz_scene_start_submenu_callback,
|
||||||
|
subghz);
|
||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
subghz->submenu, "Test", SubmenuIndexTest, subghz_scene_start_submenu_callback, subghz);
|
subghz->submenu, "Test", SubmenuIndexTest, subghz_scene_start_submenu_callback, subghz);
|
||||||
@ -76,9 +83,9 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexSaved);
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexSaved);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved);
|
||||||
return true;
|
return true;
|
||||||
} else if(event.event == SubmenuIndexAddManualy) {
|
} else if(event.event == SubmenuIndexAddManually) {
|
||||||
scene_manager_set_scene_state(
|
scene_manager_set_scene_state(
|
||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexAddManualy);
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexAddManually);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetType);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetType);
|
||||||
return true;
|
return true;
|
||||||
} else if(event.event == SubmenuIndexFrequencyAnalyzer) {
|
} else if(event.event == SubmenuIndexFrequencyAnalyzer) {
|
||||||
@ -92,6 +99,11 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexTest);
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexTest);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTest);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTest);
|
||||||
return true;
|
return true;
|
||||||
|
} else if(event.event == SubmenuIndexShowRegionInfo) {
|
||||||
|
scene_manager_set_scene_state(
|
||||||
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexShowRegionInfo);
|
||||||
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneRegionInfo);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,7 +3,7 @@ enum SubmenuIndex {
|
|||||||
SubmenuIndexRead,
|
SubmenuIndexRead,
|
||||||
SubmenuIndexRunScript,
|
SubmenuIndexRunScript,
|
||||||
SubmenuIndexSaved,
|
SubmenuIndexSaved,
|
||||||
SubmenuIndexAddManualy,
|
SubmenuIndexAddManually,
|
||||||
SubmenuIndexDebug,
|
SubmenuIndexDebug,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user