Support ext module in IR Remote

This commit is contained in:
Willy-JL
2024-01-28 05:58:49 +00:00
parent 001ba8001d
commit d37d316eb7
3 changed files with 37 additions and 0 deletions

View File

@@ -0,0 +1 @@
#include <applications/main/infrared/infrared_last_settings.c>

View File

@@ -0,0 +1 @@
#include <applications/main/infrared/infrared_last_settings.h>

View File

@@ -8,6 +8,8 @@
#include <dialogs/dialogs.h>
#include <ir_remote_icons.h>
#include <assets_icons.h>
#include "infrared_last_settings.h"
#include <furi_hal_infrared.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
@@ -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);