From 1923c159079a5bb6609be8ff82fcdea15a856ca1 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Tue, 4 Apr 2023 22:42:55 +0300 Subject: [PATCH] StarLine ignore --- .../main/subghz/helpers/subghz_types.h | 6 ++++ .../subghz/scenes/subghz_scene_receiver.c | 10 ++++++ .../scenes/subghz_scene_receiver_config.c | 32 +++++++++++++++++++ applications/main/subghz/subghz_i.h | 1 + 4 files changed, 49 insertions(+) diff --git a/applications/main/subghz/helpers/subghz_types.h b/applications/main/subghz/helpers/subghz_types.h index 3c5982427..270fd7a21 100644 --- a/applications/main/subghz/helpers/subghz_types.h +++ b/applications/main/subghz/helpers/subghz_types.h @@ -35,6 +35,12 @@ typedef enum { SubGhzSpeakerStateEnable, } SubGhzSpeakerState; +/** SubGhzStarLineIgnore state */ +typedef enum { + SubGhzStarLineIgnoreDisable, + SubGhzStarLineIgnoreEnable, +} SubGhzStarLineIgnoreState; + /** SubGhzRxKeyState state */ typedef enum { SubGhzRxKeyStateIDLE, diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index c0112199c..08fed3aa4 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -147,6 +147,16 @@ void subghz_scene_receiver_on_enter(void* context) { subghz_receiver_set_rx_callback( subghz->txrx->receiver, subghz_scene_add_to_history_callback, subghz); + if(subghz->txrx->starline_state == SubGhzStarLineIgnoreEnable) { + SubGhzProtocolDecoderBase* protocoldecoderbase = NULL; + protocoldecoderbase = + subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, "Star Line"); + if(protocoldecoderbase) { + subghz_protocol_decoder_base_set_decoder_callback( + protocoldecoderbase, NULL, subghz->txrx->receiver); + } + } + subghz->state_notifications = SubGhzNotificationStateRx; if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) { subghz_rx_end(subghz); diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index ff51e2f4d..89997b314 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -68,6 +68,15 @@ const uint32_t bin_raw_value[BIN_RAW_COUNT] = { SubGhzProtocolFlag_Decodable, SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_BinRAW, }; +#define STAR_LINE_COUNT 2 +const char* const star_line_text[BIN_RAW_COUNT] = { + "OFF", + "ON", +}; +const uint32_t star_line_value[SPEAKER_COUNT] = { + SubGhzStarLineIgnoreDisable, + SubGhzStarLineIgnoreEnable, +}; uint8_t subghz_scene_receiver_config_next_frequency(const uint32_t value, void* context) { furi_assert(context); @@ -217,6 +226,14 @@ static void subghz_scene_receiver_config_set_raw_threshold_rssi(VariableItem* it subghz->txrx->raw_threshold_rssi = raw_threshold_rssi_value[index]; } +static void subghz_scene_receiver_config_set_starline(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, star_line_text[index]); + subghz->txrx->starline_state = star_line_value[index]; +} + static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) { furi_assert(context); SubGhz* subghz = context; @@ -291,6 +308,21 @@ void subghz_scene_receiver_config_on_enter(void* context) { variable_item_set_current_value_text(item, bin_raw_text[value_index]); } + if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) != + SubGhzCustomEventManagerSet) { + item = variable_item_list_add( + subghz->variable_item_list, + "Ignore StarLine:", + STAR_LINE_COUNT, + subghz_scene_receiver_config_set_starline, + subghz); + + value_index = + value_index_uint32(subghz->txrx->starline_state, star_line_value, STAR_LINE_COUNT); + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, star_line_text[value_index]); + } + // Enable speaker, will send all incoming noises and signals to speaker so you can listen how your remote sounds like :) item = variable_item_list_add( subghz->variable_item_list, diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h index 393dd667d..adabe4aad 100644 --- a/applications/main/subghz/subghz_i.h +++ b/applications/main/subghz/subghz_i.h @@ -73,6 +73,7 @@ struct SubGhzTxRx { SubGhzTxRxState txrx_state; SubGhzHopperState hopper_state; SubGhzSpeakerState speaker_state; + SubGhzStarLineIgnoreState starline_state; uint8_t hopper_timeout; uint8_t hopper_idx_frequency; SubGhzRxKeyState rx_key_state;