diff --git a/applications/system/ir_remote/infrared_last_settings.c b/applications/system/ir_remote/infrared_last_settings.c new file mode 100644 index 000000000..a90d1b08c --- /dev/null +++ b/applications/system/ir_remote/infrared_last_settings.c @@ -0,0 +1 @@ +#include diff --git a/applications/system/ir_remote/infrared_last_settings.h b/applications/system/ir_remote/infrared_last_settings.h new file mode 100644 index 000000000..ae88e4184 --- /dev/null +++ b/applications/system/ir_remote/infrared_last_settings.h @@ -0,0 +1 @@ +#include diff --git a/applications/system/ir_remote/infrared_remote_app.c b/applications/system/ir_remote/infrared_remote_app.c index 43d7dbd2b..7cbf717b5 100644 --- a/applications/system/ir_remote/infrared_remote_app.c +++ b/applications/system/ir_remote/infrared_remote_app.c @@ -8,6 +8,8 @@ #include #include #include +#include "infrared_last_settings.h" +#include #include #include @@ -400,6 +402,26 @@ int32_t infrared_remote_app(char* p) { flipper_format_free(ff); furi_record_close(RECORD_STORAGE); + bool otg_was_enabled = furi_hal_power_is_otg_enabled(); + InfraredLastSettings* last_settings = infrared_last_settings_alloc(); + infrared_last_settings_load(last_settings); + + furi_hal_infrared_set_auto_detect(last_settings->auto_detect); + if(!last_settings->auto_detect) { + furi_hal_infrared_set_debug_out(last_settings->ext_out); + if(last_settings->ext_5v) { + uint8_t attempts = 0; + while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { + furi_hal_power_enable_otg(); + furi_delay_ms(10); + } + } else if(furi_hal_power_is_otg_enabled()) { + furi_hal_power_disable_otg(); + } + } else if(furi_hal_power_is_otg_enabled()) { + furi_hal_power_disable_otg(); + } + bool running = true; NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); @@ -541,6 +563,19 @@ int32_t infrared_remote_app(char* p) { } } + if(otg_was_enabled != furi_hal_power_is_otg_enabled()) { + if(otg_was_enabled) { + uint8_t attempts = 0; + while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { + furi_hal_power_enable_otg(); + furi_delay_ms(10); + } + } else { + furi_hal_power_disable_otg(); + } + } + infrared_last_settings_free(last_settings); + // Free all things furi_string_free(app->up_button); furi_string_free(app->down_button);