2023-02-02 22:47:50 +03:00
|
|
|
#include "../subghz_i.h"
|
|
|
|
#include "../helpers/subghz_custom_event.h"
|
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// #define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
|
|
|
// const char* const radio_modules_variables_text[] = {
|
|
|
|
// "Internal",
|
|
|
|
// "External",
|
|
|
|
// };
|
|
|
|
|
|
|
|
// #define EXT_MOD_POWER_COUNT 2
|
|
|
|
// const char* const ext_mod_power_text[EXT_MOD_POWER_COUNT] = {
|
|
|
|
// "ON",
|
|
|
|
// "OFF",
|
|
|
|
// };
|
2023-03-09 04:02:31 +03:00
|
|
|
|
2023-04-21 06:46:10 +03:00
|
|
|
#define TIMESTAMP_NAMES_COUNT 2
|
|
|
|
const char* const timestamp_names_text[TIMESTAMP_NAMES_COUNT] = {
|
|
|
|
"OFF",
|
|
|
|
"ON",
|
|
|
|
};
|
|
|
|
|
2023-02-09 22:41:12 +03:00
|
|
|
#define DEBUG_P_COUNT 2
|
|
|
|
const char* const debug_pin_text[DEBUG_P_COUNT] = {
|
|
|
|
"OFF",
|
2023-02-12 20:02:27 +03:00
|
|
|
"17(1W)",
|
2023-02-09 22:41:12 +03:00
|
|
|
};
|
|
|
|
|
2023-05-19 04:49:29 +03:00
|
|
|
#define DEBUG_COUNTER_COUNT 6
|
2023-02-25 22:28:35 +03:00
|
|
|
const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = {
|
|
|
|
"+1",
|
2023-02-28 06:19:21 +03:00
|
|
|
"+2",
|
|
|
|
"+3",
|
2023-05-19 04:49:29 +03:00
|
|
|
"+4",
|
|
|
|
"+5",
|
|
|
|
"+10",
|
2023-02-25 22:28:35 +03:00
|
|
|
};
|
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// static void subghz_scene_ext_module_changed(VariableItem* item) {
|
|
|
|
// SubGhz* subghz = variable_item_get_context(item);
|
|
|
|
// uint8_t value_index_exm = variable_item_get_current_value_index(item);
|
2023-02-02 22:47:50 +03:00
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// variable_item_set_current_value_text(item, radio_modules_variables_text[value_index_exm]);
|
2023-03-16 15:02:23 +03:00
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// subghz->last_settings->external_module_enabled = value_index_exm == 1;
|
|
|
|
// subghz_last_settings_save(subghz->last_settings);
|
|
|
|
// }
|
2023-03-16 15:02:23 +03:00
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// static void subghz_ext_module_start_var_list_enter_callback(void* context, uint32_t index) {
|
|
|
|
// SubGhz* subghz = context;
|
|
|
|
// view_dispatcher_send_custom_event(subghz->view_dispatcher, index);
|
|
|
|
// }
|
2023-02-02 22:47:50 +03:00
|
|
|
|
2023-02-09 22:41:12 +03:00
|
|
|
static void subghz_scene_receiver_config_set_debug_pin(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, debug_pin_text[index]);
|
2023-02-09 23:21:36 +03:00
|
|
|
|
2023-05-09 17:30:01 +03:00
|
|
|
subghz_txrx_set_debug_pin_state(subghz->txrx, index == 1);
|
2023-02-09 22:41:12 +03:00
|
|
|
}
|
|
|
|
|
2023-02-25 22:28:35 +03:00
|
|
|
static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) {
|
|
|
|
uint8_t index = variable_item_get_current_value_index(item);
|
|
|
|
|
|
|
|
variable_item_set_current_value_text(item, debug_counter_text[index]);
|
|
|
|
|
|
|
|
switch(index) {
|
|
|
|
case 0:
|
|
|
|
furi_hal_subghz_set_rolling_counter_mult(1);
|
|
|
|
break;
|
|
|
|
case 1:
|
2023-02-28 06:19:21 +03:00
|
|
|
furi_hal_subghz_set_rolling_counter_mult(2);
|
2023-02-25 22:28:35 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
2023-02-28 06:19:21 +03:00
|
|
|
furi_hal_subghz_set_rolling_counter_mult(3);
|
|
|
|
break;
|
2023-05-19 04:49:29 +03:00
|
|
|
case 3:
|
|
|
|
furi_hal_subghz_set_rolling_counter_mult(4);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
furi_hal_subghz_set_rolling_counter_mult(5);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
furi_hal_subghz_set_rolling_counter_mult(10);
|
|
|
|
break;
|
2023-02-25 22:28:35 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// static void subghz_scene_receiver_config_set_ext_mod_power(VariableItem* item) {
|
|
|
|
// SubGhz* subghz = variable_item_get_context(item);
|
|
|
|
// uint8_t index = variable_item_get_current_value_index(item);
|
2023-03-09 04:02:31 +03:00
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// variable_item_set_current_value_text(item, ext_mod_power_text[index]);
|
2023-03-09 04:02:31 +03:00
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// furi_hal_subghz_set_external_power_disable(index == 1);
|
|
|
|
// if(index == 1) {
|
|
|
|
// furi_hal_subghz_disable_ext_power();
|
|
|
|
// } else {
|
|
|
|
// furi_hal_subghz_enable_ext_power();
|
|
|
|
// }
|
2023-03-16 16:03:22 +03:00
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// subghz->last_settings->external_module_power_5v_disable = index == 1;
|
|
|
|
// subghz_last_settings_save(subghz->last_settings);
|
|
|
|
// }
|
2023-03-09 04:02:31 +03:00
|
|
|
|
2023-04-21 06:46:10 +03:00
|
|
|
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);
|
|
|
|
|
|
|
|
variable_item_set_current_value_text(item, timestamp_names_text[index]);
|
|
|
|
|
|
|
|
subghz->last_settings->timestamp_file_names = (index == 1);
|
|
|
|
subghz_last_settings_save(subghz->last_settings);
|
|
|
|
}
|
|
|
|
|
2023-05-11 03:54:53 +03:00
|
|
|
void subghz_scene_radio_settings_on_enter(void* context) {
|
2023-02-02 22:47:50 +03:00
|
|
|
SubGhz* subghz = context;
|
|
|
|
|
|
|
|
VariableItemList* variable_item_list = subghz->variable_item_list;
|
2023-05-11 03:50:55 +03:00
|
|
|
uint8_t value_index;
|
2023-06-18 20:25:40 +03:00
|
|
|
VariableItem* item;
|
|
|
|
|
|
|
|
// VariableItem* item = variable_item_list_add(
|
|
|
|
// variable_item_list, "Module", EXT_MODULES_COUNT, subghz_scene_ext_module_changed, subghz);
|
|
|
|
|
|
|
|
// variable_item_list_set_enter_callback(
|
|
|
|
// variable_item_list, subghz_ext_module_start_var_list_enter_callback, subghz);
|
|
|
|
// value_index = furi_hal_subghz.radio_type;
|
|
|
|
// variable_item_set_current_value_index(item, value_index);
|
|
|
|
// variable_item_set_current_value_text(item, radio_modules_variables_text[value_index]);
|
|
|
|
|
|
|
|
// item = variable_item_list_add(
|
2023-06-18 21:09:07 +03:00
|
|
|
// variable_item_list,
|
2023-06-18 20:25:40 +03:00
|
|
|
// "Ext Radio 5v",
|
|
|
|
// EXT_MOD_POWER_COUNT,
|
|
|
|
// subghz_scene_receiver_config_set_ext_mod_power,
|
|
|
|
// subghz);
|
|
|
|
// value_index = furi_hal_subghz_get_external_power_disable();
|
|
|
|
// variable_item_set_current_value_index(item, value_index);
|
|
|
|
// variable_item_set_current_value_text(item, ext_mod_power_text[value_index]);
|
2023-03-09 04:02:31 +03:00
|
|
|
|
2023-04-21 06:46:10 +03:00
|
|
|
item = variable_item_list_add(
|
2023-06-18 21:09:07 +03:00
|
|
|
variable_item_list,
|
2023-04-21 06:46:10 +03:00
|
|
|
"Time in names",
|
|
|
|
TIMESTAMP_NAMES_COUNT,
|
|
|
|
subghz_scene_receiver_config_set_timestamp_file_names,
|
|
|
|
subghz);
|
2023-06-14 01:07:07 +03:00
|
|
|
value_index = subghz->last_settings->timestamp_file_names;
|
2023-05-11 03:50:55 +03:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
|
|
|
variable_item_set_current_value_text(item, timestamp_names_text[value_index]);
|
2023-04-21 06:46:10 +03:00
|
|
|
|
2023-05-19 04:49:29 +03:00
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
item = variable_item_list_add(
|
2023-06-18 21:09:07 +03:00
|
|
|
variable_item_list,
|
2023-05-19 04:49:29 +03:00
|
|
|
"Counter incr.",
|
|
|
|
DEBUG_COUNTER_COUNT,
|
|
|
|
subghz_scene_receiver_config_set_debug_counter,
|
|
|
|
subghz);
|
|
|
|
switch(furi_hal_subghz_get_rolling_counter_mult()) {
|
|
|
|
case 1:
|
|
|
|
value_index = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
value_index = 1;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
value_index = 2;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
value_index = 3;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
value_index = 4;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
value_index = 5;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
item = variable_item_list_add(
|
2023-06-18 21:09:07 +03:00
|
|
|
variable_item_list,
|
2023-05-19 04:49:29 +03:00
|
|
|
"Counter incr.",
|
|
|
|
3,
|
|
|
|
subghz_scene_receiver_config_set_debug_counter,
|
|
|
|
subghz);
|
|
|
|
switch(furi_hal_subghz_get_rolling_counter_mult()) {
|
|
|
|
case 1:
|
|
|
|
value_index = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
value_index = 1;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
value_index = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Reset to default value
|
|
|
|
value_index = 0;
|
|
|
|
furi_hal_subghz_set_rolling_counter_mult(1);
|
|
|
|
break;
|
|
|
|
}
|
2023-05-11 03:05:04 +03:00
|
|
|
}
|
2023-05-11 03:50:55 +03:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
|
|
|
variable_item_set_current_value_text(item, debug_counter_text[value_index]);
|
2023-05-11 03:05:04 +03:00
|
|
|
|
2023-02-09 22:41:12 +03:00
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
item = variable_item_list_add(
|
2023-06-18 21:09:07 +03:00
|
|
|
variable_item_list,
|
2023-03-09 04:02:31 +03:00
|
|
|
"Debug Pin",
|
2023-02-09 22:41:12 +03:00
|
|
|
DEBUG_P_COUNT,
|
|
|
|
subghz_scene_receiver_config_set_debug_pin,
|
|
|
|
subghz);
|
2023-05-11 03:50:55 +03:00
|
|
|
value_index = subghz_txrx_get_debug_pin_state(subghz->txrx);
|
|
|
|
variable_item_set_current_value_index(item, value_index);
|
|
|
|
variable_item_set_current_value_text(item, debug_pin_text[value_index]);
|
2023-02-09 22:41:12 +03:00
|
|
|
}
|
|
|
|
|
2023-02-02 22:47:50 +03:00
|
|
|
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
|
|
|
|
}
|
|
|
|
|
2023-05-11 03:54:53 +03:00
|
|
|
bool subghz_scene_radio_settings_on_event(void* context, SceneManagerEvent event) {
|
2023-02-02 22:47:50 +03:00
|
|
|
SubGhz* subghz = context;
|
|
|
|
UNUSED(subghz);
|
|
|
|
UNUSED(event);
|
|
|
|
|
2023-02-09 23:21:36 +03:00
|
|
|
// Set selected radio module
|
2023-06-18 20:25:40 +03:00
|
|
|
// furi_hal_subghz_select_radio_type(subghz->last_settings->external_module_enabled);
|
|
|
|
// furi_hal_subghz_init_radio_type(subghz->last_settings->external_module_enabled);
|
2023-02-03 17:20:10 +03:00
|
|
|
|
2023-06-18 20:25:40 +03:00
|
|
|
// furi_hal_subghz_enable_ext_power();
|
2023-03-08 01:09:17 +03:00
|
|
|
|
2023-02-09 23:21:36 +03:00
|
|
|
// Check if module is present, if no -> show error
|
2023-06-18 20:25:40 +03:00
|
|
|
// if(!furi_hal_subghz_check_radio()) {
|
|
|
|
// subghz->last_settings->external_module_enabled = false;
|
|
|
|
// furi_hal_subghz_select_radio_type(SubGhzRadioInternal);
|
|
|
|
// furi_hal_subghz_init_radio_type(SubGhzRadioInternal);
|
|
|
|
// furi_string_set(subghz->error_str, "Please connect\nexternal radio");
|
|
|
|
// scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
|
|
|
// }
|
2023-02-09 23:56:36 +03:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-05-11 03:54:53 +03:00
|
|
|
void subghz_scene_radio_settings_on_exit(void* context) {
|
2023-02-09 23:56:36 +03:00
|
|
|
SubGhz* subghz = context;
|
|
|
|
variable_item_list_reset(subghz->variable_item_list);
|
2023-02-02 22:47:50 +03:00
|
|
|
}
|