Kostily and velosipedy

!!! Needs to be re-done in proper way after ofw subghz refactoring merge
This commit is contained in:
MX
2023-04-19 19:19:26 +03:00
parent 2de476b11d
commit 40e435a961
4 changed files with 90 additions and 20 deletions
@@ -35,12 +35,6 @@ typedef enum {
SubGhzSpeakerStateEnable,
} SubGhzSpeakerState;
/** SubGhzStarLineIgnore state */
typedef enum {
SubGhzStarLineIgnoreDisable,
SubGhzStarLineIgnoreEnable,
} SubGhzStarLineIgnoreState;
/** SubGhzRxKeyState state */
typedef enum {
SubGhzRxKeyStateIDLE,
@@ -147,7 +147,9 @@ 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) {
// TODO: Replace with proper solution based on protocol flags, remove kostily and velosipedy from here
// Needs to be done after subghz refactoring merge!!!
if(subghz->txrx->ignore_starline == true) {
SubGhzProtocolDecoderBase* protocoldecoderbase = NULL;
protocoldecoderbase =
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, "Star Line");
@@ -156,6 +158,31 @@ void subghz_scene_receiver_on_enter(void* context) {
protocoldecoderbase, NULL, subghz->txrx->receiver);
}
}
if(subghz->txrx->ignore_auto_alarms == true) {
SubGhzProtocolDecoderBase* protocoldecoderbase = NULL;
protocoldecoderbase =
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, "KIA Seed");
if(protocoldecoderbase) {
subghz_protocol_decoder_base_set_decoder_callback(
protocoldecoderbase, NULL, subghz->txrx->receiver);
}
protocoldecoderbase = NULL;
protocoldecoderbase =
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, "Scher-Khan");
if(protocoldecoderbase) {
subghz_protocol_decoder_base_set_decoder_callback(
protocoldecoderbase, NULL, subghz->txrx->receiver);
}
}
if(subghz->txrx->ignore_magellan == true) {
SubGhzProtocolDecoderBase* protocoldecoderbase = NULL;
protocoldecoderbase =
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, "Magellan");
if(protocoldecoderbase) {
subghz_protocol_decoder_base_set_decoder_callback(
protocoldecoderbase, NULL, subghz->txrx->receiver);
}
}
subghz->state_notifications = SubGhzNotificationStateRx;
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
@@ -7,6 +7,8 @@ enum SubGhzSettingIndex {
SubGhzSettingIndexModulation,
SubGhzSettingIndexBinRAW,
SubGhzSettingIndexIgnoreStarline,
SubGhzSettingIndexIgnoreCars,
SubGhzSettingIndexIgnoreMagellan,
SubGhzSettingIndexSound,
SubGhzSettingIndexLock,
SubGhzSettingIndexRAWThresholdRSSI,
@@ -69,14 +71,22 @@ 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[STAR_LINE_COUNT] = {
#define STARLINE_COUNT 2
const char* const starline_text[STARLINE_COUNT] = {
"OFF",
"ON",
};
const uint32_t star_line_value[STAR_LINE_COUNT] = {
SubGhzStarLineIgnoreDisable,
SubGhzStarLineIgnoreEnable,
#define AUTO_ALARMS_COUNT 2
const char* const auto_alarms_text[AUTO_ALARMS_COUNT] = {
"OFF",
"ON",
};
#define MAGELLAN_COUNT 2
const char* const magellan_text[MAGELLAN_COUNT] = {
"OFF",
"ON",
};
uint8_t subghz_scene_receiver_config_next_frequency(const uint32_t value, void* context) {
@@ -231,8 +241,24 @@ 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];
variable_item_set_current_value_text(item, starline_text[index]);
subghz->txrx->ignore_starline = (index == 1);
}
static void subghz_scene_receiver_config_set_auto_alarms(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, auto_alarms_text[index]);
subghz->txrx->ignore_auto_alarms = (index == 1);
}
static void subghz_scene_receiver_config_set_magellan(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, magellan_text[index]);
subghz->txrx->ignore_magellan = (index == 1);
}
static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
@@ -313,15 +339,36 @@ void subghz_scene_receiver_config_on_enter(void* context) {
SubGhzCustomEventManagerSet) {
item = variable_item_list_add(
subghz->variable_item_list,
"Ignore StarLine:",
STAR_LINE_COUNT,
"Ignore Starline:",
STARLINE_COUNT,
subghz_scene_receiver_config_set_starline,
subghz);
value_index =
value_index_uint32(subghz->txrx->starline_state, star_line_value, STAR_LINE_COUNT);
value_index = subghz->txrx->ignore_starline;
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, star_line_text[value_index]);
variable_item_set_current_value_text(item, starline_text[value_index]);
item = variable_item_list_add(
subghz->variable_item_list,
"Ignore Cars:",
AUTO_ALARMS_COUNT,
subghz_scene_receiver_config_set_auto_alarms,
subghz);
value_index = subghz->txrx->ignore_auto_alarms;
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, auto_alarms_text[value_index]);
item = variable_item_list_add(
subghz->variable_item_list,
"Ignore Magellan:",
MAGELLAN_COUNT,
subghz_scene_receiver_config_set_magellan,
subghz);
value_index = subghz->txrx->ignore_magellan;
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, magellan_text[value_index]);
}
// Enable speaker, will send all incoming noises and signals to speaker so you can listen how your remote sounds like :)
+3 -1
View File
@@ -73,7 +73,9 @@ struct SubGhzTxRx {
SubGhzTxRxState txrx_state;
SubGhzHopperState hopper_state;
SubGhzSpeakerState speaker_state;
SubGhzStarLineIgnoreState starline_state;
bool ignore_starline;
bool ignore_auto_alarms;
bool ignore_magellan;
uint8_t hopper_timeout;
uint8_t hopper_idx_frequency;
SubGhzRxKeyState rx_key_state;