irda-app-scene-learn.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "../irda-app.hpp"
  2. void IrdaAppSceneLearn::on_enter(IrdaApp* app) {
  3. auto view_manager = app->get_view_manager();
  4. auto receiver = app->get_receiver();
  5. auto event_queue = view_manager->get_event_queue();
  6. receiver->capture_once_start(event_queue);
  7. auto popup = view_manager->get_popup();
  8. popup_set_icon(popup, 0, 32, I_IrdaLearnShort_128x31);
  9. popup_set_text(
  10. popup, "Point the remote at IR port\nand push the button", 5, 10, AlignLeft, AlignCenter);
  11. popup_set_callback(popup, NULL);
  12. if(app->get_learn_new_remote()) {
  13. app->notify_double_vibro();
  14. }
  15. view_manager->switch_to(IrdaAppViewManager::ViewType::Popup);
  16. }
  17. bool IrdaAppSceneLearn::on_event(IrdaApp* app, IrdaAppEvent* event) {
  18. bool consumed = false;
  19. if(event->type == IrdaAppEvent::Type::Tick) {
  20. consumed = true;
  21. app->notify_red_blink();
  22. }
  23. if(event->type == IrdaAppEvent::Type::IrdaMessageReceived) {
  24. app->notify_success();
  25. app->switch_to_next_scene_without_saving(IrdaApp::Scene::LearnSuccess);
  26. }
  27. return consumed;
  28. }
  29. void IrdaAppSceneLearn::on_exit(IrdaApp* app) {
  30. }