|
@@ -8,6 +8,9 @@
|
|
|
#include <dialogs/dialogs.h>
|
|
#include <dialogs/dialogs.h>
|
|
|
#include <ir_remote_icons.h>
|
|
#include <ir_remote_icons.h>
|
|
|
|
|
|
|
|
|
|
+#include <infrared/infrared_app.h>
|
|
|
|
|
+#include <toolbox/saved_struct.h>
|
|
|
|
|
+
|
|
|
#include <notification/notification.h>
|
|
#include <notification/notification.h>
|
|
|
#include <notification/notification_messages.h>
|
|
#include <notification/notification_messages.h>
|
|
|
|
|
|
|
@@ -109,8 +112,7 @@ static void app_input_callback(InputEvent* input_event, void* ctx) {
|
|
|
furi_message_queue_put(event_queue, input_event, FuriWaitForever);
|
|
furi_message_queue_put(event_queue, input_event, FuriWaitForever);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int32_t infrared_remote_app(void* p) {
|
|
|
|
|
- UNUSED(p);
|
|
|
|
|
|
|
+int32_t infrared_remote_app(char* p) {
|
|
|
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
|
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
|
|
|
|
|
|
|
// App button string
|
|
// App button string
|
|
@@ -139,18 +141,26 @@ int32_t infrared_remote_app(void* p) {
|
|
|
|
|
|
|
|
InputEvent event;
|
|
InputEvent event;
|
|
|
|
|
|
|
|
|
|
+ FuriString* map_file = furi_string_alloc();
|
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
FlipperFormat* ff = flipper_format_file_alloc(storage);
|
|
FlipperFormat* ff = flipper_format_file_alloc(storage);
|
|
|
|
|
+ if(!storage_file_exists(storage, IR_REMOTE_PATH)) {
|
|
|
|
|
+ storage_common_mkdir(storage, IR_REMOTE_PATH); //Make Folder If dir not exist
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
|
|
|
|
|
- DialogsFileBrowserOptions browser_options;
|
|
|
|
|
- dialog_file_browser_set_basic_options(&browser_options, ".txt", &I_sub1_10px);
|
|
|
|
|
- FuriString* map_file = furi_string_alloc();
|
|
|
|
|
- furi_string_set(map_file, "/ext/ir_remote");
|
|
|
|
|
-
|
|
|
|
|
- bool res = dialog_file_browser_show(dialogs, map_file, map_file, &browser_options);
|
|
|
|
|
-
|
|
|
|
|
- furi_record_close(RECORD_DIALOGS);
|
|
|
|
|
|
|
+ bool res;
|
|
|
|
|
+ if(p && strlen(p)) {
|
|
|
|
|
+ furi_string_set(map_file, p);
|
|
|
|
|
+ res = true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
|
|
|
|
|
+ DialogsFileBrowserOptions browser_options;
|
|
|
|
|
+ dialog_file_browser_set_basic_options(&browser_options, ".txt", &I_sub1_10px);
|
|
|
|
|
+ browser_options.base_path = IR_REMOTE_PATH;
|
|
|
|
|
+ furi_string_set(map_file, IR_REMOTE_PATH);
|
|
|
|
|
+ res = dialog_file_browser_show(dialogs, map_file, map_file, &browser_options);
|
|
|
|
|
+ furi_record_close(RECORD_DIALOGS);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// if user didn't choose anything, free everything and exit
|
|
// if user didn't choose anything, free everything and exit
|
|
|
if(!res) {
|
|
if(!res) {
|
|
@@ -392,6 +402,31 @@ int32_t infrared_remote_app(void* p) {
|
|
|
flipper_format_free(ff);
|
|
flipper_format_free(ff);
|
|
|
furi_record_close(RECORD_STORAGE);
|
|
furi_record_close(RECORD_STORAGE);
|
|
|
|
|
|
|
|
|
|
+ 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;
|
|
bool running = true;
|
|
|
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
|
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
|
|
|
|
|
|
@@ -533,6 +568,15 @@ int32_t infrared_remote_app(void* p) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ furi_hal_infrared_set_tx_output(FuriHalInfraredTxPinInternal);
|
|
|
|
|
+ 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
|
|
// Free all things
|
|
|
furi_string_free(app->up_button);
|
|
furi_string_free(app->up_button);
|
|
|
furi_string_free(app->down_button);
|
|
furi_string_free(app->down_button);
|