desktop_scene_hw_mismatch.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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: F%d\nFW target: " TARGET,
  16. furi_hal_version_get_hw_target());
  17. popup_set_context(popup, desktop);
  18. popup_set_header(popup, "!!!! HW Mismatch !!!!", 60, 14, AlignCenter, AlignCenter);
  19. popup_set_text(popup, buffer, 60, 37, AlignCenter, AlignCenter);
  20. popup_set_callback(popup, desktop_scene_hw_mismatch_callback);
  21. view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewHwMismatch);
  22. }
  23. bool desktop_scene_hw_mismatch_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 HW_MISMATCH_BACK_EVENT:
  29. scene_manager_previous_scene(desktop->scene_manager);
  30. consumed = true;
  31. break;
  32. default:
  33. break;
  34. }
  35. }
  36. return consumed;
  37. }
  38. void desktop_scene_hw_mismatch_on_exit(void* context) {
  39. Desktop* desktop = (Desktop*)context;
  40. Popup* popup = desktop->hw_mismatch_popup;
  41. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  42. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  43. popup_set_callback(popup, NULL);
  44. popup_set_context(popup, NULL);
  45. }