nfc_rfid_detector_scene_field_presence.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "../nfc_rfid_detector_app_i.h"
  2. #include "../views/nfc_rfid_detector_view_field_presence.h"
  3. void nfc_rfid_detector_scene_field_presence_callback(
  4. NfcRfidDetectorCustomEvent event,
  5. void* context) {
  6. furi_assert(context);
  7. NfcRfidDetectorApp* app = context;
  8. view_dispatcher_send_custom_event(app->view_dispatcher, event);
  9. }
  10. static const NotificationSequence notification_app_display_on = {
  11. &message_display_backlight_on,
  12. NULL,
  13. };
  14. static void nfc_rfid_detector_scene_field_presence_update(void* context) {
  15. furi_assert(context);
  16. NfcRfidDetectorApp* app = context;
  17. uint32_t frequency = 0;
  18. bool nfc_field = nfc_rfid_detector_app_field_presence_is_nfc(app);
  19. bool rfid_field = nfc_rfid_detector_app_field_presence_is_rfid(app, &frequency);
  20. if(nfc_field || rfid_field)
  21. notification_message(app->notifications, &notification_app_display_on);
  22. nfc_rfid_detector_view_field_presence_update(
  23. app->nfc_rfid_detector_field_presence, nfc_field, rfid_field, frequency);
  24. }
  25. void nfc_rfid_detector_scene_field_presence_on_enter(void* context) {
  26. furi_assert(context);
  27. NfcRfidDetectorApp* app = context;
  28. // Start detection of field presence
  29. nfc_rfid_detector_app_field_presence_start(app);
  30. view_dispatcher_switch_to_view(app->view_dispatcher, NfcRfidDetectorViewFieldPresence);
  31. }
  32. bool nfc_rfid_detector_scene_field_presence_on_event(void* context, SceneManagerEvent event) {
  33. furi_assert(context);
  34. NfcRfidDetectorApp* app = context;
  35. bool consumed = false;
  36. if(event.type == SceneManagerEventTypeTick) {
  37. nfc_rfid_detector_scene_field_presence_update(app);
  38. }
  39. return consumed;
  40. }
  41. void nfc_rfid_detector_scene_field_presence_on_exit(void* context) {
  42. furi_assert(context);
  43. NfcRfidDetectorApp* app = context;
  44. // Stop detection of field presence
  45. nfc_rfid_detector_app_field_presence_stop(app);
  46. }