1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

Subghz special signail_settings interface end of development

This commit is contained in:
Dmitry422
2025-11-08 04:52:36 +07:00
parent b7d2ab7a0c
commit 9d1cee6d4c

View File

@@ -29,7 +29,22 @@ const int32_t counter_mode_value[COUNTER_MODE_COUNT] = {
6, 6,
}; };
void subghz_scene_signal_settings_counter_mode_changed(VariableItem* item) { typedef struct {
char* name;
uint8_t mode_count;
} Protocols;
// List of protocols names and appropriate CounterMode counts
static Protocols protocols[] = {
{"Nice FloR-S", 3},
{"CAME Atomo", 4},
{"Alutech AT-4N", 3},
{"KeeLoq", 7},
};
#define PROTOCOLS_COUNT (sizeof(protocols) / sizeof(Protocols));
void subghz_scene_signal_settings_counter_mode_changed(VariableItem * item) {
SubGhz* subghz = variable_item_get_context(item); SubGhz* subghz = variable_item_get_context(item);
UNUSED(subghz); UNUSED(subghz);
uint8_t index = variable_item_get_current_value_index(item); uint8_t index = variable_item_get_current_value_index(item);
@@ -52,26 +67,28 @@ void subghz_scene_signal_settings_on_enter(void* context) {
uint32_t tmp_counter_mode = 0; uint32_t tmp_counter_mode = 0;
counter_mode = 0xff; counter_mode = 0xff;
uint8_t mode_count=1;
// open file and check is it contains allowed protocols and CounterMode variable - if not then CcounterMode will stay 0xff // open file and check is it contains allowed protocols and CounterMode variable - if not then CcounterMode will stay 0xff
// if file contain allowed protocols but not contain CounterMode - set it to default 0 // if file contain allowed protocol but not contain CounterMode value - set default CounterMode value = 0 and available CounterMode count for this protocol
// if file contain CounterMode then load it // if file contain CounterMode value then load it
if(!flipper_format_file_open_existing(fff_data_file, file_path)) { if(!flipper_format_file_open_existing(fff_data_file, file_path)) {
FURI_LOG_E(TAG, "Error open file %s", file_path); FURI_LOG_E(TAG, "Error open file %s", file_path);
} else { } else {
flipper_format_read_string(fff_data_file, "Protocol", tmp_string); flipper_format_read_string(fff_data_file, "Protocol", tmp_string);
if((!strcmp(furi_string_get_cstr(tmp_string), "Nice FloR-S")) || // compare available protocols names, load CounterMode value from file and setup variable_item_list values_count
(!strcmp(furi_string_get_cstr(tmp_string), "CAME Atomo")) || for(uint8_t i = 0; i < PROTOCOLS_COUNT i++) {
(!strcmp(furi_string_get_cstr(tmp_string), "Alutech AT-4N")) || if(!strcmp(furi_string_get_cstr(tmp_string), protocols[i].name)) {
(!strcmp(furi_string_get_cstr(tmp_string), "KeeLoq"))) { mode_count = protocols[i].mode_count;
if(flipper_format_read_uint32(fff_data_file, "CounterMode", &tmp_counter_mode, 1)) { if(flipper_format_read_uint32(fff_data_file, "CounterMode", &tmp_counter_mode, 1)) {
counter_mode = (uint8_t)tmp_counter_mode; counter_mode = (uint8_t)tmp_counter_mode;
} else { } else {
counter_mode = 0; counter_mode = 0;
}
} }
} }
} }
FURI_LOG_I(TAG, "Loaded CounterMode value %li", counter_mode); FURI_LOG_I(TAG, "Current CounterMode value %li", counter_mode);
furi_string_free(tmp_string); furi_string_free(tmp_string);
flipper_format_file_close(fff_data_file); flipper_format_file_close(fff_data_file);
@@ -82,15 +99,15 @@ void subghz_scene_signal_settings_on_enter(void* context) {
VariableItemList* variable_item_list = subghz->variable_item_list; VariableItemList* variable_item_list = subghz->variable_item_list;
int32_t value_index; int32_t value_index;
VariableItem* item; VariableItem* item;
int32_t available_count = COUNTER_MODE_COUNT; //int32_t available_count = COUNTER_MODE_COUNT;
item = variable_item_list_add( item = variable_item_list_add(
variable_item_list, variable_item_list,
"Counter Mode", "Counter Mode",
available_count, mode_count,
subghz_scene_signal_settings_counter_mode_changed, subghz_scene_signal_settings_counter_mode_changed,
subghz); subghz);
value_index = value_index_int32(counter_mode, counter_mode_value, available_count); value_index = value_index_int32(counter_mode, counter_mode_value, mode_count);
variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, counter_mode_text[value_index]); variable_item_set_current_value_text(item, counter_mode_text[value_index]);