2022-06-21 15:45:50 +03:00
|
|
|
#include "../infrared_i.h"
|
|
|
|
|
|
|
|
enum SubmenuIndex {
|
|
|
|
SubmenuIndexUniversalRemotes,
|
|
|
|
SubmenuIndexLearnNewRemote,
|
|
|
|
SubmenuIndexSavedRemotes,
|
2023-05-11 03:15:15 +03:00
|
|
|
SubmenuIndexDebugSettings,
|
|
|
|
SubmenuIndexLearnNewRemoteRaw,
|
|
|
|
SubmenuIndexDebug
|
2022-06-21 15:45:50 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void infrared_scene_start_submenu_callback(void* context, uint32_t index) {
|
|
|
|
Infrared* infrared = context;
|
|
|
|
view_dispatcher_send_custom_event(infrared->view_dispatcher, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void infrared_scene_start_on_enter(void* context) {
|
|
|
|
Infrared* infrared = context;
|
|
|
|
Submenu* submenu = infrared->submenu;
|
|
|
|
SceneManager* scene_manager = infrared->scene_manager;
|
|
|
|
|
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Universal Remotes",
|
|
|
|
SubmenuIndexUniversalRemotes,
|
|
|
|
infrared_scene_start_submenu_callback,
|
|
|
|
infrared);
|
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Learn New Remote",
|
|
|
|
SubmenuIndexLearnNewRemote,
|
|
|
|
infrared_scene_start_submenu_callback,
|
|
|
|
infrared);
|
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Saved Remotes",
|
|
|
|
SubmenuIndexSavedRemotes,
|
|
|
|
infrared_scene_start_submenu_callback,
|
|
|
|
infrared);
|
2023-05-11 03:15:15 +03:00
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"GPIO Settings",
|
|
|
|
SubmenuIndexDebugSettings,
|
|
|
|
infrared_scene_start_submenu_callback,
|
|
|
|
infrared);
|
2022-06-21 15:45:50 +03:00
|
|
|
|
|
|
|
if(infrared->app_state.is_debug_enabled) {
|
2023-01-08 04:05:17 +03:00
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Learn New Remote RAW",
|
|
|
|
SubmenuIndexLearnNewRemoteRaw,
|
|
|
|
infrared_scene_start_submenu_callback,
|
|
|
|
infrared);
|
2022-06-21 15:45:50 +03:00
|
|
|
submenu_add_item(
|
2023-02-26 05:23:26 +03:00
|
|
|
submenu,
|
|
|
|
"Debug RX",
|
|
|
|
SubmenuIndexDebug,
|
|
|
|
infrared_scene_start_submenu_callback,
|
|
|
|
infrared);
|
2022-06-21 15:45:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const uint32_t submenu_index =
|
|
|
|
scene_manager_get_scene_state(scene_manager, InfraredSceneStart);
|
|
|
|
submenu_set_selected_item(submenu, submenu_index);
|
|
|
|
scene_manager_set_scene_state(scene_manager, InfraredSceneStart, SubmenuIndexUniversalRemotes);
|
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewSubmenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool infrared_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
Infrared* infrared = context;
|
|
|
|
SceneManager* scene_manager = infrared->scene_manager;
|
|
|
|
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
const uint32_t submenu_index = event.event;
|
|
|
|
scene_manager_set_scene_state(scene_manager, InfraredSceneStart, submenu_index);
|
|
|
|
if(submenu_index == SubmenuIndexUniversalRemotes) {
|
|
|
|
scene_manager_next_scene(scene_manager, InfraredSceneUniversal);
|
|
|
|
consumed = true;
|
2023-01-08 04:05:17 +03:00
|
|
|
} else if(
|
|
|
|
submenu_index == SubmenuIndexLearnNewRemote ||
|
|
|
|
submenu_index == SubmenuIndexLearnNewRemoteRaw) {
|
|
|
|
// enable automatic signal decoding if "Learn New Remote"
|
|
|
|
// disable automatic signal decoding if "Learn New Remote (RAW)"
|
|
|
|
infrared_worker_rx_enable_signal_decoding(
|
|
|
|
infrared->worker, submenu_index == SubmenuIndexLearnNewRemote);
|
|
|
|
|
2022-06-21 15:45:50 +03:00
|
|
|
infrared->app_state.is_learning_new_remote = true;
|
|
|
|
scene_manager_next_scene(scene_manager, InfraredSceneLearn);
|
|
|
|
consumed = true;
|
|
|
|
} else if(submenu_index == SubmenuIndexSavedRemotes) {
|
2022-10-05 18:15:23 +03:00
|
|
|
furi_string_set(infrared->file_path, INFRARED_APP_FOLDER);
|
2022-06-21 15:45:50 +03:00
|
|
|
scene_manager_next_scene(scene_manager, InfraredSceneRemoteList);
|
|
|
|
consumed = true;
|
|
|
|
} else if(submenu_index == SubmenuIndexDebug) {
|
|
|
|
scene_manager_next_scene(scene_manager, InfraredSceneDebug);
|
|
|
|
consumed = true;
|
2023-02-26 05:23:26 +03:00
|
|
|
} else if(submenu_index == SubmenuIndexDebugSettings) {
|
|
|
|
scene_manager_next_scene(scene_manager, InfraredSceneDebugSettings);
|
|
|
|
consumed = true;
|
2022-06-21 15:45:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void infrared_scene_start_on_exit(void* context) {
|
|
|
|
Infrared* infrared = context;
|
|
|
|
submenu_reset(infrared->submenu);
|
|
|
|
}
|