1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-13 13:09:49 +04:00

fix: SubGhz Read reset setting ReadRAW after using scene ReadRAW

This commit is contained in:
Der Skythe
2022-09-16 18:38:08 +04:00
parent e25148ce72
commit d67d5da034
11 changed files with 69 additions and 64 deletions

View File

@@ -257,7 +257,7 @@ bool subghz_scene_decode_raw_on_event(void* context, SceneManagerEvent event) {
notification_message(subghz->notifications, &sequence_blink_cyan_10);
break;
case SubGhzNotificationStateRxDone:
notification_message(subghz->notifications, &subghs_sequence_rx);
notification_message(subghz->notifications, &subghz_sequence_rx);
subghz->state_notifications = SubGhzNotificationStateRx;
break;
default:

View File

@@ -115,6 +115,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
case SubGhzCustomEventViewReadRAWBack:
// Check if return from config save values
if(subghz->current_scene == SubGhzSceneReceiverConfig) {
FURI_LOG_I(TAG, "Raw value: %d", subghz->last_setting->detect_raw);
subghz_last_setting_save(
subghz->last_setting, EXT_PATH("subghz/assets/last_used.txt"));
}
@@ -181,6 +182,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerSet);
subghz->current_scene = SubGhzSceneReceiverConfig;
FURI_LOG_I(TAG, "Raw value: %d", subghz->last_setting->detect_raw);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig);
consumed = true;
break;

View File

