mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 03:48:35 -07:00
Initial xfw app subghz frequency editor
This commit is contained in:
@@ -2,6 +2,7 @@ ADD_SCENE(xtreme_app, start, Start)
|
|||||||
ADD_SCENE(xtreme_app, graphics, Graphics)
|
ADD_SCENE(xtreme_app, graphics, Graphics)
|
||||||
ADD_SCENE(xtreme_app, statusbar, Statusbar)
|
ADD_SCENE(xtreme_app, statusbar, Statusbar)
|
||||||
ADD_SCENE(xtreme_app, protocols, Protocols)
|
ADD_SCENE(xtreme_app, protocols, Protocols)
|
||||||
|
ADD_SCENE(xtreme_app, protocols_frequencies, ProtocolsFrequencies)
|
||||||
ADD_SCENE(xtreme_app, dolphin, Dolphin)
|
ADD_SCENE(xtreme_app, dolphin, Dolphin)
|
||||||
ADD_SCENE(xtreme_app, misc, Misc)
|
ADD_SCENE(xtreme_app, misc, Misc)
|
||||||
ADD_SCENE(xtreme_app, misc_rename, MiscRename)
|
ADD_SCENE(xtreme_app, misc_rename, MiscRename)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
enum VarItemListIndex {
|
enum VarItemListIndex {
|
||||||
VarItemListIndexBadkbMode,
|
VarItemListIndexBadkbMode,
|
||||||
VarItemListIndexBadbtRemember,
|
VarItemListIndexBadbtRemember,
|
||||||
|
VarItemListIndexSubghzFrequencies,
|
||||||
VarItemListIndexSubghzExtend,
|
VarItemListIndexSubghzExtend,
|
||||||
VarItemListIndexSubghzBypass,
|
VarItemListIndexSubghzBypass,
|
||||||
};
|
};
|
||||||
@@ -62,6 +63,8 @@ void xtreme_app_scene_protocols_on_enter(void* context) {
|
|||||||
variable_item_set_current_value_index(item, xtreme_settings->bad_bt_remember);
|
variable_item_set_current_value_index(item, xtreme_settings->bad_bt_remember);
|
||||||
variable_item_set_current_value_text(item, xtreme_settings->bad_bt_remember ? "ON" : "OFF");
|
variable_item_set_current_value_text(item, xtreme_settings->bad_bt_remember ? "ON" : "OFF");
|
||||||
|
|
||||||
|
variable_item_list_add(var_item_list, "SubGHz Frequencies", 0, NULL, app);
|
||||||
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
var_item_list, "SubGHz Extend", 2, xtreme_app_scene_protocols_subghz_extend_changed, app);
|
var_item_list, "SubGHz Extend", 2, xtreme_app_scene_protocols_subghz_extend_changed, app);
|
||||||
variable_item_set_current_value_index(item, app->subghz_extend);
|
variable_item_set_current_value_index(item, app->subghz_extend);
|
||||||
@@ -89,6 +92,9 @@ bool xtreme_app_scene_protocols_on_event(void* context, SceneManagerEvent event)
|
|||||||
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneProtocols, event.event);
|
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneProtocols, event.event);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
switch(event.event) {
|
switch(event.event) {
|
||||||
|
case VarItemListIndexSubghzFrequencies:
|
||||||
|
scene_manager_next_scene(app->scene_manager, XtremeAppSceneProtocolsFrequencies);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
#include "../xtreme_app.h"
|
||||||
|
|
||||||
|
enum VarItemListIndex {
|
||||||
|
VarItemListIndexStaticFrequency,
|
||||||
|
VarItemListIndexHopperFrequency,
|
||||||
|
};
|
||||||
|
|
||||||
|
void xtreme_app_scene_protocols_frequencies_var_item_list_callback(void* context, uint32_t index) {
|
||||||
|
XtremeApp* app = context;
|
||||||
|
view_dispatcher_send_custom_event(app->view_dispatcher, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xtreme_app_scene_protocols_frequencies_static_frequency_changed(VariableItem* item) {
|
||||||
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
|
uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
uint32_t value = *FrequencyList_get(app->subghz_static_frequencies, index);
|
||||||
|
char text[10] = {0};
|
||||||
|
snprintf(text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
|
||||||
|
variable_item_set_current_value_text(item, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xtreme_app_scene_protocols_frequencies_hopper_frequency_changed(VariableItem* item) {
|
||||||
|
XtremeApp* app = variable_item_get_context(item);
|
||||||
|
uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
uint32_t value = *FrequencyList_get(app->subghz_hopper_frequencies, index);
|
||||||
|
char text[10] = {0};
|
||||||
|
snprintf(text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
|
||||||
|
variable_item_set_current_value_text(item, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void xtreme_app_scene_protocols_frequencies_on_enter(void* context) {
|
||||||
|
XtremeApp* app = context;
|
||||||
|
VariableItemList* var_item_list = app->var_item_list;
|
||||||
|
VariableItem* item;
|
||||||
|
|
||||||
|
item = variable_item_list_add(var_item_list, "Static Freq", FrequencyList_size(app->subghz_static_frequencies), xtreme_app_scene_protocols_frequencies_static_frequency_changed, app);
|
||||||
|
variable_item_set_current_value_index(item, 0);
|
||||||
|
if(FrequencyList_size(app->subghz_static_frequencies)) {
|
||||||
|
uint32_t value = *FrequencyList_get(app->subghz_static_frequencies, 0);
|
||||||
|
char text[10] = {0};
|
||||||
|
snprintf(text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
|
||||||
|
variable_item_set_current_value_text(item, text);
|
||||||
|
} else {
|
||||||
|
variable_item_set_current_value_text(item, "None");
|
||||||
|
}
|
||||||
|
|
||||||
|
item = variable_item_list_add(var_item_list, "Hopper Freq", FrequencyList_size(app->subghz_hopper_frequencies), xtreme_app_scene_protocols_frequencies_hopper_frequency_changed, app);
|
||||||
|
variable_item_set_current_value_index(item, 0);
|
||||||
|
if(FrequencyList_size(app->subghz_hopper_frequencies)) {
|
||||||
|
uint32_t value = *FrequencyList_get(app->subghz_hopper_frequencies, 0);
|
||||||
|
char text[10] = {0};
|
||||||
|
snprintf(text, sizeof(text), "%lu.%02lu", value / 1000000, (value % 1000000) / 10000);
|
||||||
|
variable_item_set_current_value_text(item, text);
|
||||||
|
} else {
|
||||||
|
variable_item_set_current_value_text(item, "None");
|
||||||
|
}
|
||||||
|
|
||||||
|
variable_item_list_set_enter_callback(
|
||||||
|
var_item_list, xtreme_app_scene_protocols_frequencies_var_item_list_callback, app);
|
||||||
|
|
||||||
|
variable_item_list_set_selected_item(
|
||||||
|
var_item_list, scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneProtocolsFrequencies));
|
||||||
|
|
||||||
|
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewVarItemList);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool xtreme_app_scene_protocols_frequencies_on_event(void* context, SceneManagerEvent event) {
|
||||||
|
XtremeApp* app = context;
|
||||||
|
bool consumed = false;
|
||||||
|
|
||||||
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
|
scene_manager_set_scene_state(app->scene_manager, XtremeAppSceneProtocolsFrequencies, event.event);
|
||||||
|
consumed = true;
|
||||||
|
switch(event.event) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return consumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void xtreme_app_scene_protocols_frequencies_on_exit(void* context) {
|
||||||
|
XtremeApp* app = context;
|
||||||
|
variable_item_list_reset(app->var_item_list);
|
||||||
|
}
|
||||||
@@ -22,6 +22,9 @@ static bool xtreme_app_back_event_callback(void* context) {
|
|||||||
furi_hal_subghz_set_extend_settings(app->subghz_extend, app->subghz_bypass);
|
furi_hal_subghz_set_extend_settings(app->subghz_extend, app->subghz_bypass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(app->save_subghz_frequencies) {
|
||||||
|
}
|
||||||
|
|
||||||
if(app->save_level) {
|
if(app->save_level) {
|
||||||
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
||||||
int xp = app->dolphin_level > 1 ? dolphin_get_levels()[app->dolphin_level - 2] : 0;
|
int xp = app->dolphin_level > 1 ? dolphin_get_levels()[app->dolphin_level - 2] : 0;
|
||||||
@@ -118,6 +121,37 @@ XtremeApp* xtreme_app_alloc() {
|
|||||||
|
|
||||||
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
||||||
|
|
||||||
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
|
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||||
|
FrequencyList_init(app->subghz_static_frequencies);
|
||||||
|
FrequencyList_init(app->subghz_hopper_frequencies);
|
||||||
|
app->subghz_use_defaults = true;
|
||||||
|
app->subghz_default_frequency = 0;
|
||||||
|
do {
|
||||||
|
uint32_t temp;
|
||||||
|
if(!flipper_format_file_open_existing(file, EXT_PATH("subghz/assets/setting_user"))) break;
|
||||||
|
|
||||||
|
flipper_format_read_bool(file, "Add_standard_frequencies", &app->subghz_use_defaults, 1);
|
||||||
|
|
||||||
|
if(!flipper_format_rewind(file)) break;
|
||||||
|
flipper_format_read_uint32(file, "Default_frequency", &app->subghz_default_frequency, 1);
|
||||||
|
|
||||||
|
if(!flipper_format_rewind(file)) break;
|
||||||
|
while(flipper_format_read_uint32(file, "Frequency", &temp, 1)) {
|
||||||
|
if(furi_hal_subghz_is_frequency_valid(temp)) {
|
||||||
|
FrequencyList_push_back(app->subghz_static_frequencies, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!flipper_format_rewind(file)) break;
|
||||||
|
while(flipper_format_read_uint32(file, "Hopper_frequency", &temp, 1)) {
|
||||||
|
if(furi_hal_subghz_is_frequency_valid(temp)) {
|
||||||
|
FrequencyList_push_back(app->subghz_hopper_frequencies, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while(false);
|
||||||
|
flipper_format_free(file);
|
||||||
|
|
||||||
furi_hal_subghz_get_extend_settings(&app->subghz_extend, &app->subghz_bypass);
|
furi_hal_subghz_get_extend_settings(&app->subghz_extend, &app->subghz_bypass);
|
||||||
|
|
||||||
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
||||||
@@ -129,7 +163,6 @@ XtremeApp* xtreme_app_alloc() {
|
|||||||
|
|
||||||
app->asset_pack = 0;
|
app->asset_pack = 0;
|
||||||
asset_packs_init(app->asset_packs);
|
asset_packs_init(app->asset_packs);
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
||||||
File* folder = storage_file_alloc(storage);
|
File* folder = storage_file_alloc(storage);
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
char* name = malloc(MAX_PACK_NAME_LEN);
|
char* name = malloc(MAX_PACK_NAME_LEN);
|
||||||
@@ -183,6 +216,9 @@ void xtreme_app_free(XtremeApp* app) {
|
|||||||
|
|
||||||
// Settings deinit
|
// Settings deinit
|
||||||
|
|
||||||
|
FrequencyList_clear(app->subghz_static_frequencies);
|
||||||
|
FrequencyList_clear(app->subghz_hopper_frequencies);
|
||||||
|
|
||||||
asset_packs_it_t it;
|
asset_packs_it_t it;
|
||||||
for(asset_packs_it(it, app->asset_packs); !asset_packs_end_p(it); asset_packs_next(it)) {
|
for(asset_packs_it(it, app->asset_packs); !asset_packs_end_p(it); asset_packs_next(it)) {
|
||||||
free(*asset_packs_cref(it));
|
free(*asset_packs_cref(it));
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "dolphin/dolphin.h"
|
#include "dolphin/dolphin.h"
|
||||||
#include "dolphin/dolphin_i.h"
|
#include "dolphin/dolphin_i.h"
|
||||||
#include <lib/flipper_format/flipper_format.h>
|
#include <lib/flipper_format/flipper_format.h>
|
||||||
|
#include <lib/subghz/subghz_setting.h>
|
||||||
#include <m-array.h>
|
#include <m-array.h>
|
||||||
#include "xtreme/settings.h"
|
#include "xtreme/settings.h"
|
||||||
#include "xtreme/assets.h"
|
#include "xtreme/assets.h"
|
||||||
@@ -29,6 +30,10 @@ typedef struct {
|
|||||||
VariableItemList* var_item_list;
|
VariableItemList* var_item_list;
|
||||||
TextInput* text_input;
|
TextInput* text_input;
|
||||||
Popup* popup;
|
Popup* popup;
|
||||||
|
bool subghz_use_defaults;
|
||||||
|
uint32_t subghz_default_frequency;
|
||||||
|
FrequencyList_t subghz_static_frequencies;
|
||||||
|
FrequencyList_t subghz_hopper_frequencies;
|
||||||
bool subghz_extend;
|
bool subghz_extend;
|
||||||
bool subghz_bypass;
|
bool subghz_bypass;
|
||||||
int dolphin_level;
|
int dolphin_level;
|
||||||
@@ -37,6 +42,7 @@ typedef struct {
|
|||||||
asset_packs_t asset_packs;
|
asset_packs_t asset_packs;
|
||||||
FuriString* version_tag;
|
FuriString* version_tag;
|
||||||
bool save_subghz;
|
bool save_subghz;
|
||||||
|
bool save_subghz_frequencies;
|
||||||
bool save_level;
|
bool save_level;
|
||||||
bool save_name;
|
bool save_name;
|
||||||
bool save_settings;
|
bool save_settings;
|
||||||
|
|||||||
Reference in New Issue
Block a user