Revert SubGhz FA changes

This commit is contained in:
MX 2022-11-24 03:16:31 +03:00
parent 0321717a86
commit 757b218397
No known key found for this signature in database
GPG Key ID: 6C4C311DFD4B4AB5
2 changed files with 22 additions and 12 deletions

View File

@ -5,6 +5,8 @@
#define TAG "SubghzFrequencyAnalyzerWorker"
#define SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD -97.0f
static const uint8_t subghz_preset_ook_58khz[][2] = {
{CC1101_MDMCFG4, 0b11110111}, // Rx BW filter is 58.035714kHz
/* End */
@ -70,7 +72,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
.frequency_coarse = 0, .rssi_coarse = 0, .frequency_fine = 0, .rssi_fine = 0};
float rssi = 0;
uint32_t frequency = 0;
float rssi_temp = -127.0f;
float rssi_temp = 0;
uint32_t frequency_temp = 0;
CC1101Status status;
@ -195,7 +197,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
TAG, "=:%lu:%f", frequency_rssi.frequency_fine, (double)frequency_rssi.rssi_fine);
instance->sample_hold_counter = 20;
rssi_temp = (rssi_temp + frequency_rssi.rssi_fine) / 2;
rssi_temp = frequency_rssi.rssi_fine;
frequency_temp = frequency_rssi.frequency_fine;
if(instance->filVal) {
@ -206,7 +208,10 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
// Deliver callback
if(instance->pair_callback) {
instance->pair_callback(
instance->context, frequency_rssi.frequency_fine, rssi_temp, true);
instance->context,
frequency_rssi.frequency_fine,
frequency_rssi.rssi_fine,
true);
}
} else if( // Deliver results coarse
(frequency_rssi.rssi_coarse > instance->trigger_level) &&
@ -218,7 +223,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
(double)frequency_rssi.rssi_coarse);
instance->sample_hold_counter = 20;
rssi_temp = (rssi_temp + frequency_rssi.rssi_coarse) / 2;
rssi_temp = frequency_rssi.rssi_coarse;
frequency_temp = frequency_rssi.frequency_coarse;
if(instance->filVal) {
frequency_rssi.frequency_coarse =
@ -228,12 +233,15 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
// Deliver callback
if(instance->pair_callback) {
instance->pair_callback(
instance->context, frequency_rssi.frequency_coarse, rssi_temp, true);
instance->context,
frequency_rssi.frequency_coarse,
frequency_rssi.rssi_coarse,
true);
}
} else {
if(instance->sample_hold_counter > 0) {
instance->sample_hold_counter--;
if(instance->sample_hold_counter == 15) {
if(instance->sample_hold_counter == 18) {
if(instance->pair_callback) {
instance->pair_callback(
instance->context, frequency_temp, rssi_temp, false);
@ -241,8 +249,8 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
}
} else {
instance->filVal = 0;
rssi_temp = -127.0f;
instance->pair_callback(instance->context, 0, 0, false);
if(instance->pair_callback)
instance->pair_callback(instance->context, 0, 0, false);
}
}
}
@ -258,8 +266,12 @@ SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc(void* cont
furi_assert(context);
SubGhzFrequencyAnalyzerWorker* instance = malloc(sizeof(SubGhzFrequencyAnalyzerWorker));
instance->thread = furi_thread_alloc_ex(
"SubGhzFAWorker", 2048, subghz_frequency_analyzer_worker_thread, instance);
instance->thread = furi_thread_alloc();
furi_thread_set_name(instance->thread, "SubGhzFAWorker");
furi_thread_set_stack_size(instance->thread, 2048);
furi_thread_set_context(instance->thread, instance);
furi_thread_set_callback(instance->thread, subghz_frequency_analyzer_worker_thread);
SubGhz* subghz = context;
instance->setting = subghz->setting;
instance->trigger_level = subghz->last_settings->frequency_analyzer_trigger;

View File

@ -3,8 +3,6 @@
#include <furi_hal.h>
#include "../subghz_i.h"
#define SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD -97.0f
typedef struct SubGhzFrequencyAnalyzerWorker SubGhzFrequencyAnalyzerWorker;
typedef void (*SubGhzFrequencyAnalyzerWorkerPairCallback)(