@@ -1,7 +1,9 @@
#include "../subghz_i.h"
#include "../views/receiver.h"
const NotificationSequence subghs_sequence_rx = {
#define TAG "SubGhzSceneReceiver"
const NotificationSequence subghz_sequence_rx = {
&message_green_255,
&message_vibro_on,
@@ -14,7 +16,7 @@ const NotificationSequence subghs_sequence_rx = {
NULL,
};
const NotificationSequence subghs_sequence_rx_locked = {
const NotificationSequence subghz_sequence_rx_locked = {
&message_green_255,
&message_display_backlight_on,
@@ -136,9 +138,11 @@ void subghz_scene_receiver_on_enter(void* context) {
subghz->state_notifications = SubGhzNotificationStateRx;
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
subghz_rx_end(subghz);
};
}
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
// Set values that can be reset after using DetectRAW Scene
subghz_last_setting_set_receiver_values(subghz->last_setting, subghz->txrx->receiver);
subghz_begin(
subghz,
subghz_setting_get_preset_data_by_name(
@@ -158,6 +162,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
case SubGhzCustomEventViewReceiverBack:
// Check if return from config save values
if(subghz->current_scene == SubGhzSceneReceiverConfig) {
FURI_LOG_I(TAG, "Raw value: %d", subghz->last_setting->detect_raw);
subghz_last_setting_save(
subghz->last_setting, EXT_PATH("subghz/assets/last_used.txt"));
}
@@ -166,7 +171,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
subghz_rx_end(subghz);
subghz_sleep(subghz);
};
}
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
subghz->txrx->idx_menu_chosen = 0;
subghz_receiver_set_rx_callback(subghz->txrx->receiver, NULL, subghz);
@@ -200,7 +205,10 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz->txrx->idx_menu_chosen =
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzViewIdReceiver, SubGhzCustomEventManagerSet);
subghz->current_scene = SubGhzSceneReceiverConfig;
FURI_LOG_I(TAG, "Raw value: %d", subghz->last_setting->detect_raw);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig);
consumed = true;
break;
@@ -226,9 +234,9 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
break;
case SubGhzNotificationStateRxDone:
if(subghz->lock != SubGhzLockOn) {
notification_message(subghz->notifications, &subghs_sequence_rx);
notification_message(subghz->notifications, &subghz_sequence_rx);
} else {
notification_message(subghz->notifications, &subghs_sequence_rx_locked);
notification_message(subghz->notifications, &subghz_sequence_rx_locked);
}
subghz->state_notifications = SubGhzNotificationStateRx;
break;

View File

@@ -186,8 +186,7 @@ static void subghz_scene_receiver_config_set_detect_raw(VariableItem* item) {
variable_item_set_current_value_text(item, detect_raw_text[index]);
subghz_receiver_set_filter(subghz->txrx->receiver, detect_raw_value[index]);
//subghz->last_setting->detect_raw = detect_raw_value[index];
subghz->last_setting->detect_raw = detect_raw_value[index];
subghz_protocol_decoder_raw_set_auto_mode(
subghz_receiver_search_decoder_base_by_name(
@@ -253,8 +252,6 @@ void subghz_scene_receiver_config_on_enter(void* context) {
subghz);
value_index =
subghz_scene_receiver_config_next_frequency(subghz->txrx->preset->frequency, subghz);
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneReceiverConfig, (uint32_t)item);
variable_item_set_current_value_index(item, value_index);
char text_buf[10] = {0};
snprintf(
@@ -265,20 +262,6 @@ void subghz_scene_receiver_config_on_enter(void* context) {
(subghz_setting_get_frequency(subghz->setting, value_index) % 1000000) / 10000);
variable_item_set_current_value_text(item, text_buf);
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
SubGhzCustomEventManagerSet) {
item = variable_item_list_add(
subghz->variable_item_list,
"Hopping:",
HOPPING_COUNT,
subghz_scene_receiver_config_set_hopping_running,
subghz);
value_index = subghz_scene_receiver_config_hopper_value_index(
subghz->txrx->hopper_state, hopping_value, HOPPING_COUNT, subghz);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, hopping_text[value_index]);
}
item = variable_item_list_add(
subghz->variable_item_list,
"Modulation:",
@@ -293,6 +276,17 @@ void subghz_scene_receiver_config_on_enter(void* context) {
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
SubGhzCustomEventManagerSet) {
item = variable_item_list_add(
subghz->variable_item_list,
"Hopping:",
HOPPING_COUNT,
subghz_scene_receiver_config_set_hopping_running,
subghz);
value_index = subghz_scene_receiver_config_hopper_value_index(
subghz->txrx->hopper_state, hopping_value, HOPPING_COUNT, subghz);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, hopping_text[value_index]);
item = variable_item_list_add(
subghz->variable_item_list,
"Detect Raw:",
@@ -305,10 +299,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
DETECT_RAW_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, detect_raw_text[value_index]);
}
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
SubGhzCustomEventManagerSet) {
item = variable_item_list_add(
subghz->variable_item_list,
"RSSI for Raw:",
@@ -322,10 +313,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
RSSI_THRESHOLD_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, rssi_threshold_text[value_index]);
}
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
SubGhzCustomEventManagerSet) {
variable_item_list_add(subghz->variable_item_list, "Lock Keyboard", 1, NULL, NULL);
variable_item_list_set_enter_callback(
subghz->variable_item_list,

View File

@@ -1,9 +1,9 @@
/* Abandon hope, all ye who enter here. */
#include "m-string.h"
#include "subghz/types.h"
#include "subghz_i.h"
#include <m-string.h>
#include <subghz/types.h>
#include <lib/toolbox/path.h>
#include "subghz_i.h"
bool subghz_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);

View File

@@ -1,9 +1,5 @@
#include "subghz_history.h"
#include <lib/subghz/receiver.h>
#include <lib/subghz/protocols/came.h>
#include <furi.h>
#include <m-string.h>
#define SUBGHZ_HISTORY_MAX 65
#define TAG "SubGhzHistory"

View File

@@ -142,5 +142,5 @@ bool subghz_path_is_file(string_t path);
uint32_t subghz_random_serial(void);
void subghz_hopper_update(SubGhz* subghz);
extern const NotificationSequence subghs_sequence_rx;
extern const NotificationSequence subghs_sequence_rx_locked;
extern const NotificationSequence subghz_sequence_rx;
extern const NotificationSequence subghz_sequence_rx_locked;

View File

@@ -1,12 +1,11 @@
#include "subghz_setting.h"
#include "subghz_i.h"
#include "subghz_last_setting.h"
#include <furi.h>
#include <m-list.h>
#include "furi_hal_subghz.h"
#include "furi_hal_subghz_configs.h"
#include <furi_hal_subghz.h>
#include <furi_hal_subghz_configs.h>
#include <lib/subghz/protocols/raw.h>
#define TAG "SubGhzLastSetting"
@@ -41,7 +40,7 @@ void subghz_last_setting_load(SubGhzLastSetting* instance, const char* file_path
string_init(temp_preset);
uint32_t temp_frequency = 0; // Default 433920000
uint32_t temp_hopping = 0; // Default 0
//uint32_t temp_detect_raw = 0; Default 2
uint32_t temp_detect_raw = 0; // Default 2
int32_t temp_rssi_threshold = 0; // Default -72
if(FSE_OK == storage_sd_status(storage) && file_path &&
@@ -49,31 +48,31 @@ void subghz_last_setting_load(SubGhzLastSetting* instance, const char* file_path
flipper_format_read_string(fff_data_file, "Preset", temp_preset);
flipper_format_read_uint32(fff_data_file, "Frequency", (uint32_t*)&temp_frequency, 1);
flipper_format_read_uint32(fff_data_file, "Hopping", (uint32_t*)&temp_hopping, 1);
//flipper_format_read_uint32(fff_data_file, "DetectRaw", (uint32_t*)&temp_detect_raw, 1);
flipper_format_read_uint32(fff_data_file, "DetectRaw", (uint32_t*)&temp_detect_raw, 1);
flipper_format_read_int32(fff_data_file, "Rssi", (int32_t*)&temp_rssi_threshold, 1);
} else {
FURI_LOG_E(TAG, "Error open file %s", file_path);
}
if(string_empty_p(temp_preset)) {
//FURI_LOG_I(TAG, "Last used preset not found");
FURI_LOG_D(TAG, "Last used preset not found");
string_set(instance->preset_name, SUBGHZ_LAST_SETTING_DEFAULT_PRESET);
} else {
string_set(instance->preset_name, temp_preset);
}
if(temp_frequency == 0 || !furi_hal_subghz_is_tx_allowed(temp_frequency)) {
//FURI_LOG_I(TAG, "Last used frequency not found or can't be used!");
FURI_LOG_D(TAG, "Last used frequency not found or can't be used!");
instance->frequency = SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY;
} else {
instance->frequency = temp_frequency;
}
/*if(temp_detect_raw == 0) {
if(temp_detect_raw == 0) {
instance->detect_raw = SubGhzProtocolFlag_Decodable;
} else {
instance->detect_raw = temp_detect_raw;
}*/
}
if(temp_rssi_threshold == 0) {
instance->rssi_threshold = -72;
@@ -105,15 +104,15 @@ bool subghz_last_setting_save(SubGhzLastSetting* instance, const char* file_path
file, SUBGHZ_LAST_SETTING_FILE_TYPE, SUBGHZ_LAST_SETTING_FILE_VERSION))
break;
//FURI_LOG_D(TAG, "Preset %s", string_get_cstr(instance->preset_name));
FURI_LOG_D(TAG, "Preset %s", string_get_cstr(instance->preset_name));
if(!flipper_format_insert_or_update_string_cstr(
file, "Preset", string_get_cstr(instance->preset_name)))
break;
if(!flipper_format_insert_or_update_uint32(file, "Frequency", &instance->frequency, 1))
break;
if(!flipper_format_insert_or_update_uint32(file, "Hopping", &instance->hopping, 1)) break;
//if(!flipper_format_insert_or_update_uint32(file, "DetectRaw", &instance->detect_raw, 1))
// break;
if(!flipper_format_insert_or_update_uint32(file, "DetectRaw", &instance->detect_raw, 1))
break;
if(!flipper_format_insert_or_update_int32(file, "Rssi", &instance->rssi_threshold, 1))
break;
@@ -131,14 +130,11 @@ bool subghz_last_setting_save(SubGhzLastSetting* instance, const char* file_path
}
void subghz_last_setting_set_receiver_values(SubGhzLastSetting* instance, SubGhzReceiver* receiver) {
subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable);
/*subghz_receiver_set_filter(receiver, instance->detect_raw);
SubGhzProtocolDecoderBase* protocolDecoderBase =
subghz_receiver_search_decoder_base_by_name(receiver, SUBGHZ_PROTOCOL_RAW_NAME);
subghz_receiver_set_filter(receiver, instance->detect_raw);
subghz_protocol_decoder_raw_set_auto_mode(
subghz_receiver_search_decoder_base_by_name(receiver, SUBGHZ_PROTOCOL_RAW_NAME),
(instance->detect_raw != SubGhzProtocolFlag_Decodable));*/
subghz_protocol_decoder_raw_set_rssi_threshold(
subghz_receiver_search_decoder_base_by_name(receiver, SUBGHZ_PROTOCOL_RAW_NAME),
instance->rssi_threshold);
protocolDecoderBase, (instance->detect_raw != SubGhzProtocolFlag_Decodable));
subghz_protocol_decoder_raw_set_rssi_threshold(protocolDecoderBase, instance->rssi_threshold);
}

