mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge branch 'feat/subghz-save-hopping-state' into dev-master
Signed-off-by: DerSkythe <31771569+derskythe@users.noreply.github.com>
This commit is contained in:
@@ -3,10 +3,9 @@
|
||||
#include <lib/subghz/protocols/protocol_items.h>
|
||||
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h>
|
||||
#include <lib/subghz/devices/cc1101_int/cc1101_int_interconnect.h>
|
||||
|
||||
#include <lib/subghz/blocks/custom_btn.h>
|
||||
|
||||
#define TAG "SubGhz"
|
||||
#define TAG "SubGhzTxRx"
|
||||
|
||||
static void subghz_txrx_radio_device_power_on(SubGhzTxRx* instance) {
|
||||
UNUSED(instance);
|
||||
@@ -30,8 +29,7 @@ SubGhzTxRx* subghz_txrx_alloc() {
|
||||
|
||||
instance->preset = malloc(sizeof(SubGhzRadioPreset));
|
||||
instance->preset->name = furi_string_alloc();
|
||||
subghz_txrx_set_preset(
|
||||
instance, "AM650", subghz_setting_get_default_frequency(instance->setting), NULL, 0);
|
||||
subghz_txrx_set_default_preset(instance, 0);
|
||||
|
||||
instance->txrx_state = SubGhzTxRxStateSleep;
|
||||
|
||||
@@ -383,10 +381,11 @@ void subghz_txrx_hopper_update(SubGhzTxRx* instance) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
float rssi = -127.0f;
|
||||
// Init value isn't using
|
||||
// float rssi = -127.0f;
|
||||
if(instance->hopper_state != SubGhzHopperStateRSSITimeOut) {
|
||||
// See RSSI Calculation timings in CC1101 17.3 RSSI
|
||||
rssi = subghz_devices_get_rssi(instance->radio_device);
|
||||
float rssi = subghz_devices_get_rssi(instance->radio_device);
|
||||
|
||||
// Stay if RSSI is high enough
|
||||
if(rssi > -90.0f) {
|
||||
@@ -407,7 +406,7 @@ void subghz_txrx_hopper_update(SubGhzTxRx* instance) {
|
||||
|
||||
if(instance->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_txrx_rx_end(instance);
|
||||
};
|
||||
}
|
||||
if(instance->txrx_state == SubGhzTxRxStateIDLE) {
|
||||
subghz_receiver_reset(instance->receiver);
|
||||
instance->preset->frequency =
|
||||
@@ -554,7 +553,7 @@ void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag fi
|
||||
subghz_receiver_set_filter(instance->receiver, filter);
|
||||
}
|
||||
|
||||
void subghz_txrx_set_rx_calback(
|
||||
void subghz_txrx_set_rx_callback(
|
||||
SubGhzTxRx* instance,
|
||||
SubGhzReceiverCallback callback,
|
||||
void* context) {
|
||||
@@ -672,4 +671,32 @@ void subghz_txrx_reset_dynamic_and_custom_btns(SubGhzTxRx* instance) {
|
||||
SubGhzReceiver* subghz_txrx_get_receiver(SubGhzTxRx* instance) {
|
||||
furi_assert(instance);
|
||||
return instance->receiver;
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_txrx_set_default_preset(SubGhzTxRx* instance, uint32_t frequency) {
|
||||
furi_assert(instance);
|
||||
|
||||
const char* default_modulation = "AM650";
|
||||
if(frequency == 0) {
|
||||
frequency = subghz_setting_get_default_frequency(subghz_txrx_get_setting(instance));
|
||||
}
|
||||
subghz_txrx_set_preset(instance, default_modulation, frequency, NULL, 0);
|
||||
}
|
||||
|
||||
const char*
|
||||
subghz_txrx_set_preset_internal(SubGhzTxRx* instance, uint32_t frequency, uint8_t index) {
|
||||
furi_assert(instance);
|
||||
|
||||
SubGhzSetting* setting = subghz_txrx_get_setting(instance);
|
||||
const char* preset_name = subghz_setting_get_preset_name(setting, index);
|
||||
subghz_setting_set_default_frequency(setting, frequency);
|
||||
|
||||
subghz_txrx_set_preset(
|
||||
instance,
|
||||
preset_name,
|
||||
frequency,
|
||||
subghz_setting_get_preset_data(setting, index),
|
||||
subghz_setting_get_preset_data_size(setting, index));
|
||||
|
||||
return preset_name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user