2022-02-25 15:22:58 +00:00
|
|
|
#include "../infrared_app.h"
|
2021-06-02 15:16:05 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SubmenuIndexUniversalLibrary,
|
|
|
|
SubmenuIndexLearnNewRemote,
|
|
|
|
SubmenuIndexSavedRemotes,
|
|
|
|
} SubmenuIndex;
|
|
|
|
|
|
|
|
static void submenu_callback(void* context, uint32_t index) {
|
2022-02-25 15:22:58 +00:00
|
|
|
InfraredApp* app = static_cast<InfraredApp*>(context);
|
|
|
|
InfraredAppEvent event;
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
event.type = InfraredAppEvent::Type::MenuSelected;
|
2021-06-02 15:16:05 +00:00
|
|
|
event.payload.menu_index = index;
|
|
|
|
|
|
|
|
app->get_view_manager()->send_event(&event);
|
|
|
|
}
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
void InfraredAppSceneStart::on_enter(InfraredApp* app) {
|
|
|
|
InfraredAppViewManager* view_manager = app->get_view_manager();
|
2021-06-02 15:16:05 +00:00
|
|
|
Submenu* submenu = view_manager->get_submenu();
|
|
|
|
|
|
|
|
submenu_add_item(
|
2022-04-11 11:54:38 +00:00
|
|
|
submenu, "Universal Library", SubmenuIndexUniversalLibrary, submenu_callback, app);
|
2021-06-02 15:16:05 +00:00
|
|
|
submenu_add_item(
|
2022-04-11 11:54:38 +00:00
|
|
|
submenu, "Learn New Remote", SubmenuIndexLearnNewRemote, submenu_callback, app);
|
|
|
|
submenu_add_item(submenu, "Saved Remotes", SubmenuIndexSavedRemotes, submenu_callback, app);
|
2021-06-09 13:04:49 +00:00
|
|
|
submenu_set_selected_item(submenu, submenu_item_selected);
|
|
|
|
submenu_item_selected = 0;
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
view_manager->switch_to(InfraredAppViewManager::ViewId::Submenu);
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
bool InfraredAppSceneStart::on_event(InfraredApp* app, InfraredAppEvent* event) {
|
2021-06-02 15:16:05 +00:00
|
|
|
bool consumed = false;
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
if(event->type == InfraredAppEvent::Type::MenuSelected) {
|
2021-06-09 13:04:49 +00:00
|
|
|
submenu_item_selected = event->payload.menu_index;
|
2021-06-02 15:16:05 +00:00
|
|
|
switch(event->payload.menu_index) {
|
|
|
|
case SubmenuIndexUniversalLibrary:
|
2022-02-25 15:22:58 +00:00
|
|
|
app->switch_to_next_scene(InfraredApp::Scene::Universal);
|
2021-06-02 15:16:05 +00:00
|
|
|
break;
|
|
|
|
case SubmenuIndexLearnNewRemote:
|
|
|
|
app->set_learn_new_remote(true);
|
2022-02-25 15:22:58 +00:00
|
|
|
app->switch_to_next_scene(InfraredApp::Scene::Learn);
|
2021-06-02 15:16:05 +00:00
|
|
|
break;
|
|
|
|
case SubmenuIndexSavedRemotes:
|
2022-02-25 15:22:58 +00:00
|
|
|
app->switch_to_next_scene(InfraredApp::Scene::RemoteList);
|
2021-06-02 15:16:05 +00:00
|
|
|
break;
|
2021-06-09 13:04:49 +00:00
|
|
|
default:
|
|
|
|
furi_assert(0);
|
|
|
|
break;
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|
|
|
|
consumed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
void InfraredAppSceneStart::on_exit(InfraredApp* app) {
|
|
|
|
InfraredAppViewManager* view_manager = app->get_view_manager();
|
2021-06-02 15:16:05 +00:00
|
|
|
Submenu* submenu = view_manager->get_submenu();
|
|
|
|
|
2021-07-22 00:07:00 +00:00
|
|
|
app->get_remote_manager()->reset_remote();
|
2022-01-21 17:32:03 +00:00
|
|
|
submenu_reset(submenu);
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|