View File

@@ -9,7 +9,7 @@ typedef struct {
string_t preset_name;
uint32_t frequency;
uint32_t hopping;
//uint32_t detect_raw;
uint32_t detect_raw;
int32_t rssi_threshold;
} SubGhzLastSetting;

View File

@@ -3,7 +3,7 @@
#include <furi.h>
#include <m-list.h>
#include "furi_hal_subghz_configs.h"
#include <furi_hal_subghz_configs.h>
#define TAG "SubGhzSetting"

View File

@@ -46,7 +46,7 @@ const char* const volume_text[VOLUME_COUNT] = {
};
const float volume_value[VOLUME_COUNT] = {0.0f, 0.25f, 0.5f, 0.75f, 1.0f};
#define DELAY_COUNT 8
#define DELAY_COUNT 11
const char* const delay_text[DELAY_COUNT] = {
"1s",
"5s",
@@ -56,8 +56,23 @@ const char* const delay_text[DELAY_COUNT] = {
"60s",
"90s",
"120s",
"5min",
"10min",
"30min",
};
const uint32_t delay_value[DELAY_COUNT] = {
1000,
5000,
10000,
15000,
30000,
60000,
90000,
120000,
300000,
600000,
1800000
};
const uint32_t delay_value[DELAY_COUNT] = {1000, 5000, 10000, 15000, 30000, 60000, 90000, 120000};
#define VIBRO_COUNT 2
const char* const vibro_text[VIBRO_COUNT] = {