mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-19 11:21:39 +03:00
SubRem: archive browser
This commit is contained in:
parent
f49cad314e
commit
b3810ec573
@ -12,6 +12,7 @@ static const char* tab_default_paths[] = {
|
||||
[ArchiveTabIButton] = ANY_PATH("ibutton"),
|
||||
[ArchiveTabNFC] = ANY_PATH("nfc"),
|
||||
[ArchiveTabSubGhz] = ANY_PATH("subghz"),
|
||||
[ArchiveTabSubGhzRemote] = EXT_PATH("subghz_remote"),
|
||||
[ArchiveTabLFRFID] = ANY_PATH("lfrfid"),
|
||||
[ArchiveTabInfrared] = ANY_PATH("infrared"),
|
||||
[ArchiveTabBadUsb] = ANY_PATH("badusb"),
|
||||
@ -25,6 +26,7 @@ static const char* known_ext[] = {
|
||||
[ArchiveFileTypeIButton] = ".ibtn",
|
||||
[ArchiveFileTypeNFC] = ".nfc",
|
||||
[ArchiveFileTypeSubGhz] = ".sub",
|
||||
[ArchiveFileTypeSubGhzRemote] = ".txt",
|
||||
[ArchiveFileTypeLFRFID] = ".rfid",
|
||||
[ArchiveFileTypeInfrared] = ".ir",
|
||||
[ArchiveFileTypeBadUsb] = ".txt",
|
||||
@ -40,6 +42,7 @@ static const ArchiveFileTypeEnum known_type[] = {
|
||||
[ArchiveTabIButton] = ArchiveFileTypeIButton,
|
||||
[ArchiveTabNFC] = ArchiveFileTypeNFC,
|
||||
[ArchiveTabSubGhz] = ArchiveFileTypeSubGhz,
|
||||
[ArchiveTabSubGhzRemote] = ArchiveFileTypeSubGhzRemote,
|
||||
[ArchiveTabLFRFID] = ArchiveFileTypeLFRFID,
|
||||
[ArchiveTabInfrared] = ArchiveFileTypeInfrared,
|
||||
[ArchiveTabBadUsb] = ArchiveFileTypeBadUsb,
|
||||
|
@ -22,6 +22,12 @@ void archive_set_file_type(ArchiveFile_t* file, const char* path, bool is_folder
|
||||
file->type = i;
|
||||
return; // *.txt file is a BadUSB script only if it is in BadUSB folder
|
||||
}
|
||||
} else if(i == ArchiveFileTypeSubGhzRemote) {
|
||||
if(furi_string_search(
|
||||
file->path, archive_get_default_path(ArchiveTabSubGhzRemote)) == 0) {
|
||||
file->type = i;
|
||||
return; // *.txt file is a SubRem map file only if it is in SubRem folder
|
||||
}
|
||||
} else {
|
||||
file->type = i;
|
||||
return;
|
||||
|
@ -12,6 +12,7 @@ typedef enum {
|
||||
ArchiveFileTypeIButton,
|
||||
ArchiveFileTypeNFC,
|
||||
ArchiveFileTypeSubGhz,
|
||||
ArchiveFileTypeSubGhzRemote,
|
||||
ArchiveFileTypeLFRFID,
|
||||
ArchiveFileTypeInfrared,
|
||||
ArchiveFileTypeBadUsb,
|
||||
|
@ -20,6 +20,8 @@ static const char* archive_get_flipper_app_name(ArchiveFileTypeEnum file_type) {
|
||||
return "NFC";
|
||||
case ArchiveFileTypeSubGhz:
|
||||
return "Sub-GHz";
|
||||
case ArchiveFileTypeSubGhzRemote:
|
||||
return "Sub-GHz Remote";
|
||||
case ArchiveFileTypeLFRFID:
|
||||
return "125 kHz RFID";
|
||||
case ArchiveFileTypeInfrared:
|
||||
|
@ -14,6 +14,7 @@ static const char* ArchiveTabNames[] = {
|
||||
[ArchiveTabIButton] = "iButton",
|
||||
[ArchiveTabNFC] = "NFC",
|
||||
[ArchiveTabSubGhz] = "Sub-GHz",
|
||||
[ArchiveTabSubGhzRemote] = "SubRem",
|
||||
[ArchiveTabLFRFID] = "RFID LF",
|
||||
[ArchiveTabInfrared] = "Infrared",
|
||||
[ArchiveTabBadUsb] = "Bad USB",
|
||||
@ -27,6 +28,7 @@ static const Icon* ArchiveItemIcons[] = {
|
||||
[ArchiveFileTypeIButton] = &I_ibutt_10px,
|
||||
[ArchiveFileTypeNFC] = &I_Nfc_10px,
|
||||
[ArchiveFileTypeSubGhz] = &I_sub1_10px,
|
||||
[ArchiveFileTypeSubGhzRemote] = &I_subrem_10px,
|
||||
[ArchiveFileTypeLFRFID] = &I_125_10px,
|
||||
[ArchiveFileTypeInfrared] = &I_ir_10px,
|
||||
[ArchiveFileTypeBadUsb] = &I_badusb_10px,
|
||||
|
@ -24,6 +24,7 @@
|
||||
typedef enum {
|
||||
ArchiveTabFavorites,
|
||||
ArchiveTabSubGhz,
|
||||
ArchiveTabSubGhzRemote,
|
||||
ArchiveTabLFRFID,
|
||||
ArchiveTabNFC,
|
||||
ArchiveTabInfrared,
|
||||
|
@ -8,8 +8,6 @@ void subrem_scene_open_map_file_on_enter(void* context) {
|
||||
uint32_t start_scene_state =
|
||||
scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart);
|
||||
|
||||
// TODO if optimization
|
||||
|
||||
if(load_state == SubRemLoadMapStateBack) {
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
} else if(start_scene_state == SubmenuIndexSubRemEditMapFile) {
|
||||
|
@ -39,6 +39,9 @@ void subrem_scene_remote_on_enter(void* context) {
|
||||
SubGhzRemoteApp* app = context;
|
||||
|
||||
subrem_view_remote_update_data_labels(app->subrem_remote_view, app->map_preset->subs_preset);
|
||||
subrem_view_remote_set_radio(
|
||||
app->subrem_remote_view,
|
||||
subghz_txrx_radio_device_get(app->txrx) == SubGhzRadioDeviceTypeExternalCC1101);
|
||||
|
||||
subrem_view_remote_set_callback(app->subrem_remote_view, subrem_scene_remote_callback, app);
|
||||
|
||||
|
@ -18,16 +18,23 @@ static void subghz_remote_app_tick_event_callback(void* context) {
|
||||
scene_manager_handle_tick_event(app->scene_manager);
|
||||
}
|
||||
|
||||
SubGhzRemoteApp* subghz_remote_app_alloc() {
|
||||
SubGhzRemoteApp* app = malloc(sizeof(SubGhzRemoteApp));
|
||||
static void subghz_remote_make_app_folder(SubGhzRemoteApp* app) {
|
||||
furi_assert(app);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
// Migrate old users data
|
||||
storage_common_migrate(storage, EXT_PATH("unirf"), SUBREM_APP_FOLDER);
|
||||
|
||||
if(!storage_simply_mkdir(storage, SUBREM_APP_FOLDER)) {
|
||||
//FURI_LOG_E(TAG, "Could not create folder %s", SUBREM_APP_FOLDER);
|
||||
// FURI_LOG_E(TAG, "Could not create folder %s", SUBREM_APP_FOLDER);
|
||||
dialog_message_show_storage_error(app->dialogs, "Cannot create\napp folder");
|
||||
}
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
SubGhzRemoteApp* subghz_remote_app_alloc() {
|
||||
SubGhzRemoteApp* app = malloc(sizeof(SubGhzRemoteApp));
|
||||
|
||||
furi_hal_power_suppress_charge_enter();
|
||||
|
||||
@ -103,9 +110,6 @@ SubGhzRemoteApp* subghz_remote_app_alloc() {
|
||||
|
||||
app->map_not_saved = false;
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneStart);
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
@ -164,11 +168,33 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) {
|
||||
free(app);
|
||||
}
|
||||
|
||||
int32_t subghz_remote_app(void* p) {
|
||||
UNUSED(p);
|
||||
int32_t subghz_remote_app(void* arg) {
|
||||
SubGhzRemoteApp* subghz_remote_app = subghz_remote_app_alloc();
|
||||
|
||||
furi_string_set(subghz_remote_app->file_path, SUBREM_APP_FOLDER);
|
||||
subghz_remote_make_app_folder(subghz_remote_app);
|
||||
|
||||
bool map_loaded = false;
|
||||
|
||||
if((arg != NULL) && (strlen(arg) != 0)) {
|
||||
furi_string_set(subghz_remote_app->file_path, (const char*)arg);
|
||||
SubRemLoadMapState load_state = subrem_map_file_load(
|
||||
subghz_remote_app, furi_string_get_cstr(subghz_remote_app->file_path));
|
||||
|
||||
if(load_state == SubRemLoadMapStateOK || load_state == SubRemLoadMapStateNotAllOK) {
|
||||
map_loaded = true;
|
||||
} else {
|
||||
// TODO Replace
|
||||
dialog_message_show_storage_error(subghz_remote_app->dialogs, "Cannot load\nmap file");
|
||||
}
|
||||
}
|
||||
|
||||
if(map_loaded) {
|
||||
scene_manager_next_scene(subghz_remote_app->scene_manager, SubRemSceneRemote);
|
||||
} else {
|
||||
furi_string_set(subghz_remote_app->file_path, SUBREM_APP_FOLDER);
|
||||
scene_manager_next_scene(subghz_remote_app->scene_manager, SubRemSceneStart);
|
||||
scene_manager_next_scene(subghz_remote_app->scene_manager, SubRemSceneOpenMapFile);
|
||||
}
|
||||
|
||||
view_dispatcher_run(subghz_remote_app->view_dispatcher);
|
||||
|
||||
|
@ -22,6 +22,7 @@ typedef struct {
|
||||
SubRemViewRemoteState state;
|
||||
|
||||
uint8_t pressed_btn;
|
||||
bool is_external;
|
||||
} SubRemViewRemoteModel;
|
||||
|
||||
void subrem_view_remote_set_callback(
|
||||
@ -106,6 +107,15 @@ void subrem_view_remote_set_state(
|
||||
true);
|
||||
}
|
||||
|
||||
void subrem_view_remote_set_radio(SubRemViewRemote* subrem_view_remote, bool external) {
|
||||
furi_assert(subrem_view_remote);
|
||||
with_view_model(
|
||||
subrem_view_remote->view,
|
||||
SubRemViewRemoteModel * model,
|
||||
{ model->is_external = external; },
|
||||
true);
|
||||
}
|
||||
|
||||
void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
@ -143,6 +153,8 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) {
|
||||
elements_button_right(canvas, "Save");
|
||||
} else {
|
||||
canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit.");
|
||||
canvas_draw_str_aligned(
|
||||
canvas, 126, 62, AlignRight, AlignBottom, ((model->is_external) ? "Ext" : "Int"));
|
||||
}
|
||||
|
||||
//Status text and indicator
|
||||
@ -267,6 +279,7 @@ SubRemViewRemote* subrem_view_remote_alloc() {
|
||||
}
|
||||
|
||||
model->pressed_btn = 0;
|
||||
model->is_external = false;
|
||||
},
|
||||
true);
|
||||
return subrem_view_remote;
|
||||
|
@ -33,4 +33,6 @@ void subrem_view_remote_update_data_labels(
|
||||
void subrem_view_remote_set_state(
|
||||
SubRemViewRemote* subrem_view_remote,
|
||||
SubRemViewRemoteState state,
|
||||
uint8_t presed_btn);
|
||||
uint8_t presed_btn);
|
||||
|
||||
void subrem_view_remote_set_radio(SubRemViewRemote* subrem_view_remote, bool external);
|
Loading…
Reference in New Issue
Block a user