nfc_scene_rpc.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "../nfc_i.h"
  2. void nfc_scene_rpc_on_enter(void* context) {
  3. Nfc* nfc = context;
  4. Popup* popup = nfc->popup;
  5. popup_set_header(popup, "NFC", 82, 28, AlignCenter, AlignBottom);
  6. popup_set_text(popup, "RPC mode", 82, 32, AlignCenter, AlignTop);
  7. popup_set_icon(popup, 2, 14, &I_Warning_30x23); // TODO: icon
  8. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
  9. notification_message(nfc->notifications, &sequence_display_backlight_on);
  10. }
  11. bool nfc_scene_rpc_on_event(void* context, SceneManagerEvent event) {
  12. Nfc* nfc = context;
  13. Popup* popup = nfc->popup;
  14. bool consumed = false;
  15. if(event.type == SceneManagerEventTypeCustom) {
  16. consumed = true;
  17. if(event.event == NfcCustomEventViewExit) {
  18. view_dispatcher_stop(nfc->view_dispatcher);
  19. nfc_blink_stop(nfc);
  20. } else if(event.event == NfcCustomEventRpcLoad) {
  21. nfc_blink_start(nfc);
  22. nfc_text_store_set(nfc, "emulating\n%s", nfc->dev->dev_name);
  23. popup_set_text(popup, nfc->text_store, 82, 32, AlignCenter, AlignTop);
  24. }
  25. }
  26. return consumed;
  27. }
  28. void nfc_scene_rpc_on_exit(void* context) {
  29. Nfc* nfc = context;
  30. Popup* popup = nfc->popup;
  31. nfc_rpc_exit_callback(nfc);
  32. nfc_blink_stop(nfc);
  33. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  34. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  35. popup_set_icon(popup, 0, 0, NULL);
  36. }