desktop_scene_hw_mismatch.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. Popup* popup = desktop->hw_mismatch_popup;
  11. char buffer[256]; // strange but smaller buffer not making it
  12. snprintf(
  13. buffer,
  14. sizeof(buffer),
  15. "HW target: %d\nFW target: %d",
  16. furi_hal_version_get_hw_target(),
  17. version_get_target(NULL));
  18. popup_set_context(popup, desktop);
  19. popup_set_header(
  20. popup, "!!!! HW Mismatch !!!!", 60, 14 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
  21. popup_set_text(popup, buffer, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
  22. popup_set_callback(popup, desktop_scene_hw_mismatch_callback);
  23. view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewHwMismatch);
  24. }
  25. bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event) {
  26. Desktop* desktop = (Desktop*)context;
  27. bool consumed = false;
  28. if(event.type == SceneManagerEventTypeCustom) {
  29. switch(event.event) {
  30. case HW_MISMATCH_BACK_EVENT:
  31. scene_manager_previous_scene(desktop->scene_manager);
  32. consumed = true;
  33. break;
  34. default:
  35. break;
  36. }
  37. }
  38. return consumed;
  39. }
  40. void desktop_scene_hw_mismatch_on_exit(void* context) {
  41. Desktop* desktop = (Desktop*)context;
  42. Popup* popup = desktop->hw_mismatch_popup;
  43. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  44. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  45. popup_set_callback(popup, NULL);
  46. popup_set_context(popup, NULL);
  47. }