mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-11 06:09:08 -07:00
SubGhz: fiz module seletion, furi_assert(device). drivers targets
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
App(
|
||||
appid="radio_device_cc1101_ext",
|
||||
apptype=FlipperAppType.PLUGIN,
|
||||
targets=["f7"],
|
||||
entry_point="subghz_device_cc1101_ext_ep",
|
||||
requires=["subghz"],
|
||||
fap_libs=["hwdrivers"],
|
||||
|
||||
@@ -570,7 +570,7 @@ void subghz_txrx_set_raw_file_encoder_worker_callback_end(
|
||||
context);
|
||||
}
|
||||
|
||||
bool subghz_txrx_radio_device_is_connect_external(SubGhzTxRx* instance, const char* name) {
|
||||
bool subghz_txrx_radio_device_is_external_connected(SubGhzTxRx* instance, const char* name) {
|
||||
furi_assert(instance);
|
||||
|
||||
bool is_connect = false;
|
||||
@@ -580,7 +580,10 @@ bool subghz_txrx_radio_device_is_connect_external(SubGhzTxRx* instance, const ch
|
||||
subghz_txrx_radio_device_power_on(instance);
|
||||
}
|
||||
|
||||
is_connect = subghz_devices_is_connect(subghz_devices_get_by_name(name));
|
||||
const SubGhzDevice* device = subghz_devices_get_by_name(name);
|
||||
if(device) {
|
||||
is_connect = subghz_devices_is_connect(device);
|
||||
}
|
||||
|
||||
if(!is_otg_enabled) {
|
||||
subghz_txrx_radio_device_power_off(instance);
|
||||
@@ -593,7 +596,7 @@ SubGhzRadioDeviceType
|
||||
furi_assert(instance);
|
||||
|
||||
if(radio_device_type == SubGhzRadioDeviceTypeExternalCC1101 &&
|
||||
subghz_txrx_radio_device_is_connect_external(instance, SUBGHZ_DEVICE_CC1101_EXT_NAME)) {
|
||||
subghz_txrx_radio_device_is_external_connected(instance, SUBGHZ_DEVICE_CC1101_EXT_NAME)) {
|
||||
subghz_txrx_radio_device_power_on(instance);
|
||||
instance->radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_EXT_NAME);
|
||||
subghz_devices_begin(instance->radio_device);
|
||||
@@ -601,7 +604,9 @@ SubGhzRadioDeviceType
|
||||
} else {
|
||||
subghz_txrx_radio_device_power_off(instance);
|
||||
if(instance->radio_device_type != SubGhzRadioDeviceTypeInternal) {
|
||||
subghz_devices_end(instance->radio_device);
|
||||
if(instance->radio_device) {
|
||||
subghz_devices_end(instance->radio_device);
|
||||
}
|
||||
}
|
||||
instance->radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME);
|
||||
instance->radio_device_type = SubGhzRadioDeviceTypeInternal;
|
||||
|
||||
@@ -297,7 +297,7 @@ void subghz_txrx_set_raw_file_encoder_worker_callback_end(
|
||||
* @param name Name of external radio device
|
||||
* @return bool True if is connected to the external radio device
|
||||
*/
|
||||
bool subghz_txrx_radio_device_is_connect_external(SubGhzTxRx* instance, const char* name);
|
||||
bool subghz_txrx_radio_device_is_external_connected(SubGhzTxRx* instance, const char* name);
|
||||
|
||||
/* Set the selected radio device to use
|
||||
*
|
||||
|
||||
@@ -21,7 +21,8 @@ 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_connect_external(subghz->txrx, SUBGHZ_DEVICE_CC1101_EXT_NAME) &&
|
||||
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;
|
||||
@@ -35,14 +36,18 @@ void subghz_scene_radio_setting_on_enter(void* 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",
|
||||
RADIO_DEVICE_COUNT,
|
||||
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, RADIO_DEVICE_COUNT);
|
||||
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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user