diff --git a/applications/external b/applications/external index 8fc8f9a6b..b55284793 160000 --- a/applications/external +++ b/applications/external @@ -1 +1 @@ -Subproject commit 8fc8f9a6bd75c533bb9d26da5154396b6b680ac5 +Subproject commit b55284793396994ceb621b5ca77b78f8673d7c1b diff --git a/applications/main/infrared/infrared_app.c b/applications/main/infrared/infrared_app.c index 3ea786c51..b42bfe63e 100644 --- a/applications/main/infrared/infrared_app.c +++ b/applications/main/infrared/infrared_app.c @@ -12,14 +12,6 @@ #define INFRARED_TX_MIN_INTERVAL_MS (50U) #define INFRARED_TASK_STACK_SIZE (2048UL) -#define INFRARED_SETTINGS_VERSION (1) -#define INFRARED_SETTINGS_MAGIC (0x1F) - -typedef struct { - FuriHalInfraredTxPin tx_pin; - bool otg_enabled; -} InfraredSettings; - static const NotificationSequence* infrared_notification_sequences[InfraredNotificationMessageCount] = { &sequence_success, diff --git a/applications/main/infrared/infrared_app.h b/applications/main/infrared/infrared_app.h index 09478abcd..6b7b8821a 100644 --- a/applications/main/infrared/infrared_app.h +++ b/applications/main/infrared/infrared_app.h @@ -15,4 +15,13 @@ typedef struct InfraredApp InfraredApp; #include +#include + #define INFRARED_SETTINGS_PATH EXT_PATH("infrared/.infrared.settings") +#define INFRARED_SETTINGS_VERSION (1) +#define INFRARED_SETTINGS_MAGIC (0x1F) + +typedef struct { + FuriHalInfraredTxPin tx_pin; + bool otg_enabled; +} InfraredSettings; diff --git a/applications/system/ir_remote/infrared_last_settings.c b/applications/system/ir_remote/infrared_last_settings.c deleted file mode 100644 index 897971b70..000000000 --- a/applications/system/ir_remote/infrared_last_settings.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/applications/system/ir_remote/infrared_remote_app.c b/applications/system/ir_remote/infrared_remote_app.c index 6e0176ff9..dd4ceb29d 100644 --- a/applications/system/ir_remote/infrared_remote_app.c +++ b/applications/system/ir_remote/infrared_remote_app.c @@ -8,7 +8,9 @@ #include #include #include -#include + +#include +#include #include #include @@ -401,9 +403,30 @@ int32_t infrared_remote_app(char* p) { flipper_format_free(ff); furi_record_close(RECORD_STORAGE); - InfraredLastSettings* last_settings = infrared_last_settings_alloc(); - infrared_last_settings_load(last_settings); - infrared_last_settings_apply(last_settings); + bool otg_was_enabled = furi_hal_power_is_otg_enabled(); + InfraredSettings settings = {0}; + saved_struct_load( + INFRARED_SETTINGS_PATH, + &settings, + sizeof(InfraredSettings), + INFRARED_SETTINGS_MAGIC, + INFRARED_SETTINGS_VERSION); + if(settings.tx_pin < FuriHalInfraredTxPinMax) { + furi_hal_infrared_set_tx_output(settings.tx_pin); + if(settings.otg_enabled != otg_was_enabled) { + if(settings.otg_enabled) { + furi_hal_power_enable_otg(); + } else { + furi_hal_power_disable_otg(); + } + } + } else { + FuriHalInfraredTxPin tx_pin_detected = furi_hal_infrared_detect_tx_output(); + furi_hal_infrared_set_tx_output(tx_pin_detected); + if(tx_pin_detected != FuriHalInfraredTxPinInternal) { + furi_hal_power_enable_otg(); + } + } bool running = true; NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); @@ -546,8 +569,13 @@ int32_t infrared_remote_app(char* p) { } } - infrared_last_settings_reset(last_settings); - infrared_last_settings_free(last_settings); + if(furi_hal_power_is_otg_enabled() != otg_was_enabled) { + if(otg_was_enabled) { + furi_hal_power_enable_otg(); + } else { + furi_hal_power_disable_otg(); + } + } // Free all things furi_string_free(app->up_button);