Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
cleanup & format
Browse files Browse the repository at this point in the history
  • Loading branch information
Sil333033 committed Jan 27, 2024
1 parent a18c757 commit 7a1ff13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 0 additions & 2 deletions applications/main/infrared/infrared_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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. */
};
Expand Down
20 changes: 15 additions & 5 deletions applications/main/infrared/scenes/infrared_scene_debug_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7a1ff13

Please sign in to comment.