2021-09-10 00:29:57 +00:00
|
|
|
#include "../subghz_i.h"
|
2022-10-26 15:13:00 +00:00
|
|
|
#include <lib/toolbox/value_index.h>
|
2021-09-10 00:29:57 +00:00
|
|
|
|
2023-08-04 14:52:16 +00:00
|
|
|
#define TAG "SubGhzSceneReceiverConfig"
|
|
|
|
|
2022-07-03 16:03:36 +00:00
|
|
|
enum SubGhzSettingIndex {
|
|
|
|
SubGhzSettingIndexFrequency,
|
|
|
|
SubGhzSettingIndexHopping,
|
|
|
|
SubGhzSettingIndexModulation,
|
2023-02-09 04:48:06 +00:00
|
|
|
SubGhzSettingIndexBinRAW,
|
2023-04-07 08:49:10 +00:00
|
|
|
SubGhzSettingIndexIgnoreStarline,
|
2023-04-19 16:19:26 +00:00
|
|
|
SubGhzSettingIndexIgnoreCars,
|
|
|
|
SubGhzSettingIndexIgnoreMagellan,
|
2023-09-11 19:27:27 +00:00
|
|
|
SubGhzSettingIndexIgnorePrinceton,
|
2022-12-16 22:20:10 +00:00
|
|
|
SubGhzSettingIndexSound,
|
2023-09-09 22:35:27 +00:00
|
|
|
SubGhzSettingIndexResetToDefault,
|
2022-07-03 16:03:36 +00:00
|
|
|
SubGhzSettingIndexLock,
|
2023-02-20 15:55:53 +00:00
|
|
|
SubGhzSettingIndexRAWThresholdRSSI,
|
2022-10-26 15:13:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define RAW_THRESHOLD_RSSI_COUNT 11
|
2023-02-20 15:55:53 +00:00
|
|
|
const char* const raw_threshold_rssi_text[RAW_THRESHOLD_RSSI_COUNT] = {
|
2022-10-26 15:13:00 +00:00
|
|
|
"-----",
|
|
|
|
"-85.0",
|
|
|
|
"-80.0",
|
|
|
|
"-75.0",
|
|
|
|
"-70.0",
|
|
|
|
"-65.0",
|
|
|
|
"-60.0",
|
|
|
|
"-55.0",
|
|
|
|
"-50.0",
|
|
|
|
"-45.0",
|
|
|
|
"-40.0",
|
|
|
|
|
|
|
|
};
|
2023-02-20 15:55:53 +00:00
|
|
|
const float raw_threshold_rssi_value[RAW_THRESHOLD_RSSI_COUNT] = {
|
2022-10-26 15:13:00 +00:00
|
|
|
-90.0f,
|
|
|
|
-85.0f,
|
|
|
|
-80.0f,
|
|
|
|
-75.0f,
|
|
|
|
-70.0f,
|
|
|
|
-65.0f,
|
|
|
|
-60.0f,
|
|
|
|
-55.0f,
|
|
|
|
-50.0f,
|
|
|
|
-45.0f,
|
|
|
|
-40.0f,
|
2022-07-03 16:03:36 +00:00
|
|
|
};
|
|
|
|
|
2023-08-08 04:58:20 +00:00
|
|
|
#define COMBO_BOX_COUNT 2
|
|
|
|
|
|
|
|
const uint32_t hopping_value[COMBO_BOX_COUNT] = {
|
2021-09-10 00:29:57 +00:00
|
|
|
SubGhzHopperStateOFF,
|
2023-02-20 15:55:53 +00:00
|
|
|
SubGhzHopperStateRunning,
|
2021-09-10 00:29:57 +00:00
|
|
|
};
|
|
|
|
|
2023-08-08 04:58:20 +00:00
|
|
|
const uint32_t speaker_value[COMBO_BOX_COUNT] = {
|
2022-12-16 22:20:10 +00:00
|
|
|
SubGhzSpeakerStateShutdown,
|
|
|
|
SubGhzSpeakerStateEnable,
|
|
|
|
};
|
2023-08-08 04:58:20 +00:00
|
|
|
|
|
|
|
const uint32_t bin_raw_value[COMBO_BOX_COUNT] = {
|
2023-02-09 04:48:06 +00:00
|
|
|
SubGhzProtocolFlag_Decodable,
|
|
|
|
SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_BinRAW,
|
|
|
|
};
|
2023-08-08 04:58:20 +00:00
|
|
|
|
|
|
|
const char* const combobox_text[COMBO_BOX_COUNT] = {
|
2023-04-19 16:19:26 +00:00
|
|
|
"OFF",
|
|
|
|
"ON",
|
2023-04-04 19:42:55 +00:00
|
|
|
};
|
2022-12-16 22:20:10 +00:00
|
|
|
|
2023-08-08 04:58:20 +00:00
|
|
|
static void
|
|
|
|
subghz_scene_receiver_config_set_ignore_filter(VariableItem* item, SubGhzProtocolFlag filter) {
|
|
|
|
SubGhz* subghz = variable_item_get_context(item);
|
|
|
|
uint8_t index = variable_item_get_current_value_index(item);
|
|
|
|
|
|
|
|
variable_item_set_current_value_text(item, combobox_text[index]);
|
|
|
|
|
|
|
|
if(index == 0) {
|
|
|
|
CLEAR_BIT(subghz->ignore_filter, filter);
|
|
|
|
} else {
|
|
|
|
SET_BIT(subghz->ignore_filter, filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
subghz->last_settings->ignore_filter = subghz->ignore_filter;
|
|
|
|
}
|
|
|
|
|
2022-07-26 14:16:59 +00:00
|
|
|
uint8_t subghz_scene_receiver_config_next_frequency(const uint32_t value, void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SubGhz* subghz = context;
|
2023-05-09 17:19:01 +00:00
|
|
|
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
|
|
|
|
2023-05-10 10:21:42 +00:00
|
|
|
uint8_t index = 0;
|
2023-08-08 04:58:20 +00:00
|
|
|
for(size_t i = 0; i < subghz_setting_get_frequency_count(setting); i++) {
|
2023-05-09 17:19:01 +00:00
|
|
|
if(value == subghz_setting_get_frequency(setting, i)) {
|
2021-09-10 00:29:57 +00:00
|
|
|
index = i;
|
|
|
|
break;
|
2022-07-26 14:16:59 +00:00
|
|
|
} else {
|
2023-05-09 17:19:01 +00:00
|
|
|
index = subghz_setting_get_frequency_default_index(setting);
|
2021-09-10 00:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2022-07-26 14:16:59 +00:00
|
|
|
uint8_t subghz_scene_receiver_config_next_preset(const char* preset_name, void* context) {
|
2022-04-14 14:05:40 +00:00
|
|
|
furi_assert(context);
|
|
|
|
SubGhz* subghz = context;
|
|
|
|
uint8_t index = 0;
|
2023-05-09 17:19:01 +00:00
|
|
|
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
|
|
|
|
2023-08-08 04:58:20 +00:00
|
|
|
for(size_t i = 0; i < subghz_setting_get_preset_count(setting); i++) {
|
2023-05-09 17:19:01 +00:00
|
|
|
if(!strcmp(subghz_setting_get_preset_name(setting, i), preset_name)) {
|
2022-04-14 14:05:40 +00:00
|
|
|
index = i;
|
|
|
|
break;
|
2022-06-09 07:39:12 +00:00
|
|
|
} else {
|
2023-05-09 17:19:01 +00:00
|
|
|
// index = subghz_setting_get_frequency_default_index(setting);
|
2022-04-14 14:05:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2023-08-04 14:52:16 +00:00
|
|
|
SubGhzHopperState subghz_scene_receiver_config_hopper_value_index(void* context) {
|
2021-09-10 00:29:57 +00:00
|
|
|
furi_assert(context);
|
|
|
|
SubGhz* subghz = context;
|
|
|
|
|
2023-08-04 14:52:16 +00:00
|
|
|
if(subghz_txrx_hopper_get_state(subghz->txrx) == SubGhzHopperStateOFF) {
|
|
|
|
return SubGhzHopperStateOFF;
|
2021-09-10 00:29:57 +00:00
|
|
|
} else {
|
|
|
|
variable_item_set_current_value_text(
|
|
|
|
(VariableItem*)scene_manager_get_scene_state(
|
|
|
|
subghz->scene_manager, SubGhzSceneReceiverConfig),
|
|
|
|
" -----");
|
2023-08-04 14:52:16 +00:00
|
|
|
return SubGhzHopperStateRunning;
|
2021-09-10 00:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subghz_scene_receiver_config_set_frequency(VariableItem* item) {
|
|
|
|
SubGhz* subghz = variable_item_get_context(item);
|
|
|
|
uint8_t index = variable_item_get_current_value_index(item);
|
2023-05-09 17:19:01 +00:00
|
|
|
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
2021-09-10 00:29:57 +00:00
|
|
|
|
2023-05-09 16:10:56 +00:00
|
|
|
if(subghz_txrx_hopper_get_state(subghz->txrx) == SubGhzHopperStateOFF) {
|
2022-04-14 14:05:40 +00:00
|
|
|
char text_buf[10] = {0};
|
2023-05-09 18:20:35 +00:00
|
|
|
uint32_t frequency = subghz_setting_get_frequency(setting, index);
|
|
|
|
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
|
|
|
|
2022-08-03 16:00:17 +00:00
|
|
|
snprintf(
|
2022-04-14 14:05:40 +00:00
|
|
|
text_buf,
|
2022-08-03 16:00:17 +00:00
|
|
|
sizeof(text_buf),
|
2022-04-14 14:05:40 +00:00
|
|
|
"%lu.%02lu",
|
2023-05-09 18:20:35 +00:00
|
|
|
frequency / 1000000,
|
|
|
|
(frequency % 1000000) / 10000);
|
2022-04-14 14:05:40 +00:00
|
|
|
variable_item_set_current_value_text(item, text_buf);
|
2023-05-09 16:10:56 +00:00
|
|
|
subghz_txrx_set_preset(
|
2023-05-09 12:11:54 +00:00
|
|
|
subghz->txrx,
|
|
|
|
furi_string_get_cstr(preset.name),
|
2023-05-09 18:20:35 +00:00
|
|
|
frequency,
|
2023-05-09 12:11:54 +00:00
|
|
|
preset.data,
|
|
|
|
preset.data_size);
|
|
|
|
|
2023-05-09 16:10:56 +00:00
|
|
|
preset = subghz_txrx_get_preset(subghz->txrx);
|
2023-05-09 12:11:54 +00:00
|
|
|
|
|
|
|
subghz->last_settings->frequency = preset.frequency;
|
2023-05-09 17:19:01 +00:00
|
|
|
subghz_setting_set_default_frequency(setting, preset.frequency);
|
2021-10-25 14:37:14 +00:00
|
|
|
} else {
|
2022-04-14 14:05:40 +00:00
|
|
|
variable_item_set_current_value_index(
|
2023-05-09 17:19:01 +00:00
|
|
|
item, subghz_setting_get_frequency_default_index(setting));
|
2021-09-10 00:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subghz_scene_receiver_config_set_preset(VariableItem* item) {
|
|
|
|
SubGhz* subghz = variable_item_get_context(item);
|
|
|
|
uint8_t index = variable_item_get_current_value_index(item);
|
2023-05-09 18:20:35 +00:00
|
|
|
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
|
|
|
|
|
|
|
const char* preset_name = subghz_setting_get_preset_name(setting, index);
|
2022-09-27 22:01:09 +00:00
|
|
|
variable_item_set_current_value_text(item, preset_name);
|
2022-10-26 23:56:21 +00:00
|
|
|
//subghz->last_settings->preset = index;
|
2023-05-09 16:10:56 +00:00
|
|
|
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
|
|
|
subghz_txrx_set_preset(
|
2023-05-09 09:07:36 +00:00
|
|
|
subghz->txrx,
|
2022-09-27 22:01:09 +00:00
|
|
|
preset_name,
|
2023-05-09 12:11:54 +00:00
|
|
|
preset.frequency,
|
2023-05-09 18:20:35 +00:00
|
|
|
subghz_setting_get_preset_data(setting, index),
|
|
|
|
subghz_setting_get_preset_data_size(setting, index));
|
2023-08-08 04:58:20 +00:00
|
|
|
subghz->last_settings->preset_index = index;
|
2021-09-10 00:29:57 +00:00
|
|
|
}
|
|
|
|
|
2022-08-17 16:40:09 +00:00
|
|
|
static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) {
|
2021-09-10 00:29:57 +00:00
|
|
|
SubGhz* subghz = variable_item_get_context(item);
|
2023-08-04 14:52:16 +00:00
|
|
|
SubGhzHopperState index = variable_item_get_current_value_index(item);
|
2023-05-09 17:19:01 +00:00
|
|
|
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
|
|
|
VariableItem* frequency_item = (VariableItem*)scene_manager_get_scene_state(
|
|
|
|
subghz->scene_manager, SubGhzSceneReceiverConfig);
|
2021-09-10 00:29:57 +00:00
|
|
|
|
2023-08-08 04:58:20 +00:00
|
|
|
variable_item_set_current_value_text(item, combobox_text[(uint8_t)index]);
|
2023-08-04 14:52:16 +00:00
|
|
|
|
|
|
|
if(index == SubGhzHopperStateOFF) {
|
2023-02-09 14:21:40 +00:00
|
|
|
char text_buf[10] = {0};
|
2023-05-09 17:19:01 +00:00
|
|
|
uint32_t frequency = subghz_setting_get_default_frequency(setting);
|
2023-05-09 18:20:35 +00:00
|
|
|
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
|
|
|
|
2023-02-09 14:21:40 +00:00
|
|
|
snprintf(
|
|
|
|
text_buf,
|
|
|
|
sizeof(text_buf),
|
|
|
|
"%lu.%02lu",
|
2023-05-09 17:19:01 +00:00
|
|
|
frequency / 1000000,
|
|
|
|
(frequency % 1000000) / 10000);
|
|
|
|
variable_item_set_current_value_text(frequency_item, text_buf);
|
2023-05-09 18:20:35 +00:00
|
|
|
|
2023-08-04 14:52:16 +00:00
|
|
|
// Maybe better add one more function with only with the frequency argument?
|
2023-05-09 16:10:56 +00:00
|
|
|
subghz_txrx_set_preset(
|
2023-05-09 12:11:54 +00:00
|
|
|
subghz->txrx,
|
|
|
|
furi_string_get_cstr(preset.name),
|
2023-05-09 17:19:01 +00:00
|
|
|
frequency,
|
2023-05-09 12:11:54 +00:00
|
|
|
preset.data,
|
|
|
|
preset.data_size);
|
2023-02-09 14:21:40 +00:00
|
|
|
variable_item_set_current_value_index(
|
2023-05-09 17:19:01 +00:00
|
|
|
frequency_item, subghz_setting_get_frequency_default_index(setting));
|
2023-01-19 13:27:07 +00:00
|
|
|
} else {
|
2023-05-09 17:19:01 +00:00
|
|
|
variable_item_set_current_value_text(frequency_item, " -----");
|
2023-02-09 14:21:40 +00:00
|
|
|
variable_item_set_current_value_index(
|
2023-05-09 17:19:01 +00:00
|
|
|
frequency_item, subghz_setting_get_frequency_default_index(setting));
|
2023-01-19 13:27:07 +00:00
|
|
|
}
|
2023-08-04 14:52:16 +00:00
|
|
|
subghz->last_settings->enable_hopping = index != SubGhzHopperStateOFF;
|
|
|
|
subghz_txrx_hopper_set_state(subghz->txrx, index);
|
2021-09-10 00:29:57 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 22:20:10 +00:00
|
|
|
static void subghz_scene_receiver_config_set_speaker(VariableItem* item) {
|
|
|
|
SubGhz* subghz = variable_item_get_context(item);
|
|
|
|
uint8_t index = variable_item_get_current_value_index(item);
|
|
|
|
|
2023-08-08 04:58:20 +00:00
|
|
|
variable_item_set_current_value_text(item, combobox_text[index]);
|
2023-05-09 16:10:56 +00:00
|
|
|
subghz_txrx_speaker_set_state(subghz->txrx, speaker_value[index]);
|
2022-12-16 22:20:10 +00:00
|
|
|
}
|
|
|
|
|
2023-02-09 04:48:06 +00:00
|
|
|
static void subghz_scene_receiver_config_set_bin_raw(VariableItem* item) {
|
|
|
|
SubGhz* subghz = variable_item_get_context(item);
|
|
|
|
uint8_t index = variable_item_get_current_value_index(item);
|
|
|
|
|
2023-08-08 04:58:20 +00:00
|
|
|
variable_item_set_current_value_text(item, combobox_text[index]);
|
2023-05-09 12:58:56 +00:00
|
|
|
subghz->filter = bin_raw_value[index];
|
|
|
|
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
2023-08-08 04:58:20 +00:00
|
|
|
|
2023-08-25 03:48:04 +00:00
|
|
|
// We can set here, but during subghz_last_settings_save filter was changed to ignore BinRAW
|
2023-08-08 04:58:20 +00:00
|
|
|
subghz->last_settings->filter = subghz->filter;
|
2023-02-09 04:48:06 +00:00
|
|
|
}
|
|
|
|
|
2022-10-26 15:13:00 +00:00
|
|
|
static void subghz_scene_receiver_config_set_raw_threshold_rssi(VariableItem* item) {
|
|
|
|
SubGhz* subghz = variable_item_get_context(item);
|
|
|
|
uint8_t index = variable_item_get_current_value_index(item);
|
|
|
|
|
2023-02-20 15:55:53 +00:00
|
|
|
variable_item_set_current_value_text(item, raw_threshold_rssi_text[index]);
|
2023-05-05 23:00:26 +00:00
|
|
|
subghz_threshold_rssi_set(subghz->threshold_rssi, raw_threshold_rssi_value[index]);
|
2022-10-26 15:13:00 +00:00
|
|
|
|
2023-08-08 04:58:20 +00:00
|
|
|
subghz->last_settings->rssi = raw_threshold_rssi_value[index];
|
2023-06-13 22:24:05 +00:00
|
|
|
}
|
2023-08-08 04:58:20 +00:00
|
|
|
|
2023-06-13 22:24:05 +00:00
|
|
|
static inline bool subghz_scene_receiver_config_ignore_filter_get_index(
|
|
|
|
SubGhzProtocolFlag filter,
|
|
|
|
SubGhzProtocolFlag flag) {
|
|
|
|
return READ_BIT(filter, flag) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subghz_scene_receiver_config_set_starline(VariableItem* item) {
|
|
|
|
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_StarLine);
|
2023-04-19 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void subghz_scene_receiver_config_set_auto_alarms(VariableItem* item) {
|
2023-06-13 22:24:05 +00:00
|
|
|
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_AutoAlarms);
|
2023-04-19 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void subghz_scene_receiver_config_set_magellan(VariableItem* item) {
|
2023-09-11 14:03:17 +00:00
|
|
|
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_Magellan);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subghz_scene_receiver_config_set_princeton(VariableItem* item) {
|
|
|
|
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_Princeton);
|
2023-04-04 19:42:55 +00:00
|
|
|
}
|
|
|
|
|
2023-10-03 14:56:39 +00:00
|
|
|
static void subghz_scene_receiver_config_set_niceflors(VariableItem* item) {
|
|
|
|
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_NiceFlorS);
|
|
|
|
}
|
|
|
|
|
2022-07-03 16:03:36 +00:00
|
|
|
static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
|
|
|
|
furi_assert(context);
|
|
|
|
SubGhz* subghz = context;
|
|
|
|
if(index == SubGhzSettingIndexLock) {
|
|
|
|
view_dispatcher_send_custom_event(
|
|
|
|
subghz->view_dispatcher, SubGhzCustomEventSceneSettingLock);
|
2023-09-09 22:35:27 +00:00
|
|
|
} else if(index == SubGhzSettingIndexResetToDefault) {
|
|
|
|
// Reset all values to default state!
|
|
|
|
#if SUBGHZ_LAST_SETTING_SAVE_PRESET
|
|
|
|
subghz_txrx_set_preset_internal(
|
|
|
|
subghz->txrx,
|
|
|
|
SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY,
|
|
|
|
SUBGHZ_LAST_SETTING_DEFAULT_PRESET);
|
|
|
|
#else
|
|
|
|
subghz_txrx_set_default_preset(subghz->txrx, SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY);
|
|
|
|
#endif
|
|
|
|
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
|
|
|
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
|
|
|
const char* preset_name = furi_string_get_cstr(preset.name);
|
|
|
|
int preset_index = subghz_setting_get_inx_preset_by_name(setting, preset_name);
|
|
|
|
const int default_index = 0;
|
|
|
|
|
|
|
|
subghz->last_settings->frequency = preset.frequency;
|
|
|
|
subghz->last_settings->preset_index = preset_index;
|
|
|
|
|
|
|
|
subghz_threshold_rssi_set(subghz->threshold_rssi, raw_threshold_rssi_value[default_index]);
|
|
|
|
subghz->filter = bin_raw_value[0];
|
|
|
|
subghz->ignore_filter = 0x00;
|
|
|
|
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
|
|
|
subghz->last_settings->ignore_filter = subghz->ignore_filter;
|
|
|
|
subghz->last_settings->filter = subghz->filter;
|
|
|
|
|
|
|
|
subghz_txrx_speaker_set_state(subghz->txrx, speaker_value[default_index]);
|
|
|
|
|
|
|
|
subghz_txrx_hopper_set_state(subghz->txrx, hopping_value[default_index]);
|
|
|
|
subghz->last_settings->enable_hopping = hopping_value[default_index];
|
|
|
|
|
|
|
|
variable_item_list_set_selected_item(subghz->variable_item_list, default_index);
|
|
|
|
variable_item_list_reset(subghz->variable_item_list);
|
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
subghz_last_settings_log(subghz->last_settings);
|
|
|
|
#endif
|
|
|
|
subghz_last_settings_save(subghz->last_settings);
|
|
|
|
|
|
|
|
view_dispatcher_send_custom_event(
|
|
|
|
subghz->view_dispatcher, SubGhzCustomEventSceneSettingResetToDefault);
|
2022-07-03 16:03:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-21 09:34:16 +00:00
|
|
|
void subghz_scene_receiver_config_on_enter(void* context) {
|
2021-09-10 00:29:57 +00:00
|
|
|
SubGhz* subghz = context;
|
|
|
|
VariableItem* item;
|
|
|
|
uint8_t value_index;
|
2023-05-09 18:20:35 +00:00
|
|
|
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
2023-05-09 16:10:56 +00:00
|
|
|
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
2021-09-10 00:29:57 +00:00
|
|
|
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
2023-10-03 14:56:39 +00:00
|
|
|
"Frequency",
|
2023-05-09 18:20:35 +00:00
|
|
|
subghz_setting_get_frequency_count(setting),
|
2021-09-10 00:29:57 +00:00
|
|
|
subghz_scene_receiver_config_set_frequency,
|
|
|
|
subghz);
|
2023-05-09 12:11:54 +00:00
|
|
|
value_index = subghz_scene_receiver_config_next_frequency(preset.frequency, subghz);
|
2022-09-28 03:02:23 +00:00
|
|
|
scene_manager_set_scene_state(
|
|
|
|
subghz->scene_manager, SubGhzSceneReceiverConfig, (uint32_t)item);
|
2021-09-10 00:29:57 +00:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
2022-04-14 14:05:40 +00:00
|
|
|
char text_buf[10] = {0};
|
2023-05-10 10:21:42 +00:00
|
|
|
uint32_t frequency = subghz_setting_get_frequency(setting, value_index);
|
2022-08-03 16:00:17 +00:00
|
|
|
snprintf(
|
2022-04-14 14:05:40 +00:00
|
|
|
text_buf,
|
2022-08-03 16:00:17 +00:00
|
|
|
sizeof(text_buf),
|
2022-04-14 14:05:40 +00:00
|
|
|
"%lu.%02lu",
|
2023-05-10 10:21:42 +00:00
|
|
|
frequency / 1000000,
|
|
|
|
(frequency % 1000000) / 10000);
|
2022-04-14 14:05:40 +00:00
|
|
|
variable_item_set_current_value_text(item, text_buf);
|
2021-09-10 00:29:57 +00:00
|
|
|
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
2023-10-03 14:56:39 +00:00
|
|
|
"Modulation",
|
2023-05-09 18:20:35 +00:00
|
|
|
subghz_setting_get_preset_count(setting),
|
2021-09-10 00:29:57 +00:00
|
|
|
subghz_scene_receiver_config_set_preset,
|
|
|
|
subghz);
|
2023-05-09 12:11:54 +00:00
|
|
|
value_index =
|
|
|
|
subghz_scene_receiver_config_next_preset(furi_string_get_cstr(preset.name), subghz);
|
2021-09-10 00:29:57 +00:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
2022-07-26 14:16:59 +00:00
|
|
|
variable_item_set_current_value_text(
|
2023-05-09 18:20:35 +00:00
|
|
|
item, subghz_setting_get_preset_name(setting, value_index));
|
2021-09-10 00:29:57 +00:00
|
|
|
|
2022-09-14 13:01:30 +00:00
|
|
|
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
|
|
|
SubGhzCustomEventManagerSet) {
|
2022-09-27 22:01:09 +00:00
|
|
|
// Hopping
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
2023-10-03 14:56:39 +00:00
|
|
|
"Hopping",
|
2023-08-08 04:58:20 +00:00
|
|
|
COMBO_BOX_COUNT,
|
2022-09-27 22:01:09 +00:00
|
|
|
subghz_scene_receiver_config_set_hopping_running,
|
|
|
|
subghz);
|
2023-08-04 14:52:16 +00:00
|
|
|
value_index = subghz_scene_receiver_config_hopper_value_index(subghz);
|
|
|
|
|
2022-09-27 22:01:09 +00:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
2023-08-08 04:58:20 +00:00
|
|
|
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
2023-02-08 15:48:28 +00:00
|
|
|
}
|
2023-02-09 14:21:40 +00:00
|
|
|
|
2023-02-09 04:48:06 +00:00
|
|
|
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
|
|
|
SubGhzCustomEventManagerSet) {
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
2023-10-03 14:56:39 +00:00
|
|
|
"Bin RAW",
|
2023-08-08 04:58:20 +00:00
|
|
|
COMBO_BOX_COUNT,
|
2023-02-09 04:48:06 +00:00
|
|
|
subghz_scene_receiver_config_set_bin_raw,
|
|
|
|
subghz);
|
2023-08-08 04:58:20 +00:00
|
|
|
|
|
|
|
value_index = value_index_uint32(subghz->filter, bin_raw_value, COMBO_BOX_COUNT);
|
2023-02-09 04:48:06 +00:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
2023-08-08 04:58:20 +00:00
|
|
|
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
2023-02-09 04:48:06 +00:00
|
|
|
}
|
|
|
|
|
2023-04-04 19:42:55 +00:00
|
|
|
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
|
|
|
SubGhzCustomEventManagerSet) {
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
2023-10-03 14:56:39 +00:00
|
|
|
"Ignore Starline",
|
2023-08-08 04:58:20 +00:00
|
|
|
COMBO_BOX_COUNT,
|
2023-04-04 19:42:55 +00:00
|
|
|
subghz_scene_receiver_config_set_starline,
|
|
|
|
subghz);
|
|
|
|
|
2023-06-13 22:24:05 +00:00
|
|
|
value_index = subghz_scene_receiver_config_ignore_filter_get_index(
|
|
|
|
subghz->ignore_filter, SubGhzProtocolFlag_StarLine);
|
2023-04-19 16:19:26 +00:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
2023-08-08 04:58:20 +00:00
|
|
|
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
2023-04-19 16:19:26 +00:00
|
|
|
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
2023-10-03 14:56:39 +00:00
|
|
|
"Ignore Cars",
|
2023-08-08 04:58:20 +00:00
|
|
|
COMBO_BOX_COUNT,
|
2023-04-19 16:19:26 +00:00
|
|
|
subghz_scene_receiver_config_set_auto_alarms,
|
|
|
|
subghz);
|
|
|
|
|
2023-06-13 22:24:05 +00:00
|
|
|
value_index = subghz_scene_receiver_config_ignore_filter_get_index(
|
|
|
|
subghz->ignore_filter, SubGhzProtocolFlag_AutoAlarms);
|
2023-04-19 16:19:26 +00:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
2023-08-08 04:58:20 +00:00
|
|
|
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
2023-04-19 16:19:26 +00:00
|
|
|
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
2023-10-03 14:56:39 +00:00
|
|
|
"Ignore Magellan",
|
2023-08-08 04:58:20 +00:00
|
|
|
COMBO_BOX_COUNT,
|
2023-04-19 16:19:26 +00:00
|
|
|
subghz_scene_receiver_config_set_magellan,
|
|
|
|
subghz);
|
|
|
|
|
2023-06-13 22:24:05 +00:00
|
|
|
value_index = subghz_scene_receiver_config_ignore_filter_get_index(
|
2023-09-11 14:03:17 +00:00
|
|
|
subghz->ignore_filter, SubGhzProtocolFlag_Magellan);
|
|
|
|
variable_item_set_current_value_index(item, value_index);
|
|
|
|
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
|
|
|
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
2023-10-03 14:56:39 +00:00
|
|
|
"Ignore Princeton",
|
2023-09-11 14:03:17 +00:00
|
|
|
COMBO_BOX_COUNT,
|
|
|
|
subghz_scene_receiver_config_set_princeton,
|
|
|
|
subghz);
|
|
|
|
|
|
|
|
value_index = subghz_scene_receiver_config_ignore_filter_get_index(
|
|
|
|
subghz->ignore_filter, SubGhzProtocolFlag_Princeton);
|
2023-04-04 19:42:55 +00:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
2023-08-08 04:58:20 +00:00
|
|
|
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
2023-10-03 14:56:39 +00:00
|
|
|
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
|
|
|
"Ignore NiceFloRS",
|
|
|
|
COMBO_BOX_COUNT,
|
|
|
|
subghz_scene_receiver_config_set_niceflors,
|
|
|
|
subghz);
|
|
|
|
|
|
|
|
value_index = subghz_scene_receiver_config_ignore_filter_get_index(
|
|
|
|
subghz->ignore_filter, SubGhzProtocolFlag_NiceFlorS);
|
|
|
|
variable_item_set_current_value_index(item, value_index);
|
|
|
|
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
2023-04-04 19:42:55 +00:00
|
|
|
}
|
|
|
|
|
2023-02-09 14:49:28 +00:00
|
|
|
// Enable speaker, will send all incoming noises and signals to speaker so you can listen how your remote sounds like :)
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
2023-02-08 15:48:28 +00:00
|
|
|
"Sound:",
|
2023-08-08 04:58:20 +00:00
|
|
|
COMBO_BOX_COUNT,
|
2023-02-08 15:48:28 +00:00
|
|
|
subghz_scene_receiver_config_set_speaker,
|
|
|
|
subghz);
|
2023-05-09 17:19:01 +00:00
|
|
|
value_index = value_index_uint32(
|
2023-08-08 04:58:20 +00:00
|
|
|
subghz_txrx_speaker_get_state(subghz->txrx), speaker_value, COMBO_BOX_COUNT);
|
2023-02-08 15:48:28 +00:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
2023-08-08 04:58:20 +00:00
|
|
|
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
2022-09-14 13:01:30 +00:00
|
|
|
|
2023-09-09 22:35:27 +00:00
|
|
|
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
|
|
|
SubGhzCustomEventManagerSet) {
|
|
|
|
// Reset to default
|
|
|
|
variable_item_list_add(subghz->variable_item_list, "Reset to default", 1, NULL, NULL);
|
|
|
|
|
|
|
|
variable_item_list_set_enter_callback(
|
|
|
|
subghz->variable_item_list,
|
|
|
|
subghz_scene_receiver_config_var_list_enter_callback,
|
|
|
|
subghz);
|
|
|
|
}
|
2023-02-08 15:48:28 +00:00
|
|
|
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
|
|
|
SubGhzCustomEventManagerSet) {
|
2022-09-27 22:01:09 +00:00
|
|
|
// Lock keyboard
|
2022-07-03 16:03:36 +00:00
|
|
|
variable_item_list_add(subghz->variable_item_list, "Lock Keyboard", 1, NULL, NULL);
|
|
|
|
variable_item_list_set_enter_callback(
|
|
|
|
subghz->variable_item_list,
|
|
|
|
subghz_scene_receiver_config_var_list_enter_callback,
|
|
|
|
subghz);
|
|
|
|
}
|
2023-09-09 22:35:27 +00:00
|
|
|
|
2022-10-26 15:13:00 +00:00
|
|
|
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) ==
|
|
|
|
SubGhzCustomEventManagerSet) {
|
|
|
|
item = variable_item_list_add(
|
|
|
|
subghz->variable_item_list,
|
|
|
|
"RSSI Threshold:",
|
|
|
|
RAW_THRESHOLD_RSSI_COUNT,
|
|
|
|
subghz_scene_receiver_config_set_raw_threshold_rssi,
|
|
|
|
subghz);
|
|
|
|
value_index = value_index_float(
|
2023-05-05 23:00:26 +00:00
|
|
|
subghz_threshold_rssi_get(subghz->threshold_rssi),
|
|
|
|
raw_threshold_rssi_value,
|
|
|
|
RAW_THRESHOLD_RSSI_COUNT);
|
2022-10-26 15:13:00 +00:00
|
|
|
variable_item_set_current_value_index(item, value_index);
|
2023-02-20 15:55:53 +00:00
|
|
|
variable_item_set_current_value_text(item, raw_threshold_rssi_text[value_index]);
|
2022-10-26 15:13:00 +00:00
|
|
|
}
|
2022-03-03 09:48:56 +00:00
|
|
|
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
|
2021-09-10 00:29:57 +00:00
|
|
|
}
|
|
|
|
|
2021-09-21 09:34:16 +00:00
|
|
|
bool subghz_scene_receiver_config_on_event(void* context, SceneManagerEvent event) {
|
2022-07-03 16:03:36 +00:00
|
|
|
SubGhz* subghz = context;
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
if(event.event == SubGhzCustomEventSceneSettingLock) {
|
2023-05-06 14:19:02 +00:00
|
|
|
subghz_lock(subghz);
|
2022-07-03 16:03:36 +00:00
|
|
|
scene_manager_previous_scene(subghz->scene_manager);
|
|
|
|
consumed = true;
|
2023-09-09 22:35:27 +00:00
|
|
|
} else if(event.event == SubGhzCustomEventSceneSettingResetToDefault) {
|
|
|
|
scene_manager_previous_scene(subghz->scene_manager);
|
|
|
|
consumed = true;
|
2022-07-03 16:03:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return consumed;
|
2021-09-10 00:29:57 +00:00
|
|
|
}
|
|
|
|
|
2021-09-21 09:34:16 +00:00
|
|
|
void subghz_scene_receiver_config_on_exit(void* context) {
|
2021-09-10 00:29:57 +00:00
|
|
|
SubGhz* subghz = context;
|
2022-09-28 03:02:23 +00:00
|
|
|
variable_item_list_set_selected_item(subghz->variable_item_list, 0);
|
2022-01-21 17:32:03 +00:00
|
|
|
variable_item_list_reset(subghz->variable_item_list);
|
2023-08-08 04:58:20 +00:00
|
|
|
#ifdef FURI_DEBUG
|
2023-08-08 13:31:46 +00:00
|
|
|
subghz_last_settings_log(subghz->last_settings);
|
2023-08-08 04:58:20 +00:00
|
|
|
#endif
|
2022-09-28 01:49:06 +00:00
|
|
|
subghz_last_settings_save(subghz->last_settings);
|
2021-10-27 17:37:11 +00:00
|
|
|
scene_manager_set_scene_state(
|
2022-03-03 09:48:56 +00:00
|
|
|
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
2021-09-10 00:29:57 +00:00
|
|
|
}
|