Infrared external output move out of debug and add power option

This commit is contained in:
MX 2023-05-11 03:15:15 +03:00
parent 654a622607
commit a1fa5224a3
No known key found for this signature in database
GPG Key ID: 7CCC66B7DBDD1C83
3 changed files with 40 additions and 9 deletions

View File

@ -246,6 +246,11 @@ static void infrared_free(Infrared* infrared) {
furi_string_free(infrared->file_path);
// Disable 5v power if was enabled for external module
if(furi_hal_power_is_otg_enabled()) {
furi_hal_power_disable_otg();
}
free(infrared);
}

View File

@ -18,6 +18,22 @@ static void infrared_scene_debug_settings_changed(VariableItem* item) {
furi_hal_infrared_set_debug_out(value_index_ir);
}
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++) {
furi_hal_power_enable_otg();
furi_delay_ms(10);
}
} else {
if(furi_hal_power_is_otg_enabled()) {
furi_hal_power_disable_otg();
}
}
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
}
static void infrared_debug_settings_start_var_list_enter_callback(void* context, uint32_t index) {
Infrared* infrared = context;
view_dispatcher_send_custom_event(infrared->view_dispatcher, index);
@ -42,6 +58,16 @@ void infrared_scene_debug_settings_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index_ir);
variable_item_set_current_value_text(item, infrared_debug_cfg_variables_text[value_index_ir]);
item = variable_item_list_add(
variable_item_list,
"Ext Module 5v",
2,
infrared_scene_debug_settings_power_changed,
infrared);
bool enabled = furi_hal_power_is_otg_enabled();
variable_item_set_current_value_index(item, enabled);
variable_item_set_current_value_text(item, enabled ? "ON" : "OFF");
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewVariableItemList);
}

View File

@ -3,10 +3,10 @@
enum SubmenuIndex {
SubmenuIndexUniversalRemotes,
SubmenuIndexLearnNewRemote,
SubmenuIndexLearnNewRemoteRaw,
SubmenuIndexSavedRemotes,
SubmenuIndexDebug,
SubmenuIndexDebugSettings
SubmenuIndexDebugSettings,
SubmenuIndexLearnNewRemoteRaw,
SubmenuIndexDebug
};
static void infrared_scene_start_submenu_callback(void* context, uint32_t index) {
@ -37,6 +37,12 @@ void infrared_scene_start_on_enter(void* context) {
SubmenuIndexSavedRemotes,
infrared_scene_start_submenu_callback,
infrared);
submenu_add_item(
submenu,
"GPIO Settings",
SubmenuIndexDebugSettings,
infrared_scene_start_submenu_callback,
infrared);
if(infrared->app_state.is_debug_enabled) {
submenu_add_item(
@ -51,12 +57,6 @@ void infrared_scene_start_on_enter(void* context) {
SubmenuIndexDebug,
infrared_scene_start_submenu_callback,
infrared);
submenu_add_item(
submenu,
"Debug Settings",
SubmenuIndexDebugSettings,
infrared_scene_start_submenu_callback,
infrared);
}
const uint32_t submenu_index =