diff --git a/applications/main/subghz/scenes/subghz_scene_signal_settings.c b/applications/main/subghz/scenes/subghz_scene_signal_settings.c index e74219a28..548516683 100644 --- a/applications/main/subghz/scenes/subghz_scene_signal_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_signal_settings.c @@ -14,6 +14,7 @@ static uint16_t counter16 = 0x0; static uint8_t byte_count = 0; static uint8_t* byte_ptr = NULL; static FuriString* byte_input_text; +static uint8_t button = 0x0; #define COUNTER_MODE_COUNT 7 static const char* const counter_mode_text[COUNTER_MODE_COUNT] = { @@ -74,6 +75,23 @@ void subghz_scene_signal_settings_variable_item_list_enter_callback(void* contex ByteInput* byte_input = subghz->byte_input; byte_input_set_header_text(byte_input, furi_string_get_cstr(byte_input_text)); + byte_input_set_result_callback( + byte_input, + subghz_scene_signal_settings_byte_input_callback, + NULL, + subghz, + byte_ptr, + byte_count); + view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput); + } + // when we click OK on "Edit button" item + if(index == 2) { + furi_string_cat_str(byte_input_text, " button number in HEX"); + + // Setup byte_input view + ByteInput* byte_input = subghz->byte_input; + byte_input_set_header_text(byte_input, furi_string_get_cstr(byte_input_text)); + byte_input_set_result_callback( byte_input, subghz_scene_signal_settings_byte_input_callback, @@ -130,9 +148,10 @@ void subghz_scene_signal_settings_on_enter(void* context) { flipper_format_free(fff_data_file); furi_record_close(RECORD_STORAGE); - // ### Counter edit section ### byte_input_text = furi_string_alloc_set_str("Enter "); bool counter_not_available = true; + bool button_not_available = true; + SubGhzProtocolDecoderBase* decoder = subghz_txrx_get_decoder(subghz->txrx); // deserialaze and decode loaded sugbhz file and push data to subghz_block_generic_global variable @@ -143,6 +162,8 @@ void subghz_scene_signal_settings_on_enter(void* context) { FURI_LOG_E(TAG, "Cant deserialize this subghz file"); } + // ### Counter edit section ### + if(!subghz_block_generic_global.cnt_is_available) { counter_mode = 0xff; FURI_LOG_D(TAG, "Counter mode and edit not available for this protocol"); @@ -166,6 +187,18 @@ void subghz_scene_signal_settings_on_enter(void* context) { } } + // ### Button edit section ### + + if(!subghz_block_generic_global.btn_is_available) { + FURI_LOG_D(TAG, "Button edit not available for this protocol"); + } else { + button_not_available = false; + button = subghz_block_generic_global.current_btn; + furi_string_printf(tmp_text, "%X", button); + byte_ptr = (uint8_t*)&button; + byte_count = 1; + } + furi_assert(byte_ptr); furi_assert(byte_count > 0); @@ -196,6 +229,11 @@ void subghz_scene_signal_settings_on_enter(void* context) { variable_item_set_current_value_text(item, furi_string_get_cstr(tmp_text)); variable_item_set_locked(item, (counter_not_available), "Not available\nfor this\nprotocol !"); + item = variable_item_list_add(variable_item_list, "Edit Button", 1, NULL, subghz); + variable_item_set_current_value_index(item, 0); + variable_item_set_current_value_text(item, furi_string_get_cstr(tmp_text)); + variable_item_set_locked(item, (button_not_available), "Not available\nfor this\nprotocol !"); + furi_string_free(tmp_text); view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList); diff --git a/lib/subghz/blocks/generic.h b/lib/subghz/blocks/generic.h index 1e72c5a5e..d3f7804dc 100644 --- a/lib/subghz/blocks/generic.h +++ b/lib/subghz/blocks/generic.h @@ -35,6 +35,11 @@ struct SubGhzBlockGenericGlobal { bool cnt_need_override; // flag for protocols to override signals counter inside of protocols uint8_t cnt_length_bit; // counter length in bytes (used in counter editor giu) bool cnt_is_available; // is there counter available for protocol (used in counter editor giu) + + uint8_t current_btn; // global counter value; + uint8_t new_btn; // global counter value; + bool btn_need_override; // flag for protocols to override signals counter inside of protocols + bool btn_is_available; // is there counter available for protocol (used in counter editor giu) }; extern SubGhzBlockGenericGlobal subghz_block_generic_global; //global structure for subghz