mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 14:28:36 -07:00
Improve infrared gpio setting consistency
This commit is contained in:
@@ -14,35 +14,29 @@ static void infrared_scene_debug_settings_auto_detect_changed(VariableItem* item
|
||||
|
||||
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
|
||||
|
||||
if(value == 0) {
|
||||
furi_hal_infrared_set_auto_detect(false);
|
||||
// enable other list items
|
||||
VariableItemList* variable_item_list = infrared->variable_item_list;
|
||||
VariableItem* item = variable_item_list_get(variable_item_list, 1);
|
||||
variable_item_set_current_value_index(item, infrared->last_settings->ext_out);
|
||||
variable_item_set_current_value_text(
|
||||
item, infrared_debug_cfg_variables_text[infrared->last_settings->ext_out]);
|
||||
variable_item_set_locked(item, false, "");
|
||||
// enable/disable other list items
|
||||
VariableItemList* var_item_list = infrared->variable_item_list;
|
||||
variable_item_set_locked(variable_item_list_get(var_item_list, 1), value, NULL);
|
||||
variable_item_set_locked(variable_item_list_get(var_item_list, 2), value, NULL);
|
||||
|
||||
item = variable_item_list_get(variable_item_list, 2);
|
||||
variable_item_set_current_value_index(item, infrared->last_settings->ext_5v);
|
||||
variable_item_set_current_value_text(item, infrared->last_settings->ext_5v ? "ON" : "OFF");
|
||||
variable_item_set_locked(item, false, "");
|
||||
} else {
|
||||
furi_hal_infrared_set_auto_detect(true);
|
||||
// disable other list items
|
||||
VariableItemList* variable_item_list = infrared->variable_item_list;
|
||||
VariableItem* item = variable_item_list_get(variable_item_list, 1);
|
||||
variable_item_set_current_value_index(item, 0);
|
||||
variable_item_set_locked(item, true, "Disable auto detect");
|
||||
|
||||
item = variable_item_list_get(variable_item_list, 2);
|
||||
variable_item_set_current_value_index(item, 0);
|
||||
variable_item_set_locked(item, true, "Disable auto detect");
|
||||
}
|
||||
|
||||
infrared->last_settings->auto_detect = value == 1;
|
||||
infrared->last_settings->auto_detect = value;
|
||||
infrared_last_settings_save(infrared->last_settings);
|
||||
|
||||
furi_hal_infrared_set_auto_detect(infrared->last_settings->auto_detect);
|
||||
if(!infrared->last_settings->auto_detect) {
|
||||
furi_hal_infrared_set_debug_out(infrared->last_settings->ext_out);
|
||||
if(infrared->last_settings->ext_5v) {
|
||||
uint8_t attempts = 0;
|
||||
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
|
||||
furi_hal_power_enable_otg();
|
||||
furi_delay_ms(10);
|
||||
}
|
||||
} else if(furi_hal_power_is_otg_enabled()) {
|
||||
furi_hal_power_disable_otg();
|
||||
}
|
||||
} else if(furi_hal_power_is_otg_enabled()) {
|
||||
furi_hal_power_disable_otg();
|
||||
}
|
||||
}
|
||||
|
||||
static void infrared_scene_debug_settings_pin_changed(VariableItem* item) {
|
||||
@@ -96,7 +90,7 @@ void infrared_scene_debug_settings_on_enter(void* context) {
|
||||
infrared_scene_debug_settings_auto_detect_changed,
|
||||
infrared);
|
||||
|
||||
bool auto_detect = furi_hal_infrared_is_auto_detect_enabled();
|
||||
bool auto_detect = infrared->last_settings->auto_detect;
|
||||
|
||||
variable_item_set_current_value_index(item, auto_detect);
|
||||
variable_item_set_current_value_text(item, auto_detect ? "ON" : "OFF");
|
||||
@@ -108,16 +102,14 @@ void infrared_scene_debug_settings_on_enter(void* context) {
|
||||
infrared_scene_debug_settings_pin_changed,
|
||||
infrared);
|
||||
|
||||
value_index_ir = furi_hal_infrared_get_debug_out_status();
|
||||
value_index_ir = infrared->last_settings->ext_out;
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
variable_item_list, infrared_debug_settings_start_var_list_enter_callback, infrared);
|
||||
|
||||
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]);
|
||||
if(auto_detect) {
|
||||
variable_item_set_locked(item, true, "Disable auto detect");
|
||||
}
|
||||
variable_item_set_locked(item, auto_detect, "Disable auto detect");
|
||||
|
||||
item = variable_item_list_add(
|
||||
variable_item_list,
|
||||
@@ -125,13 +117,10 @@ 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;
|
||||
bool enabled = infrared->last_settings->ext_5v;
|
||||
variable_item_set_current_value_index(item, enabled);
|
||||
variable_item_set_current_value_text(item, enabled ? "ON" : "OFF");
|
||||
if(auto_detect) {
|
||||
variable_item_set_locked(item, true, "Disable auto detect");
|
||||
}
|
||||
variable_item_set_locked(item, auto_detect, "Disable auto detect");
|
||||
|
||||
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewVariableItemList);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user