desktop_scene_hw_mismatch.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <gui/scene_manager.h>
  2. #include <furi_hal.h>
  3. #include "desktop_scene.h"
  4. #include "../desktop_i.h"
  5. #define HW_MISMATCH_BACK_EVENT (0UL)
  6. void desktop_scene_hw_mismatch_callback(void* context) {
  7. Desktop* desktop = (Desktop*)context;
  8. view_dispatcher_send_custom_event(desktop->view_dispatcher, HW_MISMATCH_BACK_EVENT);
  9. }
  10. void desktop_scene_hw_mismatch_on_enter(void* context) {
  11. Desktop* desktop = (Desktop*)context;
  12. furi_assert(desktop);
  13. Popup* popup = desktop->hw_mismatch_popup;
  14. char* text_buffer = malloc(256);
  15. scene_manager_set_scene_state(
  16. desktop->scene_manager, DesktopSceneHwMismatch, (uint32_t)text_buffer);
  17. snprintf(
  18. text_buffer,
  19. 256,
  20. "HW target: %d\nFW target: %d",
  21. furi_hal_version_get_hw_target(),
  22. version_get_target(NULL));
  23. popup_set_context(popup, desktop);
  24. popup_set_header(
  25. popup, "!!!! HW Mismatch !!!!", 60, 14 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
  26. popup_set_text(popup, text_buffer, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
  27. popup_set_callback(popup, desktop_scene_hw_mismatch_callback);
  28. view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdHwMismatch);
  29. }
  30. bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event) {
  31. Desktop* desktop = (Desktop*)context;
  32. bool consumed = false;
  33. if(event.type == SceneManagerEventTypeCustom) {
  34. switch(event.event) {
  35. case HW_MISMATCH_BACK_EVENT:
  36. scene_manager_previous_scene(desktop->scene_manager);
  37. consumed = true;
  38. break;
  39. default:
  40. break;
  41. }
  42. }
  43. return consumed;
  44. }
  45. void desktop_scene_hw_mismatch_on_exit(void* context) {
  46. Desktop* desktop = (Desktop*)context;
  47. furi_assert(desktop);
  48. Popup* popup = desktop->hw_mismatch_popup;
  49. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  50. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  51. popup_set_callback(popup, NULL);
  52. popup_set_context(popup, NULL);
  53. char* text_buffer =
  54. (char*)scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneHwMismatch);
  55. free(text_buffer);
  56. scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneHwMismatch, 0);
  57. }