mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-10 06:54:19 +00:00
SubGHz External High Power
This commit is contained in:
parent
99b203e25c
commit
58beca313d
4 changed files with 89 additions and 1 deletions
|
@ -20,6 +20,12 @@ const char* const timestamp_names_text[TIMESTAMP_NAMES_COUNT] = {
|
|||
"ON",
|
||||
};
|
||||
|
||||
#define EXT_MOD_POWER_AMP_COUNT 2
|
||||
const char* const ext_mod_power_amp_text[EXT_MOD_POWER_AMP_COUNT] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
};
|
||||
|
||||
#define DEBUG_P_COUNT 2
|
||||
const char* const debug_pin_text[DEBUG_P_COUNT] = {
|
||||
"OFF",
|
||||
|
@ -105,6 +111,22 @@ static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) {
|
|||
// subghz_last_settings_save(subghz->last_settings);
|
||||
// }
|
||||
|
||||
static void subghz_scene_reciever_config_set_ext_mod_power_amp_text(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, ext_mod_power_amp_text[index]);
|
||||
|
||||
if(index == 1) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
|
||||
} else {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
|
||||
}
|
||||
|
||||
subghz->last_settings->external_module_power_amp = index == 1;
|
||||
subghz_last_settings_save(subghz->last_settings);
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_timestamp_file_names(VariableItem* item) {
|
||||
SubGhz* subghz = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
@ -137,6 +159,16 @@ void subghz_scene_radio_settings_on_enter(void* context) {
|
|||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, radio_device_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
variable_item_list,
|
||||
"Ext High Power",
|
||||
EXT_MOD_POWER_AMP_COUNT,
|
||||
subghz_scene_reciever_config_set_ext_mod_power_amp_text,
|
||||
subghz);
|
||||
value_index = subghz->last_settings->external_module_power_amp ? 1 : 0;
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, ext_mod_power_amp_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
variable_item_list,
|
||||
"Time in names",
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_TRIGGER "FATrigger"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_ENABLED "External"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER "ExtPower"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP "ExtPowerAmp"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES "TimestampNames"
|
||||
|
||||
SubGhzLastSettings* subghz_last_settings_alloc(void) {
|
||||
|
@ -46,6 +47,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
float temp_frequency_analyzer_trigger = 0;
|
||||
bool temp_external_module_enabled = false;
|
||||
bool temp_external_module_power_5v_disable = false;
|
||||
bool temp_external_module_power_amp = false;
|
||||
bool temp_timestamp_file_names = false;
|
||||
//int32_t temp_preset = 0;
|
||||
bool frequency_analyzer_feedback_level_was_read = false;
|
||||
|
@ -77,6 +79,11 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
fff_data_file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER,
|
||||
(bool*)&temp_external_module_power_5v_disable,
|
||||
1);
|
||||
flipper_format_read_bool(
|
||||
fff_data_file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP,
|
||||
(bool*)&temp_external_module_power_amp,
|
||||
1);
|
||||
flipper_format_read_bool(
|
||||
fff_data_file,
|
||||
|
@ -96,6 +103,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_FEEDBACK_LEVEL;
|
||||
instance->frequency_analyzer_trigger = SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_TRIGGER;
|
||||
instance->external_module_enabled = false;
|
||||
instance->external_module_power_amp = false;
|
||||
instance->timestamp_file_names = false;
|
||||
|
||||
} else {
|
||||
|
@ -118,7 +126,9 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
instance->external_module_power_5v_disable = temp_external_module_power_5v_disable;
|
||||
|
||||
instance->timestamp_file_names = temp_timestamp_file_names;
|
||||
|
||||
|
||||
instance->external_module_power_amp = temp_external_module_power_amp;
|
||||
|
||||
/*/} else {
|
||||
instance->preset = temp_preset;
|
||||
}*/
|
||||
|
@ -188,6 +198,13 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
|
|||
&instance->external_module_power_5v_disable,
|
||||
1)) {
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_bool(
|
||||
file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP,
|
||||
&instance->external_module_power_amp,
|
||||
1)) {
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_bool(
|
||||
file,
|
||||
|
|
|
@ -13,6 +13,7 @@ typedef struct {
|
|||
// TODO not using but saved so as not to change the version
|
||||
bool external_module_enabled;
|
||||
bool external_module_power_5v_disable;
|
||||
bool external_module_power_amp;
|
||||
// saved so as not to change the version
|
||||
bool timestamp_file_names;
|
||||
} SubGhzLastSettings;
|
||||
|
|
|
@ -2,14 +2,34 @@
|
|||
|
||||
#include "registry.h"
|
||||
|
||||
#include <subghz/subghz_last_settings.h>
|
||||
|
||||
void subghz_devices_init() {
|
||||
furi_check(!subghz_device_registry_is_valid());
|
||||
subghz_device_registry_init();
|
||||
|
||||
SubGhzLastSettings* last_settings = subghz_last_settings_alloc();
|
||||
subghz_last_settings_load(last_settings, 0);
|
||||
|
||||
if(last_settings->external_module_power_amp) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
|
||||
}
|
||||
|
||||
subghz_last_settings_free(last_settings);
|
||||
}
|
||||
|
||||
void subghz_devices_deinit(void) {
|
||||
furi_check(subghz_device_registry_is_valid());
|
||||
subghz_device_registry_deinit();
|
||||
|
||||
SubGhzLastSettings* last_settings = subghz_last_settings_alloc();
|
||||
subghz_last_settings_load(last_settings, 0);
|
||||
|
||||
if(last_settings->external_module_power_amp) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
|
||||
}
|
||||
|
||||
subghz_last_settings_free(last_settings);
|
||||
}
|
||||
|
||||
const SubGhzDevice* subghz_devices_get_by_name(const char* device_name) {
|
||||
|
@ -69,6 +89,7 @@ void subghz_devices_idle(const SubGhzDevice* device) {
|
|||
furi_assert(device);
|
||||
if(device->interconnect->idle) {
|
||||
device->interconnect->idle();
|
||||
furi_hal_gpio_write(&gpio_ext_pc3, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,6 +142,15 @@ bool subghz_devices_set_tx(const SubGhzDevice* device) {
|
|||
furi_assert(device);
|
||||
if(device->interconnect->set_tx) {
|
||||
ret = device->interconnect->set_tx();
|
||||
|
||||
SubGhzLastSettings* last_settings = subghz_last_settings_alloc();
|
||||
subghz_last_settings_load(last_settings, 0);
|
||||
|
||||
if(last_settings->external_module_power_amp) {
|
||||
furi_hal_gpio_write(&gpio_ext_pc3, 1);
|
||||
}
|
||||
|
||||
subghz_last_settings_free(last_settings);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -161,6 +191,14 @@ void subghz_devices_set_rx(const SubGhzDevice* device) {
|
|||
furi_assert(device);
|
||||
if(device->interconnect->set_rx) {
|
||||
device->interconnect->set_rx();
|
||||
SubGhzLastSettings* last_settings = subghz_last_settings_alloc();
|
||||
subghz_last_settings_load(last_settings, 0);
|
||||
|
||||
if(last_settings->external_module_power_amp) {
|
||||
furi_hal_gpio_write(&gpio_ext_pc3, 0);
|
||||
}
|
||||
|
||||
subghz_last_settings_free(last_settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue