2021-06-02 15:16:05 +00:00
|
|
|
#include "../irda-app.hpp"
|
|
|
|
|
|
|
|
void IrdaAppSceneLearn::on_enter(IrdaApp* app) {
|
|
|
|
auto view_manager = app->get_view_manager();
|
2021-06-25 13:52:27 +00:00
|
|
|
auto transceiver = app->get_transceiver();
|
2021-06-02 15:16:05 +00:00
|
|
|
auto event_queue = view_manager->get_event_queue();
|
|
|
|
|
2021-06-25 13:52:27 +00:00
|
|
|
transceiver->capture_once_start(event_queue);
|
2021-06-02 15:16:05 +00:00
|
|
|
|
|
|
|
auto popup = view_manager->get_popup();
|
|
|
|
|
|
|
|
popup_set_icon(popup, 0, 32, I_IrdaLearnShort_128x31);
|
|
|
|
popup_set_text(
|
|
|
|
popup, "Point the remote at IR port\nand push the button", 5, 10, AlignLeft, AlignCenter);
|
|
|
|
popup_set_callback(popup, NULL);
|
|
|
|
|
2021-06-09 13:04:49 +00:00
|
|
|
if(app->get_learn_new_remote()) {
|
|
|
|
app->notify_double_vibro();
|
|
|
|
}
|
|
|
|
|
2021-06-02 15:16:05 +00:00
|
|
|
view_manager->switch_to(IrdaAppViewManager::ViewType::Popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IrdaAppSceneLearn::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
|
|
|
bool consumed = false;
|
|
|
|
|
2021-06-09 13:04:49 +00:00
|
|
|
if(event->type == IrdaAppEvent::Type::Tick) {
|
|
|
|
consumed = true;
|
|
|
|
app->notify_red_blink();
|
|
|
|
}
|
2021-06-02 15:16:05 +00:00
|
|
|
if(event->type == IrdaAppEvent::Type::IrdaMessageReceived) {
|
2021-06-09 13:04:49 +00:00
|
|
|
app->notify_success();
|
2021-06-02 15:16:05 +00:00
|
|
|
app->switch_to_next_scene_without_saving(IrdaApp::Scene::LearnSuccess);
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IrdaAppSceneLearn::on_exit(IrdaApp* app) {
|
2021-07-02 12:46:13 +00:00
|
|
|
auto transceiver = app->get_transceiver();
|
|
|
|
transceiver->capture_stop();
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|