desktop_scene_hw_mismatch.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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(popup, "!!!! HW Mismatch !!!!", 60, 14, AlignCenter, AlignCenter);
  20. popup_set_text(popup, buffer, 60, 37, AlignCenter, AlignCenter);
  21. popup_set_callback(popup, desktop_scene_hw_mismatch_callback);
  22. view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewHwMismatch);
  23. }
  24. bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event) {
  25. Desktop* desktop = (Desktop*)context;
  26. bool consumed = false;
  27. if(event.type == SceneManagerEventTypeCustom) {
  28. switch(event.event) {
  29. case HW_MISMATCH_BACK_EVENT:
  30. scene_manager_previous_scene(desktop->scene_manager);
  31. consumed = true;
  32. break;
  33. default:
  34. break;
  35. }
  36. }
  37. return consumed;
  38. }
  39. void desktop_scene_hw_mismatch_on_exit(void* context) {
  40. Desktop* desktop = (Desktop*)context;
  41. Popup* popup = desktop->hw_mismatch_popup;
  42. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  43. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  44. popup_set_callback(popup, NULL);
  45. popup_set_context(popup, NULL);
  46. }