mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
SubGhz: refactoring
This commit is contained in:
@@ -78,8 +78,7 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
|
||||
furi_string_free(modulation_str);
|
||||
furi_string_free(text);
|
||||
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save) {
|
||||
if(subghz_txrx_protocol_is_preserved(subghz->txrx)) {
|
||||
widget_add_button_element(
|
||||
subghz->widget,
|
||||
GuiButtonTypeRight,
|
||||
@@ -88,9 +87,7 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
|
||||
subghz);
|
||||
}
|
||||
// Removed static check
|
||||
if(((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
|
||||
SubGhzProtocolFlag_Send) &&
|
||||
subghz->txrx->decoder_result->protocol->encoder->deserialize) {
|
||||
if(subghz_txrx_protocol_is_send(subghz->txrx, false)) {
|
||||
widget_add_button_element(
|
||||
subghz->widget,
|
||||
GuiButtonTypeCenter,
|
||||
@@ -162,8 +159,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
return false;
|
||||
}
|
||||
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save) {
|
||||
if(subghz_txrx_protocol_is_preserved(subghz->txrx)) {
|
||||
subghz_file_name_clear(subghz);
|
||||
|
||||
if(subghz->in_decoder_scene) {
|
||||
|
||||
@@ -20,26 +20,19 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
|
||||
FuriString* frequency_str = furi_string_alloc();
|
||||
FuriString* modulation_str = furi_string_alloc();
|
||||
|
||||
bool show_button = false;
|
||||
|
||||
if(subghz_protocol_decoder_base_deserialize(
|
||||
subghz_txrx_get_decoder(subghz->txrx), subghz_txtx_get_fff_data(subghz->txrx)) ==
|
||||
SubGhzProtocolStatusOk) {
|
||||
subghz_protocol_decoder_base_get_string(
|
||||
subghz_txrx_get_decoder(subghz->txrx), key_str);
|
||||
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
|
||||
SubGhzProtocolFlag_Send) {
|
||||
show_button = true;
|
||||
}
|
||||
|
||||
subghz_get_frequency_modulation(subghz->txrx, frequency_str, modulation_str, false);
|
||||
subghz_view_transmitter_add_data_to_show(
|
||||
subghz->subghz_transmitter,
|
||||
furi_string_get_cstr(key_str),
|
||||
furi_string_get_cstr(frequency_str),
|
||||
furi_string_get_cstr(modulation_str),
|
||||
show_button);
|
||||
subghz_txrx_protocol_is_send(subghz->txrx, false));
|
||||
ret = true;
|
||||
}
|
||||
furi_string_free(frequency_str);
|
||||
|
||||
@@ -444,6 +444,28 @@ SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* txrx) {
|
||||
return txrx->decoder_result;
|
||||
}
|
||||
|
||||
bool subghz_txrx_protocol_is_preserved(SubGhzTxRx* txrx) {
|
||||
furi_assert(txrx);
|
||||
return (
|
||||
(txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save);
|
||||
}
|
||||
|
||||
bool subghz_txrx_protocol_is_send(SubGhzTxRx* txrx, bool check_type) {
|
||||
furi_assert(txrx);
|
||||
if(check_type) {
|
||||
return (
|
||||
((txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
|
||||
SubGhzProtocolFlag_Send) &&
|
||||
txrx->decoder_result->protocol->encoder->deserialize &&
|
||||
txrx->decoder_result->protocol->type == SubGhzProtocolTypeStatic);
|
||||
}
|
||||
return (
|
||||
((txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
|
||||
SubGhzProtocolFlag_Send) &&
|
||||
txrx->decoder_result->protocol->encoder->deserialize);
|
||||
}
|
||||
|
||||
//#############Create new Key##############
|
||||
#include <lib/subghz/protocols/protocol_items.h>
|
||||
#include <lib/subghz/protocols/keeloq.h>
|
||||
|
||||
@@ -84,6 +84,9 @@ void subghz_txrx_need_save_callback_set(
|
||||
FlipperFormat* subghz_txtx_get_fff_data(SubGhzTxRx* txrx);
|
||||
SubGhzSetting* subghz_txrx_get_setting(SubGhzTxRx* txrx);
|
||||
|
||||
bool subghz_txrx_protocol_is_preserved(SubGhzTxRx* txrx);
|
||||
bool subghz_txrx_protocol_is_send(SubGhzTxRx* txrx, bool check_type);
|
||||
|
||||
//#############Create new Key##############
|
||||
bool subghz_gen_data_protocol(
|
||||
void* context,
|
||||
|
||||
Reference in New Issue
Block a user