mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
External radio driver in frequency analyzer & test carrier (#5)
* SubGhz App: add support ext_cc1101 in freq analyzer * SubGhz App: add support ext_cc1101 in test_carrier * SubGhz app: Deleted the temporary menu
This commit is contained in:
@@ -4,8 +4,6 @@
|
|||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <float_tools.h>
|
#include <float_tools.h>
|
||||||
|
|
||||||
// TODO add external module
|
|
||||||
|
|
||||||
#define TAG "SubghzFrequencyAnalyzerWorker"
|
#define TAG "SubghzFrequencyAnalyzerWorker"
|
||||||
|
|
||||||
#define SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD -97.0f
|
#define SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD -97.0f
|
||||||
@@ -30,6 +28,10 @@ struct SubGhzFrequencyAnalyzerWorker {
|
|||||||
FrequencyRSSI frequency_rssi_buf;
|
FrequencyRSSI frequency_rssi_buf;
|
||||||
SubGhzSetting* setting;
|
SubGhzSetting* setting;
|
||||||
|
|
||||||
|
const SubGhzDevice* radio_device;
|
||||||
|
FuriHalSpiBusHandle* spi_bus;
|
||||||
|
bool ext_radio;
|
||||||
|
|
||||||
float filVal;
|
float filVal;
|
||||||
float trigger_level;
|
float trigger_level;
|
||||||
|
|
||||||
@@ -37,14 +39,16 @@ struct SubGhzFrequencyAnalyzerWorker {
|
|||||||
void* context;
|
void* context;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void subghz_frequency_analyzer_worker_load_registers(const uint8_t data[][2]) {
|
static void subghz_frequency_analyzer_worker_load_registers(
|
||||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
FuriHalSpiBusHandle* spi_bus,
|
||||||
|
const uint8_t data[][2]) {
|
||||||
|
furi_hal_spi_acquire(spi_bus);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while(data[i][0]) {
|
while(data[i][0]) {
|
||||||
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, data[i][0], data[i][1]);
|
cc1101_write_reg(spi_bus, data[i][0], data[i][1]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
furi_hal_spi_release(spi_bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
// running average with adaptive coefficient
|
// running average with adaptive coefficient
|
||||||
@@ -79,31 +83,35 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
|||||||
uint32_t frequency_temp = 0;
|
uint32_t frequency_temp = 0;
|
||||||
CC1101Status status;
|
CC1101Status status;
|
||||||
|
|
||||||
//Start CC1101
|
FuriHalSpiBusHandle* spi_bus = instance->spi_bus;
|
||||||
furi_hal_subghz_reset();
|
const SubGhzDevice* radio_device = instance->radio_device;
|
||||||
|
|
||||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
//Start CC1101
|
||||||
cc1101_flush_rx(&furi_hal_spi_bus_handle_subghz);
|
// furi_hal_subghz_reset();
|
||||||
cc1101_flush_tx(&furi_hal_spi_bus_handle_subghz);
|
subghz_devices_reset(radio_device);
|
||||||
|
|
||||||
|
furi_hal_spi_acquire(spi_bus);
|
||||||
|
cc1101_flush_rx(spi_bus);
|
||||||
|
cc1101_flush_tx(spi_bus);
|
||||||
|
|
||||||
// TODO probably can be used device.load_preset(FuriHalSubGhzPresetCustom, ...) for external cc1101
|
// TODO probably can be used device.load_preset(FuriHalSubGhzPresetCustom, ...) for external cc1101
|
||||||
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG0, CC1101IocfgHW);
|
cc1101_write_reg(spi_bus, CC1101_IOCFG0, CC1101IocfgHW);
|
||||||
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_MDMCFG3,
|
cc1101_write_reg(spi_bus, CC1101_MDMCFG3,
|
||||||
0b01111111); // symbol rate
|
0b01111111); // symbol rate
|
||||||
cc1101_write_reg(
|
cc1101_write_reg(
|
||||||
&furi_hal_spi_bus_handle_subghz,
|
spi_bus,
|
||||||
CC1101_AGCCTRL2,
|
CC1101_AGCCTRL2,
|
||||||
0b00000111); // 00 - DVGA all; 000 - MAX LNA+LNA2; 111 - MAGN_TARGET 42 dB
|
0b00000111); // 00 - DVGA all; 000 - MAX LNA+LNA2; 111 - MAGN_TARGET 42 dB
|
||||||
cc1101_write_reg(
|
cc1101_write_reg(
|
||||||
&furi_hal_spi_bus_handle_subghz,
|
spi_bus,
|
||||||
CC1101_AGCCTRL1,
|
CC1101_AGCCTRL1,
|
||||||
0b00001000); // 0; 0 - LNA 2 gain is decreased to minimum before decreasing LNA gain; 00 - Relative carrier sense threshold disabled; 1000 - Absolute carrier sense threshold disabled
|
0b00001000); // 0; 0 - LNA 2 gain is decreased to minimum before decreasing LNA gain; 00 - Relative carrier sense threshold disabled; 1000 - Absolute carrier sense threshold disabled
|
||||||
cc1101_write_reg(
|
cc1101_write_reg(
|
||||||
&furi_hal_spi_bus_handle_subghz,
|
spi_bus,
|
||||||
CC1101_AGCCTRL0,
|
CC1101_AGCCTRL0,
|
||||||
0b00110000); // 00 - No hysteresis, medium asymmetric dead zone, medium gain ; 11 - 64 samples agc; 00 - Normal AGC, 00 - 4dB boundary
|
0b00110000); // 00 - No hysteresis, medium asymmetric dead zone, medium gain ; 11 - 64 samples agc; 00 - Normal AGC, 00 - 4dB boundary
|
||||||
|
|
||||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
furi_hal_spi_release(spi_bus);
|
||||||
|
|
||||||
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
||||||
|
|
||||||
@@ -116,36 +124,36 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
|||||||
|
|
||||||
frequency_rssi.rssi_coarse = -127.0f;
|
frequency_rssi.rssi_coarse = -127.0f;
|
||||||
frequency_rssi.rssi_fine = -127.0f;
|
frequency_rssi.rssi_fine = -127.0f;
|
||||||
furi_hal_subghz_idle();
|
// furi_hal_subghz_idle();
|
||||||
subghz_frequency_analyzer_worker_load_registers(subghz_preset_ook_650khz);
|
subghz_devices_idle(radio_device);
|
||||||
|
subghz_frequency_analyzer_worker_load_registers(spi_bus, subghz_preset_ook_650khz);
|
||||||
|
|
||||||
// First stage: coarse scan
|
// First stage: coarse scan
|
||||||
for(size_t i = 0; i < subghz_setting_get_frequency_count(instance->setting); i++) {
|
for(size_t i = 0; i < subghz_setting_get_frequency_count(instance->setting); i++) {
|
||||||
uint32_t current_frequency = subghz_setting_get_frequency(instance->setting, i);
|
uint32_t current_frequency = subghz_setting_get_frequency(instance->setting, i);
|
||||||
if(furi_hal_subghz_is_frequency_valid(current_frequency) &&
|
// if(furi_hal_subghz_is_frequency_valid(current_frequency) &&
|
||||||
(current_frequency != 467750000) && (current_frequency != 464000000)
|
if(subghz_devices_is_frequency_valid(radio_device, current_frequency) &&
|
||||||
// &&
|
(current_frequency != 467750000) && (current_frequency != 464000000) &&
|
||||||
// !((furi_hal_subghz.radio_type == SubGhzRadioExternal) &&
|
!((instance->ext_radio) &&
|
||||||
// ((current_frequency == 390000000) || (current_frequency == 312000000) ||
|
((current_frequency == 390000000) || (current_frequency == 312000000) ||
|
||||||
// (current_frequency == 312100000) || (current_frequency == 312200000) ||
|
(current_frequency == 312100000) || (current_frequency == 312200000) ||
|
||||||
// (current_frequency == 440175000)))
|
(current_frequency == 440175000)))) {
|
||||||
) {
|
furi_hal_spi_acquire(spi_bus);
|
||||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
cc1101_switch_to_idle(spi_bus);
|
||||||
cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz);
|
frequency = cc1101_set_frequency(spi_bus, current_frequency);
|
||||||
frequency =
|
|
||||||
cc1101_set_frequency(&furi_hal_spi_bus_handle_subghz, current_frequency);
|
|
||||||
|
|
||||||
cc1101_calibrate(&furi_hal_spi_bus_handle_subghz);
|
cc1101_calibrate(spi_bus);
|
||||||
do {
|
do {
|
||||||
status = cc1101_get_status(&furi_hal_spi_bus_handle_subghz);
|
status = cc1101_get_status(spi_bus);
|
||||||
} while(status.STATE != CC1101StateIDLE);
|
} while(status.STATE != CC1101StateIDLE);
|
||||||
|
|
||||||
cc1101_switch_to_rx(&furi_hal_spi_bus_handle_subghz);
|
cc1101_switch_to_rx(spi_bus);
|
||||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
furi_hal_spi_release(spi_bus);
|
||||||
|
|
||||||
furi_delay_ms(2);
|
furi_delay_ms(2);
|
||||||
|
|
||||||
rssi = furi_hal_subghz_get_rssi();
|
// rssi = furi_hal_subghz_get_rssi();
|
||||||
|
rssi = subghz_devices_get_rssi(radio_device);
|
||||||
|
|
||||||
rssi_avg += rssi;
|
rssi_avg += rssi;
|
||||||
rssi_avg_samples++;
|
rssi_avg_samples++;
|
||||||
@@ -169,28 +177,31 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
|||||||
|
|
||||||
// Second stage: fine scan
|
// Second stage: fine scan
|
||||||
if(frequency_rssi.rssi_coarse > instance->trigger_level) {
|
if(frequency_rssi.rssi_coarse > instance->trigger_level) {
|
||||||
furi_hal_subghz_idle();
|
// furi_hal_subghz_idle();
|
||||||
subghz_frequency_analyzer_worker_load_registers(subghz_preset_ook_58khz);
|
subghz_devices_idle(radio_device);
|
||||||
|
subghz_frequency_analyzer_worker_load_registers(spi_bus, subghz_preset_ook_58khz);
|
||||||
//for example -0.3 ... 433.92 ... +0.3 step 20KHz
|
//for example -0.3 ... 433.92 ... +0.3 step 20KHz
|
||||||
for(uint32_t i = frequency_rssi.frequency_coarse - 300000;
|
for(uint32_t i = frequency_rssi.frequency_coarse - 300000;
|
||||||
i < frequency_rssi.frequency_coarse + 300000;
|
i < frequency_rssi.frequency_coarse + 300000;
|
||||||
i += 20000) {
|
i += 20000) {
|
||||||
if(furi_hal_subghz_is_frequency_valid(i)) {
|
// if(furi_hal_subghz_is_frequency_valid(i)) {
|
||||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
if(subghz_devices_is_frequency_valid(radio_device, i)) {
|
||||||
cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz);
|
furi_hal_spi_acquire(spi_bus);
|
||||||
frequency = cc1101_set_frequency(&furi_hal_spi_bus_handle_subghz, i);
|
cc1101_switch_to_idle(spi_bus);
|
||||||
|
frequency = cc1101_set_frequency(spi_bus, i);
|
||||||
|
|
||||||
cc1101_calibrate(&furi_hal_spi_bus_handle_subghz);
|
cc1101_calibrate(spi_bus);
|
||||||
do {
|
do {
|
||||||
status = cc1101_get_status(&furi_hal_spi_bus_handle_subghz);
|
status = cc1101_get_status(spi_bus);
|
||||||
} while(status.STATE != CC1101StateIDLE);
|
} while(status.STATE != CC1101StateIDLE);
|
||||||
|
|
||||||
cc1101_switch_to_rx(&furi_hal_spi_bus_handle_subghz);
|
cc1101_switch_to_rx(spi_bus);
|
||||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
furi_hal_spi_release(spi_bus);
|
||||||
|
|
||||||
furi_delay_ms(2);
|
furi_delay_ms(2);
|
||||||
|
|
||||||
rssi = furi_hal_subghz_get_rssi();
|
// rssi = furi_hal_subghz_get_rssi();
|
||||||
|
rssi = subghz_devices_get_rssi(radio_device);
|
||||||
|
|
||||||
FURI_LOG_T(TAG, "#:%lu:%f", frequency, (double)rssi);
|
FURI_LOG_T(TAG, "#:%lu:%f", frequency, (double)rssi);
|
||||||
|
|
||||||
@@ -267,8 +278,10 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Stop CC1101
|
//Stop CC1101
|
||||||
furi_hal_subghz_idle();
|
// furi_hal_subghz_idle();
|
||||||
furi_hal_subghz_sleep();
|
// furi_hal_subghz_sleep();
|
||||||
|
subghz_devices_idle(radio_device);
|
||||||
|
subghz_devices_sleep(radio_device);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -307,10 +320,26 @@ void subghz_frequency_analyzer_worker_set_pair_callback(
|
|||||||
instance->context = context;
|
instance->context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_frequency_analyzer_worker_start(SubGhzFrequencyAnalyzerWorker* instance) {
|
void subghz_frequency_analyzer_worker_start(
|
||||||
|
SubGhzFrequencyAnalyzerWorker* instance,
|
||||||
|
SubGhzTxRx* txrx) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
furi_assert(!instance->worker_running);
|
furi_assert(!instance->worker_running);
|
||||||
|
|
||||||
|
SubGhzRadioDeviceType radio_type = subghz_txrx_radio_device_get(txrx);
|
||||||
|
|
||||||
|
if(radio_type == SubGhzRadioDeviceTypeExternalCC1101) {
|
||||||
|
instance->spi_bus = &furi_hal_spi_bus_handle_external;
|
||||||
|
instance->ext_radio = true;
|
||||||
|
} else if(radio_type == SubGhzRadioDeviceTypeInternal) {
|
||||||
|
instance->spi_bus = &furi_hal_spi_bus_handle_subghz;
|
||||||
|
instance->ext_radio = false;
|
||||||
|
} else {
|
||||||
|
furi_crash("Unsuported external module");
|
||||||
|
}
|
||||||
|
|
||||||
|
instance->radio_device = subghz_devices_get_by_name(subghz_txrx_radio_device_get_name(txrx));
|
||||||
|
|
||||||
instance->worker_running = true;
|
instance->worker_running = true;
|
||||||
|
|
||||||
furi_thread_start(instance->thread);
|
furi_thread_start(instance->thread);
|
||||||
|
|||||||
@@ -45,8 +45,11 @@ void subghz_frequency_analyzer_worker_set_pair_callback(
|
|||||||
/** Start SubGhzFrequencyAnalyzerWorker
|
/** Start SubGhzFrequencyAnalyzerWorker
|
||||||
*
|
*
|
||||||
* @param instance SubGhzFrequencyAnalyzerWorker instance
|
* @param instance SubGhzFrequencyAnalyzerWorker instance
|
||||||
|
* @param txrx pointer to SubGhzTxRx
|
||||||
*/
|
*/
|
||||||
void subghz_frequency_analyzer_worker_start(SubGhzFrequencyAnalyzerWorker* instance);
|
void subghz_frequency_analyzer_worker_start(
|
||||||
|
SubGhzFrequencyAnalyzerWorker* instance,
|
||||||
|
SubGhzTxRx* txrx);
|
||||||
|
|
||||||
/** Stop SubGhzFrequencyAnalyzerWorker
|
/** Stop SubGhzFrequencyAnalyzerWorker
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -30,4 +30,3 @@ ADD_SCENE(subghz, decode_raw, DecodeRAW)
|
|||||||
ADD_SCENE(subghz, delete_raw, DeleteRAW)
|
ADD_SCENE(subghz, delete_raw, DeleteRAW)
|
||||||
ADD_SCENE(subghz, need_saving, NeedSaving)
|
ADD_SCENE(subghz, need_saving, NeedSaving)
|
||||||
ADD_SCENE(subghz, rpc, Rpc)
|
ADD_SCENE(subghz, rpc, Rpc)
|
||||||
ADD_SCENE(subghz, radio_setting, RadioSettings)
|
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
#include "../subghz_i.h"
|
|
||||||
#include <lib/toolbox/value_index.h>
|
|
||||||
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h>
|
|
||||||
|
|
||||||
enum SubGhzRadioSettingIndex {
|
|
||||||
SubGhzRadioSettingIndexDevice,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define RADIO_DEVICE_COUNT 2
|
|
||||||
const char* const radio_device_text[RADIO_DEVICE_COUNT] = {
|
|
||||||
"Internal",
|
|
||||||
"External",
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint32_t radio_device_value[RADIO_DEVICE_COUNT] = {
|
|
||||||
SubGhzRadioDeviceTypeInternal,
|
|
||||||
SubGhzRadioDeviceTypeExternalCC1101,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void subghz_scene_radio_setting_set_device(VariableItem* item) {
|
|
||||||
SubGhz* subghz = variable_item_get_context(item);
|
|
||||||
uint8_t index = variable_item_get_current_value_index(item);
|
|
||||||
|
|
||||||
if(!subghz_txrx_radio_device_is_external_connected(
|
|
||||||
subghz->txrx, SUBGHZ_DEVICE_CC1101_EXT_NAME) &&
|
|
||||||
radio_device_value[index] == SubGhzRadioDeviceTypeExternalCC1101) {
|
|
||||||
//ToDo correct if there is more than 1 module
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
variable_item_set_current_value_text(item, radio_device_text[index]);
|
|
||||||
subghz_txrx_radio_device_set(subghz->txrx, radio_device_value[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void subghz_scene_radio_setting_on_enter(void* context) {
|
|
||||||
SubGhz* subghz = context;
|
|
||||||
VariableItem* item;
|
|
||||||
uint8_t value_index;
|
|
||||||
|
|
||||||
uint8_t value_count_device = RADIO_DEVICE_COUNT;
|
|
||||||
if(subghz_txrx_radio_device_get(subghz->txrx) == SubGhzRadioDeviceTypeInternal &&
|
|
||||||
!subghz_txrx_radio_device_is_external_connected(subghz->txrx, SUBGHZ_DEVICE_CC1101_EXT_NAME))
|
|
||||||
value_count_device = 1; // Only 1 item if external disconnected
|
|
||||||
item = variable_item_list_add(
|
|
||||||
subghz->variable_item_list,
|
|
||||||
"Module",
|
|
||||||
value_count_device,
|
|
||||||
subghz_scene_radio_setting_set_device,
|
|
||||||
subghz);
|
|
||||||
value_index = value_index_uint32(
|
|
||||||
subghz_txrx_radio_device_get(subghz->txrx), radio_device_value, value_count_device);
|
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, radio_device_text[value_index]);
|
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool subghz_scene_radio_setting_on_event(void* context, SceneManagerEvent event) {
|
|
||||||
SubGhz* subghz = context;
|
|
||||||
bool consumed = false;
|
|
||||||
UNUSED(subghz);
|
|
||||||
UNUSED(event);
|
|
||||||
|
|
||||||
return consumed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void subghz_scene_radio_setting_on_exit(void* context) {
|
|
||||||
SubGhz* subghz = context;
|
|
||||||
variable_item_list_set_selected_item(subghz->variable_item_list, 0);
|
|
||||||
variable_item_list_reset(subghz->variable_item_list);
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
#include "../subghz_i.h"
|
#include "../subghz_i.h"
|
||||||
#include "../helpers/subghz_custom_event.h"
|
#include "../helpers/subghz_custom_event.h"
|
||||||
|
#include <lib/toolbox/value_index.h>
|
||||||
|
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h>
|
||||||
|
|
||||||
// #define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
#define RADIO_DEVICE_COUNT 2
|
||||||
// const char* const radio_modules_variables_text[] = {
|
const char* const radio_device_text[RADIO_DEVICE_COUNT] = {
|
||||||
// "Internal",
|
"Internal",
|
||||||
// "External",
|
"External",
|
||||||
// };
|
};
|
||||||
|
|
||||||
// #define EXT_MOD_POWER_COUNT 2
|
const uint32_t radio_device_value[RADIO_DEVICE_COUNT] = {
|
||||||
// const char* const ext_mod_power_text[EXT_MOD_POWER_COUNT] = {
|
SubGhzRadioDeviceTypeInternal,
|
||||||
// "ON",
|
SubGhzRadioDeviceTypeExternalCC1101,
|
||||||
// "OFF",
|
};
|
||||||
// };
|
|
||||||
|
|
||||||
#define TIMESTAMP_NAMES_COUNT 2
|
#define TIMESTAMP_NAMES_COUNT 2
|
||||||
const char* const timestamp_names_text[TIMESTAMP_NAMES_COUNT] = {
|
const char* const timestamp_names_text[TIMESTAMP_NAMES_COUNT] = {
|
||||||
@@ -35,20 +36,19 @@ const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = {
|
|||||||
"+10",
|
"+10",
|
||||||
};
|
};
|
||||||
|
|
||||||
// static void subghz_scene_ext_module_changed(VariableItem* item) {
|
static void subghz_scene_radio_settings_set_device(VariableItem* item) {
|
||||||
// SubGhz* subghz = variable_item_get_context(item);
|
SubGhz* subghz = variable_item_get_context(item);
|
||||||
// uint8_t value_index_exm = variable_item_get_current_value_index(item);
|
uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
|
||||||
// variable_item_set_current_value_text(item, radio_modules_variables_text[value_index_exm]);
|
if(!subghz_txrx_radio_device_is_external_connected(
|
||||||
|
subghz->txrx, SUBGHZ_DEVICE_CC1101_EXT_NAME) &&
|
||||||
// subghz->last_settings->external_module_enabled = value_index_exm == 1;
|
radio_device_value[index] == SubGhzRadioDeviceTypeExternalCC1101) {
|
||||||
// subghz_last_settings_save(subghz->last_settings);
|
//ToDo correct if there is more than 1 module
|
||||||
// }
|
index = 0;
|
||||||
|
}
|
||||||
// static void subghz_ext_module_start_var_list_enter_callback(void* context, uint32_t index) {
|
variable_item_set_current_value_text(item, radio_device_text[index]);
|
||||||
// SubGhz* subghz = context;
|
subghz_txrx_radio_device_set(subghz->txrx, radio_device_value[index]);
|
||||||
// view_dispatcher_send_custom_event(subghz->view_dispatcher, index);
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
static void subghz_scene_receiver_config_set_debug_pin(VariableItem* item) {
|
static void subghz_scene_receiver_config_set_debug_pin(VariableItem* item) {
|
||||||
SubGhz* subghz = variable_item_get_context(item);
|
SubGhz* subghz = variable_item_get_context(item);
|
||||||
@@ -122,24 +122,20 @@ void subghz_scene_radio_settings_on_enter(void* context) {
|
|||||||
uint8_t value_index;
|
uint8_t value_index;
|
||||||
VariableItem* item;
|
VariableItem* item;
|
||||||
|
|
||||||
// VariableItem* item = variable_item_list_add(
|
uint8_t value_count_device = RADIO_DEVICE_COUNT;
|
||||||
// variable_item_list, "Module", EXT_MODULES_COUNT, subghz_scene_ext_module_changed, subghz);
|
if(subghz_txrx_radio_device_get(subghz->txrx) == SubGhzRadioDeviceTypeInternal &&
|
||||||
|
!subghz_txrx_radio_device_is_external_connected(subghz->txrx, SUBGHZ_DEVICE_CC1101_EXT_NAME))
|
||||||
// variable_item_list_set_enter_callback(
|
value_count_device = 1; // Only 1 item if external disconnected
|
||||||
// variable_item_list, subghz_ext_module_start_var_list_enter_callback, subghz);
|
item = variable_item_list_add(
|
||||||
// value_index = furi_hal_subghz.radio_type;
|
subghz->variable_item_list,
|
||||||
// variable_item_set_current_value_index(item, value_index);
|
"Module",
|
||||||
// variable_item_set_current_value_text(item, radio_modules_variables_text[value_index]);
|
value_count_device,
|
||||||
|
subghz_scene_radio_settings_set_device,
|
||||||
// item = variable_item_list_add(
|
subghz);
|
||||||
// variable_item_list,
|
value_index = value_index_uint32(
|
||||||
// "Ext Radio 5v",
|
subghz_txrx_radio_device_get(subghz->txrx), radio_device_value, value_count_device);
|
||||||
// EXT_MOD_POWER_COUNT,
|
variable_item_set_current_value_index(item, value_index);
|
||||||
// subghz_scene_receiver_config_set_ext_mod_power,
|
variable_item_set_current_value_text(item, radio_device_text[value_index]);
|
||||||
// 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]);
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
variable_item_list,
|
variable_item_list,
|
||||||
@@ -227,25 +223,11 @@ bool subghz_scene_radio_settings_on_event(void* context, SceneManagerEvent event
|
|||||||
UNUSED(subghz);
|
UNUSED(subghz);
|
||||||
UNUSED(event);
|
UNUSED(event);
|
||||||
|
|
||||||
// Set selected radio module
|
|
||||||
// furi_hal_subghz_select_radio_type(subghz->last_settings->external_module_enabled);
|
|
||||||
// furi_hal_subghz_init_radio_type(subghz->last_settings->external_module_enabled);
|
|
||||||
|
|
||||||
// furi_hal_subghz_enable_ext_power();
|
|
||||||
|
|
||||||
// Check if module is present, if no -> show error
|
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_scene_radio_settings_on_exit(void* context) {
|
void subghz_scene_radio_settings_on_exit(void* context) {
|
||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
|
variable_item_list_set_selected_item(subghz->variable_item_list, 0);
|
||||||
variable_item_list_reset(subghz->variable_item_list);
|
variable_item_list_reset(subghz->variable_item_list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "../subghz_i.h"
|
#include "../subghz_i.h"
|
||||||
#include <dolphin/dolphin.h>
|
#include <dolphin/dolphin.h>
|
||||||
|
|
||||||
// TODO move RadioSettings to ExtraSettings
|
|
||||||
#include <lib/subghz/protocols/raw.h>
|
#include <lib/subghz/protocols/raw.h>
|
||||||
|
|
||||||
enum SubmenuIndex {
|
enum SubmenuIndex {
|
||||||
@@ -54,12 +53,6 @@ void subghz_scene_start_on_enter(void* context) {
|
|||||||
SubmenuIndexExtSettings,
|
SubmenuIndexExtSettings,
|
||||||
subghz_scene_start_submenu_callback,
|
subghz_scene_start_submenu_callback,
|
||||||
subghz);
|
subghz);
|
||||||
submenu_add_item(
|
|
||||||
subghz->submenu,
|
|
||||||
"Radio Settings2",
|
|
||||||
SubmenuIndexRadioSetting,
|
|
||||||
subghz_scene_start_submenu_callback,
|
|
||||||
subghz);
|
|
||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
subghz->submenu, "Test", SubmenuIndexTest, subghz_scene_start_submenu_callback, subghz);
|
subghz->submenu, "Test", SubmenuIndexTest, subghz_scene_start_submenu_callback, subghz);
|
||||||
@@ -115,11 +108,6 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexExtSettings);
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexExtSettings);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneExtModuleSettings);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneExtModuleSettings);
|
||||||
return true;
|
return true;
|
||||||
} else if(event.event == SubmenuIndexRadioSetting) {
|
|
||||||
scene_manager_set_scene_state(
|
|
||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexRadioSetting);
|
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneRadioSettings);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ void subghz_scene_test_carrier_on_enter(void* context) {
|
|||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
subghz_test_carrier_set_callback(
|
subghz_test_carrier_set_callback(
|
||||||
subghz->subghz_test_carrier, subghz_scene_test_carrier_callback, subghz);
|
subghz->subghz_test_carrier, subghz_scene_test_carrier_callback, subghz);
|
||||||
|
subghz_test_carrier_set_radio(
|
||||||
|
subghz->subghz_test_carrier,
|
||||||
|
subghz_devices_get_by_name(subghz_txrx_radio_device_get_name(subghz->txrx)));
|
||||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTestCarrier);
|
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTestCarrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
|
|||||||
// Open Notification record
|
// Open Notification record
|
||||||
subghz->notifications = furi_record_open(RECORD_NOTIFICATION);
|
subghz->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||||
|
|
||||||
|
subghz->txrx = subghz_txrx_alloc();
|
||||||
|
|
||||||
if(!alloc_for_tx_only) {
|
if(!alloc_for_tx_only) {
|
||||||
// SubMenu
|
// SubMenu
|
||||||
subghz->submenu = submenu_alloc();
|
subghz->submenu = submenu_alloc();
|
||||||
@@ -167,7 +169,8 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
|
|||||||
variable_item_list_get_view(subghz->variable_item_list));
|
variable_item_list_get_view(subghz->variable_item_list));
|
||||||
|
|
||||||
// Frequency Analyzer
|
// Frequency Analyzer
|
||||||
subghz->subghz_frequency_analyzer = subghz_frequency_analyzer_alloc();
|
// View knows too much
|
||||||
|
subghz->subghz_frequency_analyzer = subghz_frequency_analyzer_alloc(subghz->txrx);
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
subghz->view_dispatcher,
|
subghz->view_dispatcher,
|
||||||
SubGhzViewIdFrequencyAnalyzer,
|
SubGhzViewIdFrequencyAnalyzer,
|
||||||
@@ -209,8 +212,6 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
|
|||||||
//init TxRx & Protocol & History & KeyBoard
|
//init TxRx & Protocol & History & KeyBoard
|
||||||
subghz_unlock(subghz);
|
subghz_unlock(subghz);
|
||||||
|
|
||||||
subghz->txrx = subghz_txrx_alloc();
|
|
||||||
|
|
||||||
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
||||||
|
|
||||||
subghz_load_custom_presets(setting);
|
subghz_load_custom_presets(setting);
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
#include <assets_icons.h>
|
#include <assets_icons.h>
|
||||||
#include <float_tools.h>
|
#include <float_tools.h>
|
||||||
|
|
||||||
// TODO remove furi_hal_subghz
|
|
||||||
|
|
||||||
#define TAG "frequency_analyzer"
|
#define TAG "frequency_analyzer"
|
||||||
|
|
||||||
#define RSSI_MIN -97
|
#define RSSI_MIN -97
|
||||||
@@ -40,6 +38,7 @@ struct SubGhzFrequencyAnalyzer {
|
|||||||
SubGhzFrequencyAnalyzerWorker* worker;
|
SubGhzFrequencyAnalyzerWorker* worker;
|
||||||
SubGhzFrequencyAnalyzerCallback callback;
|
SubGhzFrequencyAnalyzerCallback callback;
|
||||||
void* context;
|
void* context;
|
||||||
|
SubGhzTxRx* txrx;
|
||||||
bool locked;
|
bool locked;
|
||||||
SubGHzFrequencyAnalyzerFeedbackLevel
|
SubGHzFrequencyAnalyzerFeedbackLevel
|
||||||
feedback_level; // 0 - no feedback, 1 - vibro only, 2 - vibro and sound
|
feedback_level; // 0 - no feedback, 1 - vibro only, 2 - vibro and sound
|
||||||
@@ -62,6 +61,7 @@ typedef struct {
|
|||||||
uint8_t selected_index;
|
uint8_t selected_index;
|
||||||
uint8_t max_index;
|
uint8_t max_index;
|
||||||
bool show_frame;
|
bool show_frame;
|
||||||
|
bool is_ext_radio;
|
||||||
} SubGhzFrequencyAnalyzerModel;
|
} SubGhzFrequencyAnalyzerModel;
|
||||||
|
|
||||||
void subghz_frequency_analyzer_set_callback(
|
void subghz_frequency_analyzer_set_callback(
|
||||||
@@ -168,8 +168,8 @@ void subghz_frequency_analyzer_draw(Canvas* canvas, SubGhzFrequencyAnalyzerModel
|
|||||||
// Title
|
// Title
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
// TODO
|
|
||||||
// canvas_draw_str(canvas, 0, 7, furi_hal_subghz_get_radio_type() ? "Ext" : "Int");
|
canvas_draw_str(canvas, 0, 7, model->is_ext_radio ? "Ext" : "Int");
|
||||||
canvas_draw_str(canvas, 20, 7, "Frequency Analyzer");
|
canvas_draw_str(canvas, 20, 7, "Frequency Analyzer");
|
||||||
|
|
||||||
// RSSI
|
// RSSI
|
||||||
@@ -314,7 +314,9 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
|
|||||||
uint32_t prev_freq_to_save = model->frequency_to_save;
|
uint32_t prev_freq_to_save = model->frequency_to_save;
|
||||||
uint32_t frequency_candidate = model->history_frequency[model->selected_index];
|
uint32_t frequency_candidate = model->history_frequency[model->selected_index];
|
||||||
if(frequency_candidate == 0 ||
|
if(frequency_candidate == 0 ||
|
||||||
!furi_hal_subghz_is_frequency_valid(frequency_candidate) ||
|
// !furi_hal_subghz_is_frequency_valid(frequency_candidate) ||
|
||||||
|
!subghz_txrx_radio_device_is_frequecy_valid(
|
||||||
|
instance->txrx, frequency_candidate) ||
|
||||||
prev_freq_to_save == frequency_candidate) {
|
prev_freq_to_save == frequency_candidate) {
|
||||||
frequency_candidate = 0;
|
frequency_candidate = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -336,7 +338,9 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
|
|||||||
uint32_t prev_freq_to_save = model->frequency_to_save;
|
uint32_t prev_freq_to_save = model->frequency_to_save;
|
||||||
uint32_t frequency_candidate = subghz_frequency_find_correct(model->frequency);
|
uint32_t frequency_candidate = subghz_frequency_find_correct(model->frequency);
|
||||||
if(frequency_candidate == 0 ||
|
if(frequency_candidate == 0 ||
|
||||||
!furi_hal_subghz_is_frequency_valid(frequency_candidate) ||
|
// !furi_hal_subghz_is_frequency_valid(frequency_candidate) ||
|
||||||
|
!subghz_txrx_radio_device_is_frequecy_valid(
|
||||||
|
instance->txrx, frequency_candidate) ||
|
||||||
prev_freq_to_save == frequency_candidate) {
|
prev_freq_to_save == frequency_candidate) {
|
||||||
frequency_candidate = 0;
|
frequency_candidate = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -351,7 +355,9 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
|
|||||||
uint32_t prev_freq_to_save = model->frequency_to_save;
|
uint32_t prev_freq_to_save = model->frequency_to_save;
|
||||||
uint32_t frequency_candidate = subghz_frequency_find_correct(model->frequency);
|
uint32_t frequency_candidate = subghz_frequency_find_correct(model->frequency);
|
||||||
if(frequency_candidate == 0 ||
|
if(frequency_candidate == 0 ||
|
||||||
!furi_hal_subghz_is_frequency_valid(frequency_candidate) ||
|
// !furi_hal_subghz_is_frequency_valid(frequency_candidate) ||
|
||||||
|
!subghz_txrx_radio_device_is_frequecy_valid(
|
||||||
|
instance->txrx, frequency_candidate) ||
|
||||||
prev_freq_to_save == frequency_candidate) {
|
prev_freq_to_save == frequency_candidate) {
|
||||||
frequency_candidate = 0;
|
frequency_candidate = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -542,7 +548,7 @@ void subghz_frequency_analyzer_enter(void* context) {
|
|||||||
(SubGhzFrequencyAnalyzerWorkerPairCallback)subghz_frequency_analyzer_pair_callback,
|
(SubGhzFrequencyAnalyzerWorkerPairCallback)subghz_frequency_analyzer_pair_callback,
|
||||||
instance);
|
instance);
|
||||||
|
|
||||||
subghz_frequency_analyzer_worker_start(instance->worker);
|
subghz_frequency_analyzer_worker_start(instance->worker, instance->txrx);
|
||||||
|
|
||||||
instance->rssi_last = 0;
|
instance->rssi_last = 0;
|
||||||
instance->selected_index = 0;
|
instance->selected_index = 0;
|
||||||
@@ -570,6 +576,8 @@ void subghz_frequency_analyzer_enter(void* context) {
|
|||||||
model->history_frequency_rx_count[0] = 0;
|
model->history_frequency_rx_count[0] = 0;
|
||||||
model->frequency_to_save = 0;
|
model->frequency_to_save = 0;
|
||||||
model->trigger = RSSI_MIN;
|
model->trigger = RSSI_MIN;
|
||||||
|
model->is_ext_radio =
|
||||||
|
(subghz_txrx_radio_device_get(instance->txrx) != SubGhzRadioDeviceTypeInternal);
|
||||||
},
|
},
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
@@ -587,7 +595,7 @@ void subghz_frequency_analyzer_exit(void* context) {
|
|||||||
furi_record_close(RECORD_NOTIFICATION);
|
furi_record_close(RECORD_NOTIFICATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubGhzFrequencyAnalyzer* subghz_frequency_analyzer_alloc() {
|
SubGhzFrequencyAnalyzer* subghz_frequency_analyzer_alloc(SubGhzTxRx* txrx) {
|
||||||
SubGhzFrequencyAnalyzer* instance = malloc(sizeof(SubGhzFrequencyAnalyzer));
|
SubGhzFrequencyAnalyzer* instance = malloc(sizeof(SubGhzFrequencyAnalyzer));
|
||||||
|
|
||||||
instance->feedback_level = 2;
|
instance->feedback_level = 2;
|
||||||
@@ -602,6 +610,8 @@ SubGhzFrequencyAnalyzer* subghz_frequency_analyzer_alloc() {
|
|||||||
view_set_enter_callback(instance->view, subghz_frequency_analyzer_enter);
|
view_set_enter_callback(instance->view, subghz_frequency_analyzer_enter);
|
||||||
view_set_exit_callback(instance->view, subghz_frequency_analyzer_exit);
|
view_set_exit_callback(instance->view, subghz_frequency_analyzer_exit);
|
||||||
|
|
||||||
|
instance->txrx = txrx;
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
#include "../helpers/subghz_custom_event.h"
|
#include "../helpers/subghz_custom_event.h"
|
||||||
|
#include "../helpers/subghz_txrx.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SubGHzFrequencyAnalyzerFeedbackLevelAll,
|
SubGHzFrequencyAnalyzerFeedbackLevelAll,
|
||||||
@@ -18,7 +19,7 @@ void subghz_frequency_analyzer_set_callback(
|
|||||||
SubGhzFrequencyAnalyzerCallback callback,
|
SubGhzFrequencyAnalyzerCallback callback,
|
||||||
void* context);
|
void* context);
|
||||||
|
|
||||||
SubGhzFrequencyAnalyzer* subghz_frequency_analyzer_alloc();
|
SubGhzFrequencyAnalyzer* subghz_frequency_analyzer_alloc(SubGhzTxRx* txrx);
|
||||||
|
|
||||||
void subghz_frequency_analyzer_free(SubGhzFrequencyAnalyzer* subghz_static);
|
void subghz_frequency_analyzer_free(SubGhzFrequencyAnalyzer* subghz_static);
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,11 @@
|
|||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
#include <input/input.h>
|
#include <input/input.h>
|
||||||
|
|
||||||
// TODO add external module
|
|
||||||
|
|
||||||
struct SubGhzTestCarrier {
|
struct SubGhzTestCarrier {
|
||||||
View* view;
|
View* view;
|
||||||
FuriTimer* timer;
|
FuriTimer* timer;
|
||||||
SubGhzTestCarrierCallback callback;
|
SubGhzTestCarrierCallback callback;
|
||||||
|
const SubGhzDevice* radio_device;
|
||||||
void* context;
|
void* context;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -86,6 +85,7 @@ void subghz_test_carrier_draw(Canvas* canvas, SubGhzTestCarrierModel* model) {
|
|||||||
bool subghz_test_carrier_input(InputEvent* event, void* context) {
|
bool subghz_test_carrier_input(InputEvent* event, void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubGhzTestCarrier* subghz_test_carrier = context;
|
SubGhzTestCarrier* subghz_test_carrier = context;
|
||||||
|
const SubGhzDevice* radio_device = subghz_test_carrier->radio_device;
|
||||||
|
|
||||||
if(event->key == InputKeyBack || event->type != InputTypeShort) {
|
if(event->key == InputKeyBack || event->type != InputTypeShort) {
|
||||||
return false;
|
return false;
|
||||||
@@ -95,7 +95,8 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
|
|||||||
subghz_test_carrier->view,
|
subghz_test_carrier->view,
|
||||||
SubGhzTestCarrierModel * model,
|
SubGhzTestCarrierModel * model,
|
||||||
{
|
{
|
||||||
furi_hal_subghz_idle();
|
// furi_hal_subghz_idle();
|
||||||
|
subghz_devices_idle(radio_device);
|
||||||
|
|
||||||
if(event->key == InputKeyLeft) {
|
if(event->key == InputKeyLeft) {
|
||||||
if(model->frequency > 0) model->frequency--;
|
if(model->frequency > 0) model->frequency--;
|
||||||
@@ -113,19 +114,33 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model->real_frequency =
|
// model->real_frequency =
|
||||||
furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
|
// furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
|
||||||
furi_hal_subghz_set_path(model->path);
|
furi_hal_subghz_set_path(model->path);
|
||||||
|
model->real_frequency = subghz_devices_set_frequency(
|
||||||
|
radio_device, subghz_frequencies_testing[model->frequency]);
|
||||||
|
|
||||||
if(model->status == SubGhzTestCarrierModelStatusRx) {
|
if(model->status == SubGhzTestCarrierModelStatusRx) {
|
||||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
// furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||||
furi_hal_subghz_rx();
|
// furi_hal_subghz_rx();
|
||||||
|
furi_hal_gpio_init(
|
||||||
|
subghz_devices_get_data_gpio(radio_device),
|
||||||
|
GpioModeInput,
|
||||||
|
GpioPullNo,
|
||||||
|
GpioSpeedLow);
|
||||||
|
subghz_devices_set_rx(radio_device);
|
||||||
} else {
|
} else {
|
||||||
furi_hal_gpio_init(
|
furi_hal_gpio_init(
|
||||||
&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||||
furi_hal_gpio_write(&gpio_cc1101_g0, true);
|
furi_hal_gpio_write(&gpio_cc1101_g0, true);
|
||||||
if(!furi_hal_subghz_tx()) {
|
// if(!furi_hal_subghz_tx()) {
|
||||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
// furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||||
|
if(!subghz_devices_set_tx(radio_device)) {
|
||||||
|
furi_hal_gpio_init(
|
||||||
|
subghz_devices_get_data_gpio(radio_device),
|
||||||
|
GpioModeInput,
|
||||||
|
GpioPullNo,
|
||||||
|
GpioSpeedLow);
|
||||||
subghz_test_carrier->callback(
|
subghz_test_carrier->callback(
|
||||||
SubGhzTestCarrierEventOnlyRx, subghz_test_carrier->context);
|
SubGhzTestCarrierEventOnlyRx, subghz_test_carrier->context);
|
||||||
}
|
}
|
||||||
@@ -139,26 +154,37 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
|
|||||||
void subghz_test_carrier_enter(void* context) {
|
void subghz_test_carrier_enter(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubGhzTestCarrier* subghz_test_carrier = context;
|
SubGhzTestCarrier* subghz_test_carrier = context;
|
||||||
|
furi_assert(subghz_test_carrier->radio_device);
|
||||||
|
const SubGhzDevice* radio_device = subghz_test_carrier->radio_device;
|
||||||
|
|
||||||
furi_hal_subghz_reset();
|
// furi_hal_subghz_reset();
|
||||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
|
// furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||||
|
|
||||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
// furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||||
|
|
||||||
|
subghz_devices_reset(radio_device);
|
||||||
|
subghz_devices_load_preset(radio_device, FuriHalSubGhzPresetOok650Async, NULL);
|
||||||
|
|
||||||
|
furi_hal_gpio_init(
|
||||||
|
subghz_devices_get_data_gpio(radio_device), GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||||
|
|
||||||
with_view_model(
|
with_view_model(
|
||||||
subghz_test_carrier->view,
|
subghz_test_carrier->view,
|
||||||
SubGhzTestCarrierModel * model,
|
SubGhzTestCarrierModel * model,
|
||||||
{
|
{
|
||||||
model->frequency = subghz_frequencies_433_92_testing; // 433
|
model->frequency = subghz_frequencies_433_92_testing; // 433
|
||||||
model->real_frequency =
|
// model->real_frequency =
|
||||||
furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
|
// furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
|
||||||
|
model->real_frequency = subghz_devices_set_frequency(
|
||||||
|
radio_device, subghz_frequencies_testing[model->frequency]);
|
||||||
model->path = FuriHalSubGhzPathIsolate; // isolate
|
model->path = FuriHalSubGhzPathIsolate; // isolate
|
||||||
model->rssi = 0.0f;
|
model->rssi = 0.0f;
|
||||||
model->status = SubGhzTestCarrierModelStatusRx;
|
model->status = SubGhzTestCarrierModelStatusRx;
|
||||||
},
|
},
|
||||||
true);
|
true);
|
||||||
|
|
||||||
furi_hal_subghz_rx();
|
// furi_hal_subghz_rx();
|
||||||
|
subghz_devices_set_rx(radio_device);
|
||||||
|
|
||||||
furi_timer_start(subghz_test_carrier->timer, furi_kernel_get_tick_frequency() / 4);
|
furi_timer_start(subghz_test_carrier->timer, furi_kernel_get_tick_frequency() / 4);
|
||||||
}
|
}
|
||||||
@@ -170,7 +196,8 @@ void subghz_test_carrier_exit(void* context) {
|
|||||||
furi_timer_stop(subghz_test_carrier->timer);
|
furi_timer_stop(subghz_test_carrier->timer);
|
||||||
|
|
||||||
// Reinitialize IC to default state
|
// Reinitialize IC to default state
|
||||||
furi_hal_subghz_sleep();
|
// furi_hal_subghz_sleep();
|
||||||
|
subghz_devices_sleep(subghz_test_carrier->radio_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_test_carrier_rssi_timer_callback(void* context) {
|
void subghz_test_carrier_rssi_timer_callback(void* context) {
|
||||||
@@ -182,7 +209,8 @@ void subghz_test_carrier_rssi_timer_callback(void* context) {
|
|||||||
SubGhzTestCarrierModel * model,
|
SubGhzTestCarrierModel * model,
|
||||||
{
|
{
|
||||||
if(model->status == SubGhzTestCarrierModelStatusRx) {
|
if(model->status == SubGhzTestCarrierModelStatusRx) {
|
||||||
model->rssi = furi_hal_subghz_get_rssi();
|
// model->rssi = furi_hal_subghz_get_rssi();
|
||||||
|
model->rssi = subghz_devices_get_rssi(subghz_test_carrier->radio_device);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
false);
|
false);
|
||||||
@@ -218,3 +246,10 @@ View* subghz_test_carrier_get_view(SubGhzTestCarrier* subghz_test_carrier) {
|
|||||||
furi_assert(subghz_test_carrier);
|
furi_assert(subghz_test_carrier);
|
||||||
return subghz_test_carrier->view;
|
return subghz_test_carrier->view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void subghz_test_carrier_set_radio(
|
||||||
|
SubGhzTestCarrier* subghz_test_carrier,
|
||||||
|
const SubGhzDevice* radio_device) {
|
||||||
|
furi_assert(subghz_test_carrier);
|
||||||
|
subghz_test_carrier->radio_device = radio_device;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
|
#include <lib/subghz/devices/devices.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SubGhzTestCarrierEventOnlyRx,
|
SubGhzTestCarrierEventOnlyRx,
|
||||||
@@ -20,3 +21,7 @@ SubGhzTestCarrier* subghz_test_carrier_alloc();
|
|||||||
void subghz_test_carrier_free(SubGhzTestCarrier* subghz_test_carrier);
|
void subghz_test_carrier_free(SubGhzTestCarrier* subghz_test_carrier);
|
||||||
|
|
||||||
View* subghz_test_carrier_get_view(SubGhzTestCarrier* subghz_test_carrier);
|
View* subghz_test_carrier_get_view(SubGhzTestCarrier* subghz_test_carrier);
|
||||||
|
|
||||||
|
void subghz_test_carrier_set_radio(
|
||||||
|
SubGhzTestCarrier* subghz_test_carrier,
|
||||||
|
const SubGhzDevice* radio_device);
|
||||||
|
|||||||
Reference in New Issue
Block a user