cleanup & format

This commit is contained in:
Sil333033
2024-01-27 20:43:56 +01:00
parent a18c757097
commit 7a1ff13bb6
2 changed files with 15 additions and 7 deletions

View File

@@ -31,7 +31,6 @@
#include "infrared_remote.h" #include "infrared_remote.h"
#include "infrared_brute_force.h" #include "infrared_brute_force.h"
#include "infrared_custom_event.h" #include "infrared_custom_event.h"
// #include "infrared_last_settings.h"
#include "scenes/infrared_scene.h" #include "scenes/infrared_scene.h"
#include "views/infrared_progress_view.h" #include "views/infrared_progress_view.h"
@@ -129,7 +128,6 @@ struct InfraredApp {
/** Arbitrary text storage for various inputs. */ /** Arbitrary text storage for various inputs. */
char text_store[INFRARED_TEXT_STORE_NUM][INFRARED_TEXT_STORE_SIZE + 1]; char text_store[INFRARED_TEXT_STORE_NUM][INFRARED_TEXT_STORE_SIZE + 1];
InfraredAppState app_state; /**< Application state. */ InfraredAppState app_state; /**< Application state. */
//InfraredLastSettings* last_settings; /**< Last settings. */
void* rpc_ctx; /**< Pointer to the RPC context object. */ void* rpc_ctx; /**< Pointer to the RPC context object. */
}; };

View File

@@ -21,13 +21,21 @@ static void infrared_scene_debug_settings_changed(VariableItem* item) {
} }
} else { } else {
furi_hal_infrared_block_external_output(false); 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) { static void infrared_scene_debug_settings_power_changed(VariableItem* item) {
bool value = variable_item_get_current_value_index(item); bool value = variable_item_get_current_value_index(item);
if(value) { 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_hal_power_enable_otg();
furi_delay_ms(10); furi_delay_ms(10);
} }
@@ -72,13 +80,15 @@ void infrared_scene_debug_settings_on_enter(void* context) {
2, 2,
infrared_scene_debug_settings_power_changed, infrared_scene_debug_settings_power_changed,
infrared); infrared);
bool enabled = furi_hal_power_is_otg_enabled() || bool enabled = (furi_hal_power_is_otg_enabled() ||
furi_hal_power_is_charging() || // 5v is enabled via hardware if charging furi_hal_power_is_charging()) && // 5v is enabled via hardware if charging
furi_hal_infrared_is_external_connected(); 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_index(item, enabled);
variable_item_set_current_value_text(item, enabled ? "ON" : "OFF"); 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; uint8_t attempts = 0;
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
furi_hal_power_enable_otg(); furi_hal_power_enable_otg();