From 7a1ff13bb62450643f012665cbeca1de572d086f Mon Sep 17 00:00:00 2001 From: Sil333033 <94360907+Sil333033@users.noreply.github.com> Date: Sat, 27 Jan 2024 20:43:56 +0100 Subject: [PATCH] cleanup & format --- applications/main/infrared/infrared_app_i.h | 2 -- .../scenes/infrared_scene_debug_settings.c | 20 ++++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/applications/main/infrared/infrared_app_i.h b/applications/main/infrared/infrared_app_i.h index 72797d1de..1aa77e0e8 100644 --- a/applications/main/infrared/infrared_app_i.h +++ b/applications/main/infrared/infrared_app_i.h @@ -31,7 +31,6 @@ #include "infrared_remote.h" #include "infrared_brute_force.h" #include "infrared_custom_event.h" -// #include "infrared_last_settings.h" #include "scenes/infrared_scene.h" #include "views/infrared_progress_view.h" @@ -129,7 +128,6 @@ struct InfraredApp { /** Arbitrary text storage for various inputs. */ char text_store[INFRARED_TEXT_STORE_NUM][INFRARED_TEXT_STORE_SIZE + 1]; InfraredAppState app_state; /**< Application state. */ - //InfraredLastSettings* last_settings; /**< Last settings. */ void* rpc_ctx; /**< Pointer to the RPC context object. */ }; diff --git a/applications/main/infrared/scenes/infrared_scene_debug_settings.c b/applications/main/infrared/scenes/infrared_scene_debug_settings.c index 4cebc8fa9..a3ec1b461 100644 --- a/applications/main/infrared/scenes/infrared_scene_debug_settings.c +++ b/applications/main/infrared/scenes/infrared_scene_debug_settings.c @@ -21,13 +21,21 @@ static void infrared_scene_debug_settings_changed(VariableItem* item) { } } else { furi_hal_infrared_block_external_output(false); + if(furi_hal_infrared_is_external_connected() && !furi_hal_power_is_otg_enabled()) { + uint8_t attempts = 0; + while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { + furi_hal_power_enable_otg(); + furi_delay_ms(10); + } + } } } static void infrared_scene_debug_settings_power_changed(VariableItem* item) { bool value = variable_item_get_current_value_index(item); if(value) { - for(int i = 0; i < 5 && !furi_hal_power_is_otg_enabled(); i++) { + uint8_t attempts = 0; + while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { furi_hal_power_enable_otg(); furi_delay_ms(10); } @@ -72,13 +80,15 @@ void infrared_scene_debug_settings_on_enter(void* context) { 2, infrared_scene_debug_settings_power_changed, infrared); - bool enabled = furi_hal_power_is_otg_enabled() || - furi_hal_power_is_charging() || // 5v is enabled via hardware if charging - furi_hal_infrared_is_external_connected(); + bool enabled = (furi_hal_power_is_otg_enabled() || + furi_hal_power_is_charging()) && // 5v is enabled via hardware if charging + furi_hal_infrared_is_external_connected() && + !furi_hal_infrared_is_external_output_blocked(); variable_item_set_current_value_index(item, enabled); variable_item_set_current_value_text(item, enabled ? "ON" : "OFF"); - if(furi_hal_infrared_is_external_connected() && !furi_hal_power_is_otg_enabled()) { + if(furi_hal_infrared_is_external_connected() && !furi_hal_power_is_otg_enabled() && + !furi_hal_infrared_is_external_output_blocked()) { uint8_t attempts = 0; while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { furi_hal_power_enable_otg();