mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-10 15:04:19 +00:00
Debug pin setting for subghz protocol development
When DEBUG is on in settings, you can turn on debug pin in radio settings now, DO NOT use it if you don't know what it is!!!!
This commit is contained in:
parent
16a5b13be4
commit
fda38c9d04
4 changed files with 50 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "../helpers/subghz_custom_event.h"
|
||||
|
||||
uint8_t value_index;
|
||||
uint8_t value_index2;
|
||||
|
||||
#define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
||||
const char* const radio_modules_variables_text[] = {
|
||||
|
@ -9,6 +10,12 @@ const char* const radio_modules_variables_text[] = {
|
|||
"External",
|
||||
};
|
||||
|
||||
#define DEBUG_P_COUNT 2
|
||||
const char* const debug_pin_text[DEBUG_P_COUNT] = {
|
||||
"OFF",
|
||||
"A7",
|
||||
};
|
||||
|
||||
static void subghz_scene_ext_module_changed(VariableItem* item) {
|
||||
SubGhz* subghz = variable_item_get_context(item);
|
||||
value_index = variable_item_get_current_value_index(item);
|
||||
|
@ -21,6 +28,14 @@ static void subghz_ext_module_start_var_list_enter_callback(void* context, uint3
|
|||
view_dispatcher_send_custom_event(subghz->view_dispatcher, index);
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_debug_pin(VariableItem* item) {
|
||||
SubGhz* subghz = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, debug_pin_text[index]);
|
||||
subghz->txrx->debug_pin_state = index == 1;
|
||||
}
|
||||
|
||||
void subghz_scene_ext_module_settings_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
|
@ -36,6 +51,18 @@ void subghz_scene_ext_module_settings_on_enter(void* context) {
|
|||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, radio_modules_variables_text[value_index]);
|
||||
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
item = variable_item_list_add(
|
||||
subghz->variable_item_list,
|
||||
"Debug Pin:",
|
||||
DEBUG_P_COUNT,
|
||||
subghz_scene_receiver_config_set_debug_pin,
|
||||
subghz);
|
||||
value_index2 = subghz->txrx->debug_pin_state;
|
||||
variable_item_set_current_value_index(item, value_index2);
|
||||
variable_item_set_current_value_text(item, debug_pin_text[value_index2]);
|
||||
}
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
|
||||
}
|
||||
|
||||
|
@ -44,6 +71,14 @@ bool subghz_scene_ext_module_settings_on_event(void* context, SceneManagerEvent
|
|||
UNUSED(subghz);
|
||||
UNUSED(event);
|
||||
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
if(value_index2 == 1) {
|
||||
furi_hal_subghz_set_async_mirror_pin(&gpio_ext_pa7);
|
||||
} else {
|
||||
furi_hal_subghz_set_async_mirror_pin(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
furi_hal_subghz_set_radio_type(value_index);
|
||||
|
||||
if(!furi_hal_subghz_check_radio()) {
|
||||
|
|
|
@ -259,6 +259,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
|
|||
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
|
||||
subghz->txrx->speaker_state = SubGhzSpeakerStateDisable;
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
subghz->txrx->debug_pin_state = false;
|
||||
if(!alloc_for_tx_only) {
|
||||
subghz->txrx->history = subghz_history_alloc();
|
||||
}
|
||||
|
|
|
@ -599,7 +599,9 @@ void subghz_hopper_update(SubGhz* subghz) {
|
|||
void subghz_speaker_on(SubGhz* subghz) {
|
||||
if(subghz->txrx->speaker_state == SubGhzSpeakerStateEnable) {
|
||||
if(furi_hal_speaker_acquire(30)) {
|
||||
furi_hal_subghz_set_async_mirror_pin(&gpio_speaker);
|
||||
if(!subghz->txrx->debug_pin_state) {
|
||||
furi_hal_subghz_set_async_mirror_pin(&gpio_speaker);
|
||||
}
|
||||
} else {
|
||||
subghz->txrx->speaker_state = SubGhzSpeakerStateDisable;
|
||||
}
|
||||
|
@ -609,7 +611,9 @@ void subghz_speaker_on(SubGhz* subghz) {
|
|||
void subghz_speaker_off(SubGhz* subghz) {
|
||||
if(subghz->txrx->speaker_state != SubGhzSpeakerStateDisable) {
|
||||
if(furi_hal_speaker_is_mine()) {
|
||||
furi_hal_subghz_set_async_mirror_pin(NULL);
|
||||
if(!subghz->txrx->debug_pin_state) {
|
||||
furi_hal_subghz_set_async_mirror_pin(NULL);
|
||||
}
|
||||
furi_hal_speaker_release();
|
||||
if(subghz->txrx->speaker_state == SubGhzSpeakerStateShutdown)
|
||||
subghz->txrx->speaker_state = SubGhzSpeakerStateDisable;
|
||||
|
@ -620,7 +624,9 @@ void subghz_speaker_off(SubGhz* subghz) {
|
|||
void subghz_speaker_mute(SubGhz* subghz) {
|
||||
if(subghz->txrx->speaker_state == SubGhzSpeakerStateEnable) {
|
||||
if(furi_hal_speaker_is_mine()) {
|
||||
furi_hal_subghz_set_async_mirror_pin(NULL);
|
||||
if(!subghz->txrx->debug_pin_state) {
|
||||
furi_hal_subghz_set_async_mirror_pin(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -628,7 +634,9 @@ void subghz_speaker_mute(SubGhz* subghz) {
|
|||
void subghz_speaker_unmute(SubGhz* subghz) {
|
||||
if(subghz->txrx->speaker_state == SubGhzSpeakerStateEnable) {
|
||||
if(furi_hal_speaker_is_mine()) {
|
||||
furi_hal_subghz_set_async_mirror_pin(&gpio_speaker);
|
||||
if(!subghz->txrx->debug_pin_state) {
|
||||
furi_hal_subghz_set_async_mirror_pin(&gpio_speaker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,8 @@ struct SubGhzTxRx {
|
|||
uint8_t hopper_idx_frequency;
|
||||
SubGhzRxKeyState rx_key_state;
|
||||
|
||||
bool debug_pin_state;
|
||||
|
||||
float raw_threshold_rssi;
|
||||
uint8_t raw_threshold_rssi_low_count;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue