work to home

This commit is contained in:
Dmitry422
2026-01-30 21:43:05 +07:00
parent 1d734948d9
commit 0eae6030b0
5 changed files with 124 additions and 16 deletions

View File

@@ -11,10 +11,15 @@
static uint32_t counter_mode = 0xff;
static uint32_t counter32 = 0x0;
static uint16_t counter16 = 0x0;
static uint8_t byte_count = 0;
static uint8_t* byte_ptr = NULL;
static uint8_t cnt_byte_count = 0;
static uint8_t* cnt_byte_ptr = NULL;
static FuriString* byte_input_text;
static uint8_t button = 0x0;
static uint8_t btn_byte_count = 1;
static uint8_t* btn_byte_ptr = NULL;
#define COUNTER_MODE_COUNT 7
static const char* const counter_mode_text[COUNTER_MODE_COUNT] = {
"System",
@@ -79,8 +84,25 @@ void subghz_scene_signal_settings_variable_item_list_enter_callback(void* contex
subghz_scene_signal_settings_byte_input_callback,
NULL,
subghz,
byte_ptr,
byte_count);
cnt_byte_ptr,
cnt_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,
NULL,
subghz,
btn_byte_ptr,
btn_byte_count);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdByteInput);
}
}
@@ -130,9 +152,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 +166,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");
@@ -155,19 +180,31 @@ void subghz_scene_signal_settings_on_enter(void* context) {
counter32 = subghz_block_generic_global.current_cnt;
furi_string_printf(tmp_text, "%lX", counter32);
counter32 = __bswap32(counter32);
byte_ptr = (uint8_t*)&counter32;
byte_count = 4;
cnt_byte_ptr = (uint8_t*)&counter32;
cnt_byte_count = 4;
} else {
counter16 = subghz_block_generic_global.current_cnt;
furi_string_printf(tmp_text, "%X", counter16);
counter16 = __bswap16(counter16);
byte_ptr = (uint8_t*)&counter16;
byte_count = 2;
cnt_byte_ptr = (uint8_t*)&counter16;
cnt_byte_count = 2;
}
}
furi_assert(byte_ptr);
furi_assert(byte_count > 0);
// ### 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);
btn_byte_ptr = (uint8_t*)&button;
}
furi_assert(cnt_byte_ptr);
furi_assert(cnt_byte_count > 0);
furi_assert(btn_byte_ptr);
//Create and Enable/Disable variable_item_list depending on current values
VariableItemList* variable_item_list = subghz->variable_item_list;
@@ -196,6 +233,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);
@@ -206,7 +248,7 @@ bool subghz_scene_signal_settings_on_event(void* context, SceneManagerEvent even
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventByteInputDone) {
switch(byte_count) {
switch(cnt_byte_count) {
case 2:
// set new cnt value and override_flag to global variable and call transmit to generate and save subghz signal
counter16 = __bswap16(counter16);