desktop_scene_hw_mismatch.c 2.0 KB

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