desktop_scene_pin_timeout.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <furi.h>
  2. #include <FreeRTOS.h>
  3. #include <portmacro.h>
  4. #include <timer.h>
  5. #include <gui/scene_manager.h>
  6. #include "../desktop_i.h"
  7. #include "../views/desktop_view_pin_timeout.h"
  8. #include "desktop_scene.h"
  9. #include "desktop_scene_i.h"
  10. static void desktop_scene_pin_timeout_callback(void* context) {
  11. Desktop* desktop = (Desktop*)context;
  12. view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopPinTimeoutExit);
  13. }
  14. void desktop_scene_pin_timeout_on_enter(void* context) {
  15. Desktop* desktop = (Desktop*)context;
  16. uint32_t timeout =
  17. scene_manager_get_scene_state(desktop->scene_manager, DesktopScenePinTimeout);
  18. desktop_view_pin_timeout_start(desktop->pin_timeout_view, timeout);
  19. desktop_view_pin_timeout_set_callback(
  20. desktop->pin_timeout_view, desktop_scene_pin_timeout_callback, desktop);
  21. view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdPinTimeout);
  22. }
  23. bool desktop_scene_pin_timeout_on_event(void* context, SceneManagerEvent event) {
  24. Desktop* desktop = (Desktop*)context;
  25. bool consumed = false;
  26. if(event.type == SceneManagerEventTypeCustom) {
  27. switch(event.event) {
  28. case DesktopPinTimeoutExit:
  29. scene_manager_previous_scene(desktop->scene_manager);
  30. consumed = true;
  31. break;
  32. }
  33. }
  34. return consumed;
  35. }
  36. void desktop_scene_pin_timeout_on_exit(void* context) {
  37. UNUSED(context);
  38